masterview 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +31 -1
- data/README +70 -69
- data/RELEASE_NOTES +70 -64
- data/Rakefile +26 -27
- data/TODO +13 -29
- data/doc/about.html +246 -0
- data/doc/configuration.html +49 -36
- data/doc/developer.html +423 -41
- data/doc/directives.html +139 -51
- data/doc/guide.html +19 -9
- data/doc/index.html +90 -224
- data/doc/installation.html +36 -28
- data/doc/media_list.html +30 -20
- data/doc/simple_diagram.html +3 -5
- data/doc/stylesheets/masterview.css +16 -1
- data/examples/rails_app_config/masterview/settings.rb +2 -1
- data/init.rb +1 -1
- data/lib/#ChangeLog# +6 -0
- data/lib/masterview/analyzer.rb +48 -34
- data/lib/masterview/attr_string_parser.rb +5 -1
- data/lib/masterview/case_insensitive_hash.rb +69 -0
- data/lib/masterview/{pathname_extensions.rb → core_ext/pathname.rb} +0 -0
- data/lib/masterview/{string_extensions.rb → core_ext/string.rb} +0 -0
- data/lib/masterview/deprecated/directive_base.rb +362 -0
- data/lib/masterview/directive_base.rb +201 -179
- data/lib/masterview/directive_dsl.rb +457 -0
- data/lib/masterview/directive_helpers.rb +28 -141
- data/lib/masterview/directive_load_path.rb +388 -0
- data/lib/masterview/directive_metadata.rb +377 -0
- data/lib/masterview/directive_registry.rb +259 -69
- data/lib/masterview/directives/.metadata +16 -0
- data/lib/masterview/directives/attr.rb +9 -8
- data/lib/masterview/directives/block.rb +11 -14
- data/lib/masterview/directives/check_box.rb +13 -18
- data/lib/masterview/directives/collection_select.rb +15 -29
- data/lib/masterview/directives/content.rb +9 -3
- data/lib/masterview/directives/else.rb +15 -13
- data/lib/masterview/directives/elsif.rb +14 -13
- data/lib/masterview/directives/eval.rb +20 -0
- data/lib/masterview/directives/form.rb +56 -9
- data/lib/masterview/directives/form_remote.rb +26 -0
- data/lib/masterview/directives/global_inline_erb.rb +10 -14
- data/lib/masterview/directives/hidden_field.rb +11 -20
- data/lib/masterview/directives/if.rb +13 -12
- data/lib/masterview/directives/image_tag.rb +20 -28
- data/lib/masterview/directives/import.rb +5 -12
- data/lib/masterview/directives/import_render.rb +7 -19
- data/lib/masterview/directives/insert_generated_comment.rb +8 -11
- data/lib/masterview/directives/javascript_include.rb +21 -12
- data/lib/masterview/directives/link_to.rb +14 -8
- data/lib/masterview/directives/link_to_function.rb +22 -0
- data/lib/masterview/directives/link_to_if.rb +15 -13
- data/lib/masterview/directives/link_to_remote.rb +13 -8
- data/lib/masterview/directives/omit_tag.rb +32 -16
- data/lib/masterview/directives/password_field.rb +10 -22
- data/lib/masterview/directives/radio_button.rb +11 -22
- data/lib/masterview/directives/replace.rb +7 -8
- data/lib/masterview/directives/select.rb +11 -24
- data/lib/masterview/directives/stylesheet_link.rb +20 -12
- data/lib/masterview/directives/submit.rb +11 -5
- data/lib/masterview/directives/text_area.rb +10 -23
- data/lib/masterview/directives/text_field.rb +10 -22
- data/lib/masterview/exceptions.rb +21 -0
- data/lib/masterview/extras/app/controllers/masterview_controller.rb +102 -75
- data/lib/masterview/extras/app/views/layouts/masterview_admin.rhtml +24 -23
- data/lib/masterview/extras/app/views/layouts/masterview_admin_config.rhtml +81 -0
- data/lib/masterview/extras/app/views/masterview/admin/configuration.rhtml +5 -1
- data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +2 -2
- data/lib/masterview/extras/app/views/masterview/admin/directives.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/features.rhtml +5 -79
- data/lib/masterview/extras/app/views/masterview/admin/interact.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +3 -71
- data/lib/masterview/extras/init_mv_admin_pages.rb +42 -23
- data/lib/masterview/filter_helpers.rb +26 -0
- data/lib/masterview/initializer.rb +99 -53
- data/lib/masterview/io.rb +19 -15
- data/lib/masterview/keyword_expander.rb +7 -2
- data/lib/masterview/masterview_info.rb +229 -23
- data/lib/masterview/masterview_version.rb +2 -2
- data/lib/masterview/parser.rb +275 -105
- data/lib/masterview/parser_helpers.rb +54 -0
- data/lib/masterview/rails_ext/action_controller_erb_direct.rb +29 -0
- data/lib/masterview/rails_ext/action_controller_reparse_checking.rb +27 -0
- data/lib/masterview/{extras/init_rails_erb_mv_direct.rb → rails_ext/action_view_erb_direct.rb} +12 -59
- data/lib/masterview/template_spec.rb +3 -2
- data/lib/masterview.rb +21 -12
- data/lib/rexml/parsers/baseparser_with_doctype_fix.rb +473 -0
- data/lib/rexml/parsers/sax2parser_with_doctype_fix.rb +243 -0
- data/test/directive_test_helper.rb +135 -0
- data/test/fixtures/directives/id_check.rb +18 -0
- data/test/fixtures/directives/test_directive_events.rb +70 -0
- data/test/test_helper.rb +18 -5
- data/test/tmp/views/layouts/product.rhtml +10 -10
- data/test/tmp/views/product/_form.rhtml +4 -4
- data/test/tmp/views/product/_product.rhtml +3 -3
- data/test/tmp/views/product/destroy.rhtml +5 -5
- data/test/tmp/views/product/edit.rhtml +4 -4
- data/test/tmp/views/product/list.rhtml +3 -3
- data/test/tmp/views/product/new.rhtml +4 -4
- data/test/tmp/views/product/show.rhtml +2 -2
- data/test/unit/attr_string_parser_test.rb +105 -0
- data/test/unit/case_insensitive_hash_mod_test.rb +104 -0
- data/test/unit/config_settings_test.rb +13 -1
- data/test/unit/default_generate_mio_filter_test.rb +3 -3
- data/test/unit/deprecated_directive_base_test.rb +30 -0
- data/test/unit/directive_attr_test.rb +111 -35
- data/test/unit/directive_base_test.rb +520 -1
- data/test/unit/directive_block_test.rb +30 -22
- data/test/unit/directive_content_test.rb +24 -11
- data/test/unit/directive_else_test.rb +18 -15
- data/test/unit/directive_elsif_test.rb +17 -15
- data/test/unit/directive_form_remote_test.rb +59 -0
- data/test/unit/directive_form_test.rb +31 -39
- data/test/unit/directive_global_inline_erb_test.rb +28 -17
- data/test/unit/directive_grid_test_notready.rb +38 -0
- data/test/unit/directive_helpers_test.rb +39 -0
- data/test/unit/directive_hidden_field_test.rb +44 -29
- data/test/unit/directive_if_test.rb +10 -7
- data/test/unit/directive_image_tag_test.rb +69 -61
- data/test/unit/directive_import_render_test.rb +28 -38
- data/test/unit/directive_import_test.rb +16 -14
- data/test/unit/directive_insert_generated_comment_test.rb +32 -0
- data/test/unit/directive_javascript_include_test.rb +40 -43
- data/test/unit/directive_link_to_function_test.rb +40 -0
- data/test/unit/directive_link_to_if_test.rb +52 -12
- data/test/unit/directive_link_to_remote_test.rb +58 -0
- data/test/unit/directive_link_to_test.rb +46 -31
- data/test/unit/directive_load_path_test.rb +257 -0
- data/test/unit/directive_metadata_test.rb +313 -0
- data/test/unit/directive_omit_tag_test.rb +73 -21
- data/test/unit/directive_password_field_test.rb +44 -38
- data/test/unit/directive_registry_test.rb +44 -0
- data/test/unit/directive_replace_test.rb +28 -12
- data/test/unit/directive_stylesheet_link_test.rb +43 -36
- data/test/unit/directive_submit_test.rb +29 -30
- data/test/unit/directive_text_area_test.rb +40 -36
- data/test/unit/directive_text_field_test.rb +44 -38
- data/test/unit/example_directive_child_events_test.rb +41 -0
- data/test/unit/example_test.rb +31 -4
- data/test/unit/file_mio_test.rb +18 -13
- data/test/unit/filter_helpers_test.rb +10 -8
- data/test/unit/find_directive_parent_test.rb +174 -0
- data/test/unit/keyword_expander_test.rb +4 -2
- data/test/unit/mio_test.rb +18 -11
- data/test/unit/mtime_string_hash_mio_tree_test.rb +5 -1
- data/test/unit/parser_test.rb +41 -29
- data/test/unit/pathname_extensions_test.rb +1 -1
- data/test/unit/run_parser_test.rb +2 -2
- data/test/unit/simplified_directive_base_test.rb +256 -0
- data/test/unit/string_hash_mio_test.rb +5 -1
- data/test/unit/template_file_watcher_test.rb +2 -2
- data/test/unit/template_test.rb +221 -46
- metadata +86 -45
- data/lib/masterview/directives/testfilter.rb +0 -55
- data/lib/masterview/extras/init_rails_reparse_checking.rb +0 -62
@@ -3,38 +3,90 @@
|
|
3
3
|
require 'test/unit'
|
4
4
|
currentPath = File.dirname(__FILE__)
|
5
5
|
require File.join( currentPath, '../../lib/masterview' )
|
6
|
-
require File.join( currentPath, '../../lib/masterview/directives/omit_tag')
|
6
|
+
#require File.join( currentPath, '../../lib/masterview/directives/omit_tag')
|
7
|
+
require File.join( currentPath, '../directive_test_helper' )
|
8
|
+
DirectiveTestHelpers.load_masterview_directive('omit_tag')
|
7
9
|
|
8
10
|
class TestOmit_tag < Test::Unit::TestCase
|
9
|
-
include
|
11
|
+
include DirectiveTestHelpers
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
OmitTag = MasterView::Directives::OmitTag # test subject
|
14
|
+
|
15
|
+
ELEMENT_TAG = 'div'
|
16
|
+
ELEMENT_CONTENT = '<p>hello world</p>'
|
17
|
+
|
18
|
+
def test_metadata
|
19
|
+
assert_equal MasterView::ConfigSettings.namespace_prefix, OmitTag.namespace_prefix
|
20
|
+
assert_equal 'omit_tag', OmitTag.attribute_name
|
13
21
|
end
|
14
22
|
|
15
23
|
def test_omit_tag
|
16
|
-
|
17
|
-
|
24
|
+
create_template_element ELEMENT_TAG,
|
25
|
+
:attributes => { 'id' => 'foobar', 'style' => 'test'},
|
26
|
+
:content => ELEMENT_CONTENT
|
18
27
|
attr_value = ""
|
19
|
-
|
20
|
-
assert_equal
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
create_directive OmitTag, attr_value
|
29
|
+
assert_equal '', render_element_event(:stag), 'start tag unconditionally suppressed, not erb checking needed'
|
30
|
+
assert_equal '', render_element_event(:etag), 'start tag unconditionally suppressed, not erb checking needed'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_omit_tag_true
|
34
|
+
create_template_element ELEMENT_TAG,
|
35
|
+
:attributes => { 'id' => 'foobar', 'style' => 'test'},
|
36
|
+
:content => ELEMENT_CONTENT
|
37
|
+
attr_value = "true"
|
38
|
+
create_directive OmitTag, attr_value
|
39
|
+
assert_equal '', render_element_event(:stag), 'start tag unconditionally suppressed, not erb checking needed'
|
40
|
+
assert_equal '', render_element_event(:etag), 'start tag unconditionally suppressed, not erb checking needed'
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_omit_tag_false
|
44
|
+
create_template_element ELEMENT_TAG,
|
45
|
+
:attributes => { 'id' => 'foobar', 'style' => 'test'},
|
46
|
+
:content => ELEMENT_CONTENT
|
47
|
+
attr_value = "false"
|
48
|
+
create_directive OmitTag, attr_value
|
49
|
+
assert_equal '', render_element_event(:stag), 'start tag unconditionally generated, not erb checking needed'
|
50
|
+
assert_equal '', render_element_event(:etag), 'start tag unconditionally generated, not erb checking needed'
|
25
51
|
end
|
26
52
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
53
|
+
def test_omit_tag_conditional
|
54
|
+
create_template_element ELEMENT_TAG,
|
55
|
+
:attributes => { 'id' => 'foobar', 'style' => 'test'},
|
56
|
+
:content => ELEMENT_CONTENT
|
30
57
|
attr_value = "@test"
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
58
|
+
create_directive OmitTag, attr_value
|
59
|
+
expected_content = ["<% if( @test ) -%>", [], "<% end -%>"].join
|
60
|
+
assert_equal expected_content, render_element_event(:stag)
|
61
|
+
expected_content = ["<% if( @test ) -%>", [], "<% end -%>"].join
|
62
|
+
assert_equal expected_content, render_element_event(:etag)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_complete_rendering_when_tag_omitted
|
66
|
+
create_template_element ELEMENT_TAG, :content => ELEMENT_CONTENT
|
67
|
+
create_directive OmitTag, ''
|
68
|
+
append_default_render_handler
|
69
|
+
assert_equal '', render_element_event(:stag)
|
70
|
+
assert_equal '', render_element_event(:content)
|
71
|
+
assert_equal '', render_element_event(:etag)
|
72
|
+
###ISSUE: assert_equal ELEMENT_CONTENT, render_element_event(:element) ??why not??
|
73
|
+
assert_equal ELEMENT_CONTENT, element_content
|
74
|
+
end
|
75
|
+
|
76
|
+
#ISSUE: need to debug this test case so it correctly expresses what we're trying to check [DJL 06-Oct-2006]
|
77
|
+
def test_complete_rendering_when_tag_included
|
78
|
+
start_tag = "<#{ELEMENT_TAG}>"
|
79
|
+
end_tag = "</#{ELEMENT_TAG}>"
|
80
|
+
create_template_element ELEMENT_TAG, :content => ELEMENT_CONTENT
|
81
|
+
create_directive OmitTag, 'false'
|
82
|
+
append_default_render_handler
|
83
|
+
assert_equal start_tag, render_element_event(:stag)
|
84
|
+
assert_equal '', render_element_event(:content)
|
85
|
+
assert_equal end_tag, render_element_event(:etag)
|
86
|
+
###ISSUE: assert_equal ELEMENT_CONTENT, render_element_event(:element) ??why not??
|
87
|
+
#TEMP DISABLE: assert_equal [start_tag, ELEMENT_CONTENT, end_tag].join, element_content
|
37
88
|
end
|
38
89
|
|
90
|
+
#TODO: add a test case to verify the complete output element rendering with conditional tag checking
|
39
91
|
|
40
92
|
end
|
@@ -3,87 +3,93 @@
|
|
3
3
|
require 'test/unit'
|
4
4
|
currentPath = File.dirname(__FILE__)
|
5
5
|
require File.join( currentPath, '../../lib/masterview' )
|
6
|
-
require File.join( currentPath, '../../lib/masterview/directives/password_field')
|
6
|
+
#require File.join( currentPath, '../../lib/masterview/directives/password_field')
|
7
|
+
require File.join( currentPath, '../directive_test_helper' )
|
8
|
+
DirectiveTestHelpers.load_masterview_directive('password_field')
|
7
9
|
|
8
10
|
class TestPasswordField < Test::Unit::TestCase
|
9
|
-
include
|
11
|
+
include DirectiveTestHelpers
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
PasswordField = MasterView::Directives::PasswordField # test subject
|
14
|
+
|
15
|
+
ELEMENT_TAG = 'input'
|
16
|
+
|
17
|
+
def test_metadata
|
18
|
+
assert_equal MasterView::ConfigSettings.namespace_prefix, PasswordField.namespace_prefix
|
19
|
+
assert_equal 'password_field', PasswordField.attribute_name
|
13
20
|
end
|
14
21
|
|
15
|
-
def
|
22
|
+
def create_element_with_password_field_directive(obj, method, other_attr_values, attributes)
|
23
|
+
|
16
24
|
attr_value = "#{obj}, #{method}"
|
17
|
-
attr_value << ', ' <<
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
dcs.context[:tag].content = "hello world"
|
25
|
-
dcs.render
|
26
|
-
end
|
25
|
+
attr_value << ', ' << other_attr_values unless other_attr_values.nil?
|
26
|
+
|
27
|
+
input_tag = create_template_element ELEMENT_TAG,
|
28
|
+
:attributes => attributes,
|
29
|
+
:content => 'hello world'
|
30
|
+
create_directive PasswordField, attr_value
|
31
|
+
assert_equal '', render_element_event(:stag)
|
27
32
|
|
28
|
-
def test_normal
|
29
|
-
obj = ':product'
|
30
|
-
method = ':price'
|
31
|
-
ret = password_field_exec(obj, method, nil, { 'type' => 'text', 'value' => 'fake text' } )
|
32
|
-
assert_equal "<%= password_field #{obj}, #{method} %>", ret
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def test_normal
|
36
36
|
obj = ':product'
|
37
37
|
method = ':price'
|
38
|
-
|
39
|
-
|
38
|
+
create_element_with_password_field_directive(obj, method, nil, { 'type' => 'text', 'value' => 'fake text' } )
|
39
|
+
expected_content = "<%= password_field( #{obj}, #{method} ) %>"
|
40
|
+
assert_equal expected_content, render_element_event(:etag)
|
40
41
|
end
|
41
42
|
|
42
43
|
def test_disabled
|
43
44
|
obj = ':product'
|
44
45
|
method = ':price'
|
45
|
-
|
46
|
-
|
46
|
+
create_element_with_password_field_directive(obj, method, nil, { 'type' => 'text', 'value' => 'fake text', 'disabled' => 'disabled'} )
|
47
|
+
expected_content = "<%= password_field( #{obj}, #{method}, :disabled => true ) %>"
|
48
|
+
assert_equal expected_content, render_element_event(:etag)
|
47
49
|
end
|
48
50
|
|
49
51
|
def test_size
|
50
52
|
obj = ':product'
|
51
53
|
method = ':price'
|
52
|
-
|
53
|
-
|
54
|
+
create_element_with_password_field_directive(obj, method, nil, { 'type' => 'text', 'value' => 'fake text', 'size' => '10' } )
|
55
|
+
expected_content = "<%= password_field( #{obj}, #{method}, :size => 10 ) %>"
|
56
|
+
assert_equal expected_content, render_element_event(:etag)
|
54
57
|
end
|
55
58
|
|
56
59
|
def test_maxlength
|
57
60
|
obj = ':product'
|
58
61
|
method = ':price'
|
59
|
-
|
60
|
-
|
62
|
+
create_element_with_password_field_directive(obj, method, nil, { 'type' => 'text', 'value' => 'fake text', 'maxlength' => '21' } )
|
63
|
+
expected_content = "<%= password_field( #{obj}, #{method}, :maxlength => 21 ) %>"
|
64
|
+
assert_equal expected_content, render_element_event(:etag)
|
61
65
|
end
|
62
66
|
|
63
67
|
def test_all
|
64
68
|
obj = ':product'
|
65
69
|
method = ':price'
|
66
|
-
|
67
|
-
{
|
68
|
-
'type' => 'text', 'value' => 'fake text', 'disabled' => 'disabled',
|
69
|
-
'size' => '10', 'maxlength' => '21',
|
70
|
+
create_element_with_password_field_directive(obj, method, nil,
|
71
|
+
{
|
72
|
+
'type' => 'text', 'value' => 'fake text', 'disabled' => 'disabled',
|
73
|
+
'size' => '10', 'maxlength' => '21',
|
70
74
|
'readonly' => 'readonly', 'class' => 'classfoo', 'style' => 'stylebar',
|
71
75
|
'tabindex' => 'tab1', 'accesskey' => 'ak2'
|
72
76
|
} )
|
73
|
-
|
77
|
+
expected_content = "<%= password_field( #{obj}, #{method}, :accesskey => \"ak2\", :class => \"classfoo\", :disabled => true, :maxlength => 21, :readonly => true, :size => 10, :style => \"stylebar\", :tabindex => \"tab1\" ) %>"
|
78
|
+
assert_equal expected_content, render_element_event(:etag)
|
74
79
|
end
|
75
80
|
|
76
81
|
def test_all_uc
|
77
82
|
obj = ':product'
|
78
83
|
method = ':price'
|
79
|
-
|
80
|
-
{
|
81
|
-
'TYPE' => 'PASSWORD', 'value' => 'fake text', 'DISABLED' => 'DISABLED',
|
84
|
+
create_element_with_password_field_directive(obj, method, nil,
|
85
|
+
{
|
86
|
+
'TYPE' => 'PASSWORD', 'value' => 'fake text', 'DISABLED' => 'DISABLED',
|
82
87
|
'SIZE' => '10', 'MAXLENGTH' => '21',
|
83
88
|
'READONLY' => 'readonly', 'CLASS' => 'classfoo', 'STYLE' => 'stylebar',
|
84
89
|
'TABINDEX' => 'tab1', 'ACCESSKEY' => 'ak2'
|
85
90
|
} )
|
86
|
-
|
91
|
+
expected_content = "<%= password_field( #{obj}, #{method}, :accesskey => \"ak2\", :class => \"classfoo\", :disabled => true, :maxlength => 21, :readonly => true, :size => 10, :style => \"stylebar\", :tabindex => \"tab1\" ) %>"
|
92
|
+
assert_equal expected_content, render_element_event(:etag)
|
87
93
|
end
|
88
94
|
|
89
95
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
currentPath = File.dirname(__FILE__)
|
5
|
+
require File.join( currentPath, '../../lib/masterview/directive_metadata' )
|
6
|
+
require File.join( currentPath, '../../lib/masterview/directive_registry' )
|
7
|
+
|
8
|
+
DEBUG_TRACE = false #test dev hack
|
9
|
+
|
10
|
+
class TestDirectiveRegistry < Test::Unit::TestCase
|
11
|
+
|
12
|
+
# test subject
|
13
|
+
DirectiveRegistry = MasterView::DirectiveRegistry
|
14
|
+
|
15
|
+
def test_current
|
16
|
+
|
17
|
+
assert_not_nil DirectiveRegistry.current
|
18
|
+
|
19
|
+
begin
|
20
|
+
DirectiveRegistry.current.mv_namespace_prefix
|
21
|
+
rescue
|
22
|
+
# this is ordinarily done during masterview initialization
|
23
|
+
DirectiveRegistry.register_default_namespaces( 'mv:', 'mvx:' )
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_not_nil DirectiveRegistry.current.mv_namespace_prefix
|
27
|
+
assert_not_nil DirectiveRegistry.current.mv_extensions_namespace_prefix
|
28
|
+
|
29
|
+
# we maintain separate metadata defaults for mv namespace and extensions
|
30
|
+
assert_not_nil DirectiveRegistry.current.metadata_defaults
|
31
|
+
assert_not_nil DirectiveRegistry.current.metadata_defaults_extensions
|
32
|
+
assert_not_same DirectiveRegistry.current.metadata_defaults, DirectiveRegistry.current.metadata_defaults_extensions
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_construction
|
37
|
+
|
38
|
+
registry = DirectiveRegistry.new
|
39
|
+
#STDOUT.puts "CREATED registry=#{registry}"
|
40
|
+
assert registry.loaded_classes.empty?
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -3,25 +3,41 @@
|
|
3
3
|
require 'test/unit'
|
4
4
|
currentPath = File.dirname(__FILE__)
|
5
5
|
require File.join( currentPath, '../../lib/masterview' )
|
6
|
-
require File.join( currentPath, '../../lib/masterview/directives/replace')
|
6
|
+
#require File.join( currentPath, '../../lib/masterview/directives/replace')
|
7
|
+
require File.join( currentPath, '../directive_test_helper' )
|
8
|
+
DirectiveTestHelpers.load_masterview_directive('replace')
|
7
9
|
|
8
10
|
class TestReplace < Test::Unit::TestCase
|
9
|
-
include
|
11
|
+
include DirectiveTestHelpers
|
12
|
+
|
13
|
+
Replace = MasterView::Directives::Replace # test subject
|
14
|
+
|
15
|
+
ELEMENT_TAG = 'h1'
|
16
|
+
TEMPLATE_ELEMENT_ATTRIBUTES = { 'id' => 'foobar', 'style' => 'test'}
|
17
|
+
|
18
|
+
def check_element_rendering(expected_content)
|
19
|
+
|
20
|
+
erbized_content = "<%= #{expected_content} %>"
|
21
|
+
assert_equal '', render_element_event(:stag)
|
22
|
+
#??what to do/check at :content processing point?
|
23
|
+
assert_equal erbized_content, render_element_event(:etag)
|
24
|
+
|
25
|
+
###ISSUE: Needs work (?) - this should be verifying that the original tags are dropped
|
10
26
|
|
11
|
-
def setup
|
12
|
-
@directives = MasterView::DirectiveSet.new
|
13
27
|
end
|
14
28
|
|
15
29
|
def test_replace
|
16
|
-
|
17
|
-
|
30
|
+
|
31
|
+
# ensure we have some sample content that's getting replaced
|
32
|
+
test_element = create_template_element ELEMENT_TAG,
|
33
|
+
:attribute => TEMPLATE_ELEMENT_ATTRIBUTES,
|
34
|
+
:content => "product name goes here"
|
35
|
+
|
18
36
|
attr_value = "h @product[name]"
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
dcs.context[:tag].content = "hello world"
|
24
|
-
assert_equal "<%= h @product[name] %>", dcs.render
|
37
|
+
create_directive Replace, attr_value
|
38
|
+
|
39
|
+
check_element_rendering attr_value
|
40
|
+
|
25
41
|
end
|
26
42
|
|
27
43
|
end
|
@@ -3,61 +3,68 @@
|
|
3
3
|
require 'test/unit'
|
4
4
|
currentPath = File.dirname(__FILE__)
|
5
5
|
require File.join( currentPath, '../../lib/masterview' )
|
6
|
-
require File.join( currentPath, '../../lib/masterview/directives/stylesheet_link' )
|
6
|
+
#require File.join( currentPath, '../../lib/masterview/directives/stylesheet_link' )
|
7
|
+
require File.join( currentPath, '../directive_test_helper' )
|
8
|
+
DirectiveTestHelpers.load_masterview_directive('stylesheet_link')
|
7
9
|
|
8
10
|
class StylesheetLinkTest < Test::Unit::TestCase
|
9
|
-
include
|
11
|
+
include DirectiveTestHelpers
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
StylesheetLink = MasterView::Directives::StylesheetLink # test subject
|
14
|
+
|
15
|
+
ELEMENT_TAG = 'link'
|
16
|
+
|
17
|
+
def test_metadata
|
18
|
+
assert_equal MasterView::ConfigSettings.namespace_prefix, StylesheetLink.namespace_prefix
|
19
|
+
assert_equal 'stylesheet_link', StylesheetLink.attribute_name
|
13
20
|
end
|
14
21
|
|
15
22
|
def test_default
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
dcs.context = tag.create_context
|
23
|
-
assert_equal "<%= stylesheet_link_tag 'hello world' %>", dcs.render
|
23
|
+
create_template_element ELEMENT_TAG
|
24
|
+
attr_value = "styles.css"
|
25
|
+
create_directive StylesheetLink, attr_value
|
26
|
+
assert_equal '', render_element_event(:stag)
|
27
|
+
expected_content = "<%= stylesheet_link_tag( '#{attr_value}' ) %>"
|
28
|
+
assert_equal expected_content, render_element_event(:etag)
|
24
29
|
end
|
25
30
|
|
26
31
|
def test_empty_infer_path
|
27
|
-
|
28
|
-
|
32
|
+
link_tag = create_template_element ELEMENT_TAG,
|
33
|
+
:attributes => { 'src' => '../../public/stylesheets/foo.css' }
|
29
34
|
attr_value = ""
|
30
|
-
|
31
|
-
assert_equal
|
32
|
-
|
33
|
-
|
34
|
-
dcs.context[:tag].attributes['src'] = '../../public/stylesheets/foo.css'
|
35
|
-
assert_equal "<%= stylesheet_link_tag 'foo.css' %>", dcs.render
|
35
|
+
create_directive StylesheetLink, attr_value
|
36
|
+
assert_equal '', render_element_event(:stag)
|
37
|
+
expected_content = "<%= stylesheet_link_tag( 'foo.css' ) %>"
|
38
|
+
assert_equal expected_content, render_element_event(:etag)
|
36
39
|
end
|
37
40
|
|
38
41
|
def test_empty_infer_path_sub
|
39
|
-
|
40
|
-
|
42
|
+
link_tag = create_template_element ELEMENT_TAG,
|
43
|
+
:attributes => { 'src' => '../../public/stylesheets/bar/foo.css' }
|
41
44
|
attr_value = ""
|
42
|
-
|
43
|
-
assert_equal
|
44
|
-
|
45
|
-
|
46
|
-
dcs.context[:tag].attributes['src'] = '../../public/stylesheets/bar/foo.css'
|
47
|
-
assert_equal "<%= stylesheet_link_tag 'bar/foo.css' %>", dcs.render
|
45
|
+
create_directive StylesheetLink, attr_value
|
46
|
+
assert_equal '', render_element_event(:stag)
|
47
|
+
expected_content = "<%= stylesheet_link_tag( 'bar/foo.css' ) %>"
|
48
|
+
assert_equal expected_content, render_element_event(:etag)
|
48
49
|
end
|
49
50
|
|
50
51
|
def test_empty_use_src
|
51
|
-
|
52
|
-
|
52
|
+
link_tag = create_template_element ELEMENT_TAG,
|
53
|
+
:attributes => { 'src' => '/mystylesheets/foo.css' }
|
53
54
|
attr_value = ""
|
54
|
-
|
55
|
-
assert_equal
|
56
|
-
|
57
|
-
|
58
|
-
dcs.context[:tag].attributes['src'] = '/mystylesheets/foo.css'
|
59
|
-
assert_equal "<%= stylesheet_link_tag '/mystylesheets/foo.css' %>", dcs.render
|
55
|
+
create_directive StylesheetLink, attr_value
|
56
|
+
assert_equal '', render_element_event(:stag)
|
57
|
+
expected_content = "<%= stylesheet_link_tag( '/mystylesheets/foo.css' ) %>"
|
58
|
+
assert_equal expected_content, render_element_event(:etag)
|
60
59
|
end
|
61
60
|
|
61
|
+
def test_multiple
|
62
|
+
link_tag = create_template_element ELEMENT_TAG
|
63
|
+
attr_value = "hello/world, foo/bar, baz"
|
64
|
+
create_directive StylesheetLink, attr_value
|
65
|
+
assert_equal '', render_element_event(:stag)
|
66
|
+
expected_content = "<%= stylesheet_link_tag( 'hello/world', 'foo/bar', 'baz' ) %>"
|
67
|
+
assert_equal expected_content, render_element_event(:etag)
|
68
|
+
end
|
62
69
|
|
63
70
|
end
|
@@ -3,52 +3,51 @@
|
|
3
3
|
require 'test/unit'
|
4
4
|
currentPath = File.dirname(__FILE__)
|
5
5
|
require File.join( currentPath, '../../lib/masterview' )
|
6
|
-
require File.join( currentPath, '../../lib/masterview/directives/submit')
|
6
|
+
#require File.join( currentPath, '../../lib/masterview/directives/submit')
|
7
|
+
require File.join( currentPath, '../directive_test_helper' )
|
8
|
+
DirectiveTestHelpers.load_masterview_directive('submit')
|
7
9
|
|
8
10
|
class TestSubmitTag < Test::Unit::TestCase
|
9
|
-
include
|
11
|
+
include DirectiveTestHelpers
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
Submit = MasterView::Directives::Submit # test subject
|
14
|
+
|
15
|
+
ELEMENT_TAG = 'input'
|
14
16
|
|
15
17
|
def test_submit
|
16
18
|
submit_text = 'foobar'
|
17
|
-
|
18
|
-
|
19
|
+
create_template_element ELEMENT_TAG,
|
20
|
+
:attributes => { 'type' => 'submit', 'value' => submit_text },
|
21
|
+
:content => 'hello world'
|
19
22
|
attr_value = "baz"
|
20
|
-
|
21
|
-
assert_equal
|
22
|
-
|
23
|
-
|
24
|
-
dcs.context[:tag].content = "hello world"
|
25
|
-
assert_equal "<%= submit_tag '#{submit_text}' %>", dcs.render
|
23
|
+
create_directive Submit, attr_value
|
24
|
+
assert_equal '', render_element_event(:stag)
|
25
|
+
expected_content = "<%= submit_tag( '#{submit_text}' ) %>"
|
26
|
+
assert_equal expected_content, render_element_event(:etag)
|
26
27
|
end
|
27
28
|
|
28
29
|
def test_submit_with_hash
|
29
30
|
submit_text = 'foobar'
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal "<%= submit_tag '#{submit_text}', #{attr_value} %>", dcs.render
|
31
|
+
create_template_element ELEMENT_TAG,
|
32
|
+
:attributes => { 'type' => 'submit', 'value' => submit_text },
|
33
|
+
:content => 'hello world'
|
34
|
+
attr_value = "{:foo => 'bar'}"
|
35
|
+
create_directive Submit, attr_value
|
36
|
+
assert_equal '', render_element_event(:stag)
|
37
|
+
expected_content = "<%= submit_tag( '#{submit_text}', #{attr_value} ) %>"
|
38
|
+
assert_equal expected_content, render_element_event(:etag)
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_submit_with_hash_no_brack
|
42
42
|
submit_text = 'foobar'
|
43
|
-
|
44
|
-
|
43
|
+
create_template_element ELEMENT_TAG,
|
44
|
+
:attributes => { 'type' => 'submit', 'value' => submit_text },
|
45
|
+
:content => 'hello world'
|
45
46
|
attr_value = ":foo => 'bar'"
|
46
|
-
|
47
|
-
assert_equal
|
48
|
-
|
49
|
-
|
50
|
-
dcs.context[:tag].content = "hello world"
|
51
|
-
assert_equal "<%= submit_tag '#{submit_text}', #{attr_value} %>", dcs.render
|
47
|
+
create_directive Submit, attr_value
|
48
|
+
assert_equal '', render_element_event(:stag)
|
49
|
+
expected_content = "<%= submit_tag( '#{submit_text}', #{attr_value} ) %>"
|
50
|
+
assert_equal expected_content, render_element_event(:etag)
|
52
51
|
end
|
53
52
|
|
54
53
|
end
|