padrino-helpers 0.11.4 → 0.12.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +6 -6
- data/lib/padrino-helpers/asset_tag_helpers.rb +26 -33
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +16 -17
- data/lib/padrino-helpers/form_helpers.rb +121 -129
- data/lib/padrino-helpers/format_helpers.rb +1 -1
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +25 -60
- data/lib/padrino-helpers/output_helpers/erb_handler.rb +7 -58
- data/lib/padrino-helpers/output_helpers/haml_handler.rb +5 -43
- data/lib/padrino-helpers/output_helpers/slim_handler.rb +5 -65
- data/lib/padrino-helpers/output_helpers.rb +26 -13
- data/lib/padrino-helpers/render_helpers.rb +21 -18
- data/lib/padrino-helpers.rb +1 -0
- data/padrino-helpers.gemspec +2 -1
- data/test/fixtures/markup_app/app.rb +14 -10
- data/test/fixtures/markup_app/views/button_to.haml +2 -2
- data/test/fixtures/markup_app/views/capture_concat.haml +3 -3
- data/test/fixtures/markup_app/views/capture_concat.slim +3 -3
- data/test/fixtures/markup_app/views/content_for.erb +10 -1
- data/test/fixtures/markup_app/views/content_for.haml +7 -0
- data/test/fixtures/markup_app/views/content_for.slim +8 -1
- data/test/fixtures/markup_app/views/content_tag.erb +2 -0
- data/test/fixtures/markup_app/views/content_tag.haml +4 -2
- data/test/fixtures/markup_app/views/content_tag.slim +3 -1
- data/test/fixtures/markup_app/views/fields_for.haml +4 -4
- data/test/fixtures/markup_app/views/form_for.haml +3 -3
- data/test/fixtures/markup_app/views/form_tag.haml +6 -6
- data/test/fixtures/markup_app/views/link_to.haml +1 -1
- data/test/fixtures/markup_app/views/simple_partial.slim +1 -1
- data/test/fixtures/render_app/app.rb +16 -4
- data/test/fixtures/render_app/views/_deep.erb +3 -0
- data/test/fixtures/render_app/views/_deep.haml +2 -0
- data/test/fixtures/render_app/views/_deep.slim +2 -0
- data/test/fixtures/render_app/views/_partial_block_erb.erb +10 -0
- data/test/fixtures/render_app/views/_partial_block_haml.haml +7 -0
- data/test/fixtures/render_app/views/_partial_block_slim.slim +7 -0
- data/test/fixtures/render_app/views/double_capture_erb.erb +2 -2
- data/test/fixtures/render_app/views/double_capture_haml.haml +1 -1
- data/test/fixtures/render_app/views/double_capture_slim.slim +1 -1
- data/test/fixtures/render_app/views/render_block_erb.erb +5 -0
- data/test/fixtures/render_app/views/render_block_haml.haml +4 -0
- data/test/fixtures/render_app/views/render_block_slim.slim +4 -0
- data/test/fixtures/render_app/views/wrong_capture_erb.erb +3 -0
- data/test/fixtures/render_app/views/wrong_capture_haml.haml +2 -0
- data/test/fixtures/render_app/views/wrong_capture_slim.slim +2 -0
- data/test/test_asset_tag_helpers.rb +34 -0
- data/test/test_form_builder.rb +10 -0
- data/test/test_form_helpers.rb +18 -18
- data/test/test_format_helpers.rb +10 -0
- data/test/test_output_helpers.rb +25 -22
- data/test/test_render_helpers.rb +67 -0
- data/test/test_tag_helpers.rb +9 -0
- metadata +38 -7
@@ -98,6 +98,16 @@ describe "AssetTagHelpers" do
|
|
98
98
|
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
99
99
|
assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
100
100
|
end
|
101
|
+
|
102
|
+
should "not double-escape" do
|
103
|
+
actual_link = link_to('test escape', '?a=1&b=2')
|
104
|
+
assert_has_tag('a', :href => '?a=1&b=2') { actual_link }
|
105
|
+
end
|
106
|
+
|
107
|
+
should "escape scary things" do
|
108
|
+
actual_link = link_to('test escape<adfs>', '?a=1&b=<script>alert(1)</script>')
|
109
|
+
assert_no_match('<script', actual_link)
|
110
|
+
end
|
101
111
|
end
|
102
112
|
|
103
113
|
context 'for #mail_to method' do
|
@@ -269,6 +279,14 @@ describe "AssetTagHelpers" do
|
|
269
279
|
assert actual_html.html_safe?
|
270
280
|
end
|
271
281
|
|
282
|
+
should "respond to js_asset_folder setting" do
|
283
|
+
time = stop_time_for_test
|
284
|
+
self.class.stubs(:js_asset_folder).returns('js')
|
285
|
+
assert_equal 'js', asset_folder_name(:js)
|
286
|
+
actual_html = javascript_include_tag('application')
|
287
|
+
assert_has_tag('script', :src => "/js/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
|
288
|
+
end
|
289
|
+
|
272
290
|
should "display javascript item for long relative path" do
|
273
291
|
time = stop_time_for_test
|
274
292
|
actual_html = javascript_include_tag('example/demo/application')
|
@@ -356,4 +374,20 @@ describe "AssetTagHelpers" do
|
|
356
374
|
assert_has_tag('link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title') { feed_tag :rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title" }
|
357
375
|
end
|
358
376
|
end
|
377
|
+
|
378
|
+
context 'for #asset_path method' do
|
379
|
+
should 'generate proper paths for js and css' do
|
380
|
+
assert_match /\/javascripts\/app.js\?\d+/, asset_path(:js, 'app')
|
381
|
+
assert_match /\/stylesheets\/app.css\?\d+/, asset_path(:css, 'app')
|
382
|
+
end
|
383
|
+
|
384
|
+
should 'generate proper paths for images and other files' do
|
385
|
+
assert_match /\/images\/app.png\?\d+/, asset_path(:images, 'app.png')
|
386
|
+
assert_match /\/documents\/app.pdf\?\d+/, asset_path(:documents, 'app.pdf')
|
387
|
+
end
|
388
|
+
|
389
|
+
should 'generate proper paths for public folder' do
|
390
|
+
assert_match /\/files\/file.ext\?\d+/, asset_path('files/file.ext')
|
391
|
+
end
|
392
|
+
end
|
359
393
|
end
|
data/test/test_form_builder.rb
CHANGED
@@ -70,6 +70,16 @@ describe "FormBuilder" do
|
|
70
70
|
assert_has_tag(:input, :type => 'text', :name => 'user[role_types_attributes][0][name]', :id => 'foo_user_role_types_attributes_0_name') { actual_html }
|
71
71
|
end
|
72
72
|
|
73
|
+
should "display correct form html with :as option" do
|
74
|
+
actual_html = form_for(@user, '/update', :as => :customer) do |f|
|
75
|
+
f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
|
76
|
+
end
|
77
|
+
|
78
|
+
assert_has_no_tag(:form, :as => 'customer') { actual_html }
|
79
|
+
assert_has_tag(:input, :type => 'text', :name => 'customer[first_name]', :id => 'customer_first_name') { actual_html }
|
80
|
+
assert_has_tag(:input, :type => 'text', :name => 'customer[role_types_attributes][0][name]', :id => 'customer_role_types_attributes_0_name') { actual_html }
|
81
|
+
end
|
82
|
+
|
73
83
|
should "display correct form html with remote option and method put" do
|
74
84
|
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true, :method => 'put') { "Demo" }
|
75
85
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true') { actual_html }
|
data/test/test_form_helpers.rb
CHANGED
@@ -675,7 +675,7 @@ describe "FormHelpers" do
|
|
675
675
|
should "display select tag with grouped options for a nested array and accept disabled groups" do
|
676
676
|
opts = [
|
677
677
|
["Friends",["Yoda",["Obiwan",2]]],
|
678
|
-
["Enemies", ["Palpatine",['Darth Vader',3]], true]
|
678
|
+
["Enemies", ["Palpatine",['Darth Vader',3]], {:disabled => true}]
|
679
679
|
]
|
680
680
|
actual_html = select_tag( 'name', :grouped_options => opts )
|
681
681
|
assert_has_tag(:select, :name => "name") { actual_html }
|
@@ -686,8 +686,8 @@ describe "FormHelpers" do
|
|
686
686
|
|
687
687
|
should "display select tag with grouped options for a nested array and accept disabled groups and/or with disabled options" do
|
688
688
|
opts = [
|
689
|
-
["Friends",["Yoda",["Obiwan",2, true]]],
|
690
|
-
["Enemies", [["Palpatine", "Palpatine", true],['Darth Vader',3]], true]
|
689
|
+
["Friends",["Yoda",["Obiwan",2, {:disabled => true}]]],
|
690
|
+
["Enemies", [["Palpatine", "Palpatine", {:disabled => true}],['Darth Vader',3]], {:disabled => true}]
|
691
691
|
]
|
692
692
|
actual_html = select_tag( 'name', :grouped_options => opts )
|
693
693
|
assert_has_tag(:select, :name => "name") { actual_html }
|
@@ -713,22 +713,10 @@ describe "FormHelpers" do
|
|
713
713
|
assert_has_tag(:option, :value => "3", :content => "Darth Vader") { actual_html }
|
714
714
|
end
|
715
715
|
|
716
|
-
should "display select tag with grouped options for a hash and accept disabled groups" do
|
717
|
-
opts = {
|
718
|
-
"Friends" => ["Yoda",["Obiwan",2]],
|
719
|
-
"Enemies" => ["Palpatine",['Darth Vader',3], {:disabled => true}]
|
720
|
-
}
|
721
|
-
actual_html = select_tag( 'name', :grouped_options => opts )
|
722
|
-
assert_has_tag(:select, :name => "name") { actual_html }
|
723
|
-
assert_has_tag(:option, :disabled => 'disabled', :count => 0) { actual_html }
|
724
|
-
assert_has_tag(:optgroup, :disabled => 'disabled', :count => 1) { actual_html }
|
725
|
-
assert_has_tag(:optgroup, :label => "Enemies", :disabled => 'disabled') { actual_html }
|
726
|
-
end
|
727
|
-
|
728
716
|
should "display select tag with grouped options for a hash and accept disabled groups and/or with disabled options" do
|
729
717
|
opts = {
|
730
|
-
"Friends" => ["Yoda",["Obiwan",2,true]],
|
731
|
-
"Enemies" => [["Palpatine","Palpatine",true],["Darth Vader",3], {:disabled => true}]
|
718
|
+
"Friends" => ["Yoda",["Obiwan",2,{:disabled => true}]],
|
719
|
+
"Enemies" => [["Palpatine","Palpatine",{:disabled => true}],["Darth Vader",3], {:disabled => true}]
|
732
720
|
}
|
733
721
|
actual_html = select_tag( 'name', :grouped_options => opts )
|
734
722
|
assert_has_tag(:select, :name => "name") { actual_html }
|
@@ -739,6 +727,18 @@ describe "FormHelpers" do
|
|
739
727
|
assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine", :disabled => 'disabled') { actual_html }
|
740
728
|
end
|
741
729
|
|
730
|
+
should "display select tag with grouped options for a rails-style attribute hash" do
|
731
|
+
opts = {
|
732
|
+
"Friends" => ["Yoda",["Obiwan",2,{:magister=>'no'}],{:lame=>'yes'}],
|
733
|
+
"Enemies" => [["Palpatine","Palpatine",{:scary=>'yes',:old=>'yes'}],["Darth Vader",3,{:disabled=>true}]]
|
734
|
+
}
|
735
|
+
actual_html = select_tag( 'name', :grouped_options => opts, :disabled_options => [2], :selected => ['Yoda'] )
|
736
|
+
assert_has_tag(:optgroup, :label => "Friends", :lame => 'yes') { actual_html }
|
737
|
+
assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine", :scary => 'yes', :old => 'yes') { actual_html }
|
738
|
+
assert_has_tag(:option, :content => "Darth Vader", :disabled => 'disabled') { actual_html }
|
739
|
+
assert_has_tag(:option, :content => "Obiwan", :disabled => 'disabled') { actual_html }
|
740
|
+
assert_has_tag(:option, :content => "Yoda", :selected => 'selected') { actual_html }
|
741
|
+
end
|
742
742
|
|
743
743
|
should "display select tag in ruby with multiple attribute" do
|
744
744
|
actual_html = select_tag(:favorite_color, :multiple => true, :options => ['only', 'option'])
|
@@ -756,7 +756,7 @@ describe "FormHelpers" do
|
|
756
756
|
end
|
757
757
|
|
758
758
|
should "display options with values and accept disabled options" do
|
759
|
-
options = [['Green', 'green1', true], ['Blue', 'blue1'], ['Black', "black1"]]
|
759
|
+
options = [['Green', 'green1', {:disabled => true}], ['Blue', 'blue1'], ['Black', "black1"]]
|
760
760
|
actual_html = select_tag(:favorite_color, :options => options)
|
761
761
|
assert_has_tag(:select, :name => 'favorite_color') { actual_html }
|
762
762
|
assert_has_tag('select option', :disabled => 'disabled', :count => 1) { actual_html }
|
data/test/test_format_helpers.rb
CHANGED
@@ -29,6 +29,16 @@ describe "FormatHelpers" do
|
|
29
29
|
assert_equal "<p class=\"description\">Look me! A class!</p>", actual_text
|
30
30
|
end
|
31
31
|
|
32
|
+
should "escape html tags" do
|
33
|
+
actual_text = simple_format("Will you escape <b>that</b>?")
|
34
|
+
assert_equal "<p>Will you escape <b>that</b>?</p>", actual_text
|
35
|
+
end
|
36
|
+
|
37
|
+
should "support already sanitized text" do
|
38
|
+
actual_text = simple_format("Don't try to escape <b>me</b>!".html_safe)
|
39
|
+
assert_equal "<p>Don't try to escape <b>me</b>!</p>", actual_text
|
40
|
+
end
|
41
|
+
|
32
42
|
context 'wrapped in a custom tag' do
|
33
43
|
should "format simple text into html format" do
|
34
44
|
actual_text = simple_format("Here is some basic text...\n...with a line break.", :tag => :div)
|
data/test/test_output_helpers.rb
CHANGED
@@ -9,20 +9,26 @@ describe "OutputHelpers" do
|
|
9
9
|
context 'for #content_for method' do
|
10
10
|
should 'work for erb templates' do
|
11
11
|
visit '/erb/content_for'
|
12
|
-
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
|
13
|
-
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
|
12
|
+
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
|
13
|
+
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
|
14
|
+
assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication"
|
15
|
+
assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
|
14
16
|
end
|
15
17
|
|
16
18
|
should "work for haml templates" do
|
17
19
|
visit '/haml/content_for'
|
18
|
-
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
|
19
|
-
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
|
20
|
+
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
|
21
|
+
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
|
22
|
+
assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication"
|
23
|
+
assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
|
20
24
|
end
|
21
25
|
|
22
26
|
should "work for slim templates" do
|
23
27
|
visit '/slim/content_for'
|
24
|
-
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
|
25
|
-
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
|
28
|
+
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
|
29
|
+
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
|
30
|
+
assert_have_no_selector '.demo3 p', :content => "One", :class => "duplication"
|
31
|
+
assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
|
26
32
|
end
|
27
33
|
end # content_for
|
28
34
|
|
@@ -49,20 +55,20 @@ describe "OutputHelpers" do
|
|
49
55
|
context 'for #capture_html method' do
|
50
56
|
should "work for erb templates" do
|
51
57
|
visit '/erb/capture_concat'
|
52
|
-
assert_have_selector 'p span', :content => "Captured Line 1"
|
53
|
-
assert_have_selector 'p span', :content => "Captured Line 2"
|
58
|
+
assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
|
59
|
+
assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
|
54
60
|
end
|
55
61
|
|
56
62
|
should "work for haml templates" do
|
57
63
|
visit '/haml/capture_concat'
|
58
|
-
assert_have_selector 'p span', :content => "Captured Line 1"
|
59
|
-
assert_have_selector 'p span', :content => "Captured Line 2"
|
64
|
+
assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
|
65
|
+
assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
|
60
66
|
end
|
61
67
|
|
62
68
|
should "work for slim templates" do
|
63
69
|
visit '/slim/capture_concat'
|
64
|
-
assert_have_selector 'p span', :content => "Captured Line 1"
|
65
|
-
assert_have_selector 'p span', :content => "Captured Line 2"
|
70
|
+
assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
|
71
|
+
assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|
@@ -79,30 +85,27 @@ describe "OutputHelpers" do
|
|
79
85
|
|
80
86
|
should "work for slim templates" do
|
81
87
|
visit '/slim/capture_concat'
|
82
|
-
|
83
|
-
# assert_have_selector 'p', :content => "Concat Line 3", :count => 1
|
88
|
+
assert_have_selector 'p', :content => "Concat Line 3", :count => 1
|
84
89
|
end
|
85
90
|
end
|
86
91
|
|
87
92
|
context 'for #block_is_template?' do
|
88
93
|
should "work for erb templates" do
|
89
94
|
visit '/erb/capture_concat'
|
90
|
-
assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template'
|
91
|
-
|
92
|
-
# assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
|
95
|
+
assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template', :count => 1
|
96
|
+
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
|
93
97
|
end
|
94
98
|
|
95
99
|
should "work for haml templates" do
|
96
100
|
visit '/haml/capture_concat'
|
97
|
-
assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template'
|
98
|
-
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
|
101
|
+
assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template', :count => 1
|
102
|
+
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
|
99
103
|
end
|
100
104
|
|
101
105
|
should "work for slim templates" do
|
102
106
|
visit '/slim/capture_concat'
|
103
|
-
|
104
|
-
|
105
|
-
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
|
107
|
+
assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template', :count => 1
|
108
|
+
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
data/test/test_render_helpers.rb
CHANGED
@@ -54,6 +54,57 @@ describe "RenderHelpers" do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
context 'render with block' do
|
58
|
+
should 'render slim with block' do
|
59
|
+
visit '/render_block_slim'
|
60
|
+
assert_have_selector 'h1', :content => 'prefix'
|
61
|
+
assert_have_selector 'h3', :content => 'postfix'
|
62
|
+
assert_have_selector '.slim-block'
|
63
|
+
assert_have_selector 'div', :content => 'go block!'
|
64
|
+
end
|
65
|
+
should 'render erb with block' do
|
66
|
+
visit '/render_block_erb'
|
67
|
+
assert_have_selector 'h1', :content => 'prefix'
|
68
|
+
assert_have_selector 'h3', :content => 'postfix'
|
69
|
+
assert_have_selector '.erb-block'
|
70
|
+
assert_have_selector 'div', :content => 'go block!'
|
71
|
+
end
|
72
|
+
should 'render haml with block' do
|
73
|
+
visit '/render_block_haml'
|
74
|
+
assert_have_selector 'h1', :content => 'prefix'
|
75
|
+
assert_have_selector 'h3', :content => 'postfix'
|
76
|
+
assert_have_selector '.haml-block'
|
77
|
+
assert_have_selector 'div', :content => 'go block!'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'partial with block' do
|
82
|
+
should 'show partial slim with block' do
|
83
|
+
visit '/partial_block_slim'
|
84
|
+
assert_have_selector 'h1', :content => 'prefix'
|
85
|
+
assert_have_selector 'h3', :content => 'postfix'
|
86
|
+
assert_have_selector '.slim-block'
|
87
|
+
assert_have_selector 'div', :content => 'go block!'
|
88
|
+
assert_have_selector 'div.deep', :content => 'Done'
|
89
|
+
end
|
90
|
+
should 'show partial erb with block' do
|
91
|
+
visit '/partial_block_erb'
|
92
|
+
assert_have_selector 'h1', :content => 'prefix'
|
93
|
+
assert_have_selector 'h3', :content => 'postfix'
|
94
|
+
assert_have_selector '.erb-block'
|
95
|
+
assert_have_selector 'div', :content => 'go block!'
|
96
|
+
assert_have_selector 'div.deep', :content => 'Done'
|
97
|
+
end
|
98
|
+
should 'show partial haml with block' do
|
99
|
+
visit '/partial_block_haml'
|
100
|
+
assert_have_selector 'h1', :content => 'prefix'
|
101
|
+
assert_have_selector 'h3', :content => 'postfix'
|
102
|
+
assert_have_selector '.haml-block'
|
103
|
+
assert_have_selector 'div', :content => 'go block!'
|
104
|
+
assert_have_selector 'div.deep', :content => 'Done'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
57
108
|
context 'for #current_engine method' do
|
58
109
|
should 'detect correctly current engine for a padrino application' do
|
59
110
|
visit '/current_engine'
|
@@ -90,5 +141,21 @@ describe "RenderHelpers" do
|
|
90
141
|
visit '/double_capture_erb'
|
91
142
|
assert_equal 1,$number_of_captures
|
92
143
|
end
|
144
|
+
|
145
|
+
should "fail on wrong erb usage" do
|
146
|
+
assert_raises(SyntaxError) do
|
147
|
+
visit '/wrong_capture_erb'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
should "ignore wrong haml usage" do
|
152
|
+
visit '/wrong_capture_haml'
|
153
|
+
assert_have_no_selector 'p', :content => 'this is wrong'
|
154
|
+
end
|
155
|
+
|
156
|
+
should "ignore wrong slim usage" do
|
157
|
+
visit '/wrong_capture_slim'
|
158
|
+
assert_have_no_selector 'p', :content => 'this is wrong'
|
159
|
+
end
|
93
160
|
end
|
94
161
|
end
|
data/test/test_tag_helpers.rb
CHANGED
@@ -70,6 +70,9 @@ describe "TagHelpers" do
|
|
70
70
|
assert_have_selector :p, :content => "Test 2"
|
71
71
|
assert_have_selector :p, :content => "Test 3"
|
72
72
|
assert_have_selector :p, :content => "Test 4"
|
73
|
+
assert_have_selector :p, :content => "one"
|
74
|
+
assert_have_selector :p, :content => "two"
|
75
|
+
assert_have_no_selector :p, :content => "failed"
|
73
76
|
end
|
74
77
|
|
75
78
|
should "support tags with haml" do
|
@@ -78,6 +81,9 @@ describe "TagHelpers" do
|
|
78
81
|
assert_have_selector :p, :content => "Test 2"
|
79
82
|
assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3'
|
80
83
|
assert_have_selector :p, :content => "Test 4"
|
84
|
+
assert_have_selector :p, :content => "one"
|
85
|
+
assert_have_selector :p, :content => "two"
|
86
|
+
assert_have_no_selector :p, :content => "failed"
|
81
87
|
end
|
82
88
|
|
83
89
|
should "support tags with slim" do
|
@@ -86,6 +92,9 @@ describe "TagHelpers" do
|
|
86
92
|
assert_have_selector :p, :content => "Test 2"
|
87
93
|
assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3'
|
88
94
|
assert_have_selector :p, :content => "Test 4"
|
95
|
+
assert_have_selector :p, :content => "one"
|
96
|
+
assert_have_selector :p, :content => "two"
|
97
|
+
assert_have_no_selector :p, :content => "failed"
|
89
98
|
end
|
90
99
|
end
|
91
100
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-12-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-core
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.12.0.rc1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.12.0.rc1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: i18n
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,6 +34,9 @@ dependencies:
|
|
34
34
|
- - ~>
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '0.6'
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.6.7
|
37
40
|
type: :runtime
|
38
41
|
prerelease: false
|
39
42
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -41,6 +44,9 @@ dependencies:
|
|
41
44
|
- - ~>
|
42
45
|
- !ruby/object:Gem::Version
|
43
46
|
version: '0.6'
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.6.7
|
44
50
|
description: Tag helpers, asset helpers, form helpers, form builders and many more
|
45
51
|
helpers for padrino
|
46
52
|
email: padrinorb@gmail.com
|
@@ -134,6 +140,12 @@ files:
|
|
134
140
|
- test/fixtures/markup_app/views/simple_partial.haml
|
135
141
|
- test/fixtures/markup_app/views/simple_partial.slim
|
136
142
|
- test/fixtures/render_app/app.rb
|
143
|
+
- test/fixtures/render_app/views/_deep.erb
|
144
|
+
- test/fixtures/render_app/views/_deep.haml
|
145
|
+
- test/fixtures/render_app/views/_deep.slim
|
146
|
+
- test/fixtures/render_app/views/_partial_block_erb.erb
|
147
|
+
- test/fixtures/render_app/views/_partial_block_haml.haml
|
148
|
+
- test/fixtures/render_app/views/_partial_block_slim.slim
|
137
149
|
- test/fixtures/render_app/views/current_engine.haml
|
138
150
|
- test/fixtures/render_app/views/current_engines/_erb.erb
|
139
151
|
- test/fixtures/render_app/views/current_engines/_haml.haml
|
@@ -144,9 +156,15 @@ files:
|
|
144
156
|
- test/fixtures/render_app/views/erb/test.erb
|
145
157
|
- test/fixtures/render_app/views/explicit_engine.haml
|
146
158
|
- test/fixtures/render_app/views/haml/test.haml
|
159
|
+
- test/fixtures/render_app/views/render_block_erb.erb
|
160
|
+
- test/fixtures/render_app/views/render_block_haml.haml
|
161
|
+
- test/fixtures/render_app/views/render_block_slim.slim
|
147
162
|
- test/fixtures/render_app/views/template/_user.haml
|
148
163
|
- test/fixtures/render_app/views/template/haml_template.haml
|
149
164
|
- test/fixtures/render_app/views/template/some_template.haml
|
165
|
+
- test/fixtures/render_app/views/wrong_capture_erb.erb
|
166
|
+
- test/fixtures/render_app/views/wrong_capture_haml.haml
|
167
|
+
- test/fixtures/render_app/views/wrong_capture_slim.slim
|
150
168
|
- test/helper.rb
|
151
169
|
- test/test_asset_tag_helpers.rb
|
152
170
|
- test/test_breadcrumb_helpers.rb
|
@@ -159,7 +177,8 @@ files:
|
|
159
177
|
- test/test_render_helpers.rb
|
160
178
|
- test/test_tag_helpers.rb
|
161
179
|
homepage: http://www.padrinorb.com
|
162
|
-
licenses:
|
180
|
+
licenses:
|
181
|
+
- MIT
|
163
182
|
metadata: {}
|
164
183
|
post_install_message:
|
165
184
|
rdoc_options:
|
@@ -173,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
192
|
version: '0'
|
174
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
194
|
requirements:
|
176
|
-
- - '
|
195
|
+
- - '>'
|
177
196
|
- !ruby/object:Gem::Version
|
178
|
-
version: 1.3.
|
197
|
+
version: 1.3.1
|
179
198
|
requirements: []
|
180
199
|
rubyforge_project: padrino-helpers
|
181
200
|
rubygems_version: 2.0.6
|
@@ -224,6 +243,12 @@ test_files:
|
|
224
243
|
- test/fixtures/markup_app/views/simple_partial.haml
|
225
244
|
- test/fixtures/markup_app/views/simple_partial.slim
|
226
245
|
- test/fixtures/render_app/app.rb
|
246
|
+
- test/fixtures/render_app/views/_deep.erb
|
247
|
+
- test/fixtures/render_app/views/_deep.haml
|
248
|
+
- test/fixtures/render_app/views/_deep.slim
|
249
|
+
- test/fixtures/render_app/views/_partial_block_erb.erb
|
250
|
+
- test/fixtures/render_app/views/_partial_block_haml.haml
|
251
|
+
- test/fixtures/render_app/views/_partial_block_slim.slim
|
227
252
|
- test/fixtures/render_app/views/current_engine.haml
|
228
253
|
- test/fixtures/render_app/views/current_engines/_erb.erb
|
229
254
|
- test/fixtures/render_app/views/current_engines/_haml.haml
|
@@ -234,9 +259,15 @@ test_files:
|
|
234
259
|
- test/fixtures/render_app/views/erb/test.erb
|
235
260
|
- test/fixtures/render_app/views/explicit_engine.haml
|
236
261
|
- test/fixtures/render_app/views/haml/test.haml
|
262
|
+
- test/fixtures/render_app/views/render_block_erb.erb
|
263
|
+
- test/fixtures/render_app/views/render_block_haml.haml
|
264
|
+
- test/fixtures/render_app/views/render_block_slim.slim
|
237
265
|
- test/fixtures/render_app/views/template/_user.haml
|
238
266
|
- test/fixtures/render_app/views/template/haml_template.haml
|
239
267
|
- test/fixtures/render_app/views/template/some_template.haml
|
268
|
+
- test/fixtures/render_app/views/wrong_capture_erb.erb
|
269
|
+
- test/fixtures/render_app/views/wrong_capture_haml.haml
|
270
|
+
- test/fixtures/render_app/views/wrong_capture_slim.slim
|
240
271
|
- test/helper.rb
|
241
272
|
- test/test_asset_tag_helpers.rb
|
242
273
|
- test/test_breadcrumb_helpers.rb
|