padrino-helpers 0.16.0.pre4 → 0.16.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +29 -29
  3. data/Rakefile +1 -1
  4. data/lib/padrino/rendering/erb_template.rb +7 -7
  5. data/lib/padrino/rendering/erubi_template.rb +4 -4
  6. data/lib/padrino/rendering/erubis_template.rb +4 -4
  7. data/lib/padrino/rendering/haml_template.rb +1 -1
  8. data/lib/padrino/rendering/hamlit_template.rb +4 -4
  9. data/lib/padrino/rendering/slim_template.rb +5 -5
  10. data/lib/padrino/rendering.rb +54 -45
  11. data/lib/padrino/safe_buffer.rb +31 -36
  12. data/lib/padrino-helpers/asset_tag_helpers.rb +48 -48
  13. data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +74 -70
  14. data/lib/padrino-helpers/form_builder/standard_form_builder.rb +20 -20
  15. data/lib/padrino-helpers/form_helpers/errors.rb +14 -14
  16. data/lib/padrino-helpers/form_helpers/options.rb +25 -24
  17. data/lib/padrino-helpers/form_helpers/security.rb +5 -5
  18. data/lib/padrino-helpers/form_helpers.rb +133 -133
  19. data/lib/padrino-helpers/format_helpers.rb +61 -63
  20. data/lib/padrino-helpers/number_helpers.rb +82 -78
  21. data/lib/padrino-helpers/output_helpers/abstract_handler.rb +5 -3
  22. data/lib/padrino-helpers/output_helpers/erb_handler.rb +2 -2
  23. data/lib/padrino-helpers/output_helpers/haml_handler.rb +1 -1
  24. data/lib/padrino-helpers/output_helpers.rb +16 -17
  25. data/lib/padrino-helpers/render_helpers.rb +28 -27
  26. data/lib/padrino-helpers/tag_helpers.rb +62 -58
  27. data/lib/padrino-helpers/translation_helpers.rb +2 -2
  28. data/lib/padrino-helpers.rb +1 -2
  29. data/padrino-helpers.gemspec +17 -17
  30. data/test/fixtures/apps/render.rb +2 -2
  31. data/test/fixtures/markup_app/app.rb +9 -8
  32. data/test/fixtures/markup_app/views/button_to.erb +3 -3
  33. data/test/fixtures/markup_app/views/button_to.haml +2 -2
  34. data/test/fixtures/markup_app/views/button_to.slim +3 -3
  35. data/test/fixtures/markup_app/views/content_for.erb +4 -4
  36. data/test/fixtures/markup_app/views/content_for.haml +4 -4
  37. data/test/fixtures/markup_app/views/content_for.slim +2 -2
  38. data/test/fixtures/markup_app/views/content_tag.erb +3 -3
  39. data/test/fixtures/markup_app/views/content_tag.haml +3 -3
  40. data/test/fixtures/markup_app/views/content_tag.slim +3 -3
  41. data/test/fixtures/markup_app/views/fields_for.erb +2 -2
  42. data/test/fixtures/markup_app/views/fields_for.haml +2 -2
  43. data/test/fixtures/markup_app/views/fields_for.slim +2 -2
  44. data/test/fixtures/markup_app/views/form_for.erb +41 -41
  45. data/test/fixtures/markup_app/views/form_for.haml +41 -41
  46. data/test/fixtures/markup_app/views/form_for.slim +41 -42
  47. data/test/fixtures/markup_app/views/form_tag.erb +47 -47
  48. data/test/fixtures/markup_app/views/form_tag.haml +48 -48
  49. data/test/fixtures/markup_app/views/form_tag.slim +49 -49
  50. data/test/fixtures/markup_app/views/link_to.erb +2 -2
  51. data/test/fixtures/markup_app/views/link_to.haml +2 -2
  52. data/test/fixtures/markup_app/views/link_to.slim +2 -2
  53. data/test/fixtures/markup_app/views/meta_tag.erb +2 -2
  54. data/test/fixtures/markup_app/views/meta_tag.haml +2 -2
  55. data/test/fixtures/markup_app/views/meta_tag.slim +2 -2
  56. data/test/fixtures/markup_app/views/simple_partial.erb +1 -1
  57. data/test/fixtures/markup_app/views/simple_partial.haml +1 -1
  58. data/test/fixtures/markup_app/views/simple_partial.slim +1 -1
  59. data/test/fixtures/render_app/app.rb +13 -12
  60. data/test/fixtures/render_app/views/_unsafe.html.builder +1 -1
  61. data/test/fixtures/render_app/views/_unsafe_object.html.builder +1 -1
  62. data/test/fixtures/render_app/views/explicit_engine.haml +3 -3
  63. data/test/helper.rb +19 -19
  64. data/test/test_asset_tag_helpers.rb +133 -133
  65. data/test/test_form_builder.rb +629 -628
  66. data/test/test_form_helpers.rb +610 -610
  67. data/test/test_format_helpers.rb +66 -63
  68. data/test/test_helpers.rb +2 -2
  69. data/test/test_locale.rb +13 -11
  70. data/test/test_number_helpers.rb +65 -65
  71. data/test/test_output_helpers.rb +76 -76
  72. data/test/test_render_helpers.rb +101 -101
  73. data/test/test_rendering.rb +329 -326
  74. data/test/test_rendering_extensions.rb +4 -4
  75. data/test/test_tag_helpers.rb +55 -55
  76. metadata +6 -6
@@ -1,157 +1,157 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
2
- require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
1
+ require_relative 'helper'
2
+ require_relative 'fixtures/markup_app/app'
3
3
 
4
- describe "OutputHelpers" do
4
+ describe 'OutputHelpers' do
5
5
  def app
6
6
  MarkupDemo
7
7
  end
8
8
 
9
9
  describe 'for #content_for method' do
10
10
  it 'should work for erb templates' do
11
- get "/erb/content_for"
12
- assert_response_has_tag '.demo h1', :content => "This is content yielded from a content_for", :count => 1
13
- assert_response_has_tag '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
14
- assert_response_has_no_tag '.demo3 p', :content => "One", :class => "duplication"
15
- assert_response_has_tag '.demo3 p', :content => "Two", :class => "duplication"
11
+ get '/erb/content_for'
12
+ assert_response_has_tag '.demo h1', content: 'This is content yielded from a content_for', count: 1
13
+ assert_response_has_tag '.demo2 h1', content: 'This is content yielded with name Johnny Smith', count: 1
14
+ assert_response_has_no_tag '.demo3 p', content: 'One', class: 'duplication'
15
+ assert_response_has_tag '.demo3 p', content: 'Two', class: 'duplication'
16
16
  end
17
17
 
18
18
  it 'should work for haml templates' do
19
- get "/haml/content_for"
20
- assert_response_has_tag '.demo h1', :content => "This is content yielded from a content_for", :count => 1
21
- assert_response_has_tag '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
22
- assert_response_has_no_tag '.demo3 p', :content => "One", :class => "duplication"
23
- assert_response_has_tag '.demo3 p', :content => "Two", :class => "duplication"
19
+ get '/haml/content_for'
20
+ assert_response_has_tag '.demo h1', content: 'This is content yielded from a content_for', count: 1
21
+ assert_response_has_tag '.demo2 h1', content: 'This is content yielded with name Johnny Smith', count: 1
22
+ assert_response_has_no_tag '.demo3 p', content: 'One', class: 'duplication'
23
+ assert_response_has_tag '.demo3 p', content: 'Two', class: 'duplication'
24
24
  end
25
25
 
26
26
  it 'should work for slim templates' do
27
- get "/slim/content_for"
28
- assert_response_has_tag '.demo h1', :content => "This is content yielded from a content_for", :count => 1
29
- assert_response_has_tag '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
30
- assert_response_has_no_tag '.demo3 p', :content => "One", :class => "duplication"
31
- assert_response_has_tag '.demo3 p', :content => "Two", :class => "duplication"
27
+ get '/slim/content_for'
28
+ assert_response_has_tag '.demo h1', content: 'This is content yielded from a content_for', count: 1
29
+ assert_response_has_tag '.demo2 h1', content: 'This is content yielded with name Johnny Smith', count: 1
30
+ assert_response_has_no_tag '.demo3 p', content: 'One', class: 'duplication'
31
+ assert_response_has_tag '.demo3 p', content: 'Two', class: 'duplication'
32
32
  end
33
33
  end # content_for
34
34
 
35
- describe "for #content_for? method" do
35
+ describe 'for #content_for? method' do
36
36
  it 'should work for erb templates' do
37
- get "/erb/content_for"
38
- assert_response_has_tag '.demo_has_content', :content => "true"
39
- assert_response_has_tag '.fake_has_content', :content => "false"
37
+ get '/erb/content_for'
38
+ assert_response_has_tag '.demo_has_content', content: 'true'
39
+ assert_response_has_tag '.fake_has_content', content: 'false'
40
40
  end
41
41
 
42
42
  it 'should work for haml templates' do
43
- get "/haml/content_for"
44
- assert_response_has_tag '.demo_has_content', :content => "true"
45
- assert_response_has_tag '.fake_has_content', :content => "false"
43
+ get '/haml/content_for'
44
+ assert_response_has_tag '.demo_has_content', content: 'true'
45
+ assert_response_has_tag '.fake_has_content', content: 'false'
46
46
  end
47
47
 
48
48
  it 'should work for slim templates' do
49
- get "/slim/content_for"
50
- assert_response_has_tag '.demo_has_content', :content => "true"
51
- assert_response_has_tag '.fake_has_content', :content => "false"
49
+ get '/slim/content_for'
50
+ assert_response_has_tag '.demo_has_content', content: 'true'
51
+ assert_response_has_tag '.fake_has_content', content: 'false'
52
52
  end
53
53
  end # content_for?
54
54
 
55
55
  describe 'for #capture_html method' do
56
56
  it 'should work for erb templates' do
57
- get "/erb/capture_concat"
58
- assert_response_has_tag 'p span', :content => "Captured Line 1", :count => 1
59
- assert_response_has_tag 'p span', :content => "Captured Line 2", :count => 1
57
+ get '/erb/capture_concat'
58
+ assert_response_has_tag 'p span', content: 'Captured Line 1', count: 1
59
+ assert_response_has_tag 'p span', content: 'Captured Line 2', count: 1
60
60
  end
61
61
 
62
62
  it 'should work for haml templates' do
63
- get "/haml/capture_concat"
64
- assert_response_has_tag 'p span', :content => "Captured Line 1", :count => 1
65
- assert_response_has_tag 'p span', :content => "Captured Line 2", :count => 1
63
+ get '/haml/capture_concat'
64
+ assert_response_has_tag 'p span', content: 'Captured Line 1', count: 1
65
+ assert_response_has_tag 'p span', content: 'Captured Line 2', count: 1
66
66
  end
67
67
 
68
68
  it 'should work for slim templates' do
69
- get "/slim/capture_concat"
70
- assert_response_has_tag 'p span', :content => "Captured Line 1", :count => 1
71
- assert_response_has_tag 'p span', :content => "Captured Line 2", :count => 1
69
+ get '/slim/capture_concat'
70
+ assert_response_has_tag 'p span', content: 'Captured Line 1', count: 1
71
+ assert_response_has_tag 'p span', content: 'Captured Line 2', count: 1
72
72
  end
73
73
  end
74
74
 
75
75
  describe 'for #concat_content method' do
76
76
  it 'should work for erb templates' do
77
- get "/erb/capture_concat"
78
- assert_response_has_tag 'p', :content => "Concat Line 3", :count => 1
77
+ get '/erb/capture_concat'
78
+ assert_response_has_tag 'p', content: 'Concat Line 3', count: 1
79
79
  end
80
80
 
81
81
  it 'should work for haml templates' do
82
- get "/haml/capture_concat"
83
- assert_response_has_tag 'p', :content => "Concat Line 3", :count => 1
82
+ get '/haml/capture_concat'
83
+ assert_response_has_tag 'p', content: 'Concat Line 3', count: 1
84
84
  end
85
85
 
86
86
  it 'should work for slim templates' do
87
- get "/slim/capture_concat"
88
- assert_response_has_tag 'p', :content => "Concat Line 3", :count => 1
87
+ get '/slim/capture_concat'
88
+ assert_response_has_tag 'p', content: 'Concat Line 3', count: 1
89
89
  end
90
90
  end
91
91
 
92
92
  describe 'for #block_is_template?' do
93
93
  it 'should work for erb templates' do
94
- get "/erb/capture_concat"
95
- assert_response_has_tag 'p', :content => "The erb block passed in is a template", :class => 'is_template', :count => 1
96
- assert_response_has_no_tag 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
94
+ get '/erb/capture_concat'
95
+ assert_response_has_tag 'p', content: 'The erb block passed in is a template', class: 'is_template', count: 1
96
+ assert_response_has_no_tag 'p', content: 'The ruby block passed in is a template', class: 'is_template', count: 1
97
97
  end
98
98
 
99
99
  it 'should work for haml templates' do
100
- get "/haml/capture_concat"
101
- assert_response_has_tag 'p', :content => "The haml block passed in is a template", :class => 'is_template', :count => 1
102
- assert_response_has_no_tag 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
100
+ get '/haml/capture_concat'
101
+ assert_response_has_tag 'p', content: 'The haml block passed in is a template', class: 'is_template', count: 1
102
+ assert_response_has_no_tag 'p', content: 'The ruby block passed in is a template', class: 'is_template', count: 1
103
103
  end
104
104
 
105
105
  it 'should work for slim templates' do
106
- get "/slim/capture_concat"
107
- assert_response_has_tag 'p', :content => "The slim block passed in is a template", :class => 'is_template', :count => 1
108
- assert_response_has_no_tag 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
106
+ get '/slim/capture_concat'
107
+ assert_response_has_tag 'p', content: 'The slim block passed in is a template', class: 'is_template', count: 1
108
+ assert_response_has_no_tag 'p', content: 'The ruby block passed in is a template', class: 'is_template', count: 1
109
109
  end
110
110
  end
111
111
 
112
112
  describe 'for #current_engine method' do
113
113
  it 'should detect correctly current engine for erb' do
114
- get "/erb/current_engine"
115
- assert_response_has_tag 'p.start', :content => "erb"
116
- assert_response_has_tag 'p.haml', :content => "haml"
117
- assert_response_has_tag 'p.erb', :content => "erb"
118
- assert_response_has_tag 'p.slim', :content => "slim"
119
- assert_response_has_tag 'p.end', :content => "erb"
114
+ get '/erb/current_engine'
115
+ assert_response_has_tag 'p.start', content: 'erb'
116
+ assert_response_has_tag 'p.haml', content: 'haml'
117
+ assert_response_has_tag 'p.erb', content: 'erb'
118
+ assert_response_has_tag 'p.slim', content: 'slim'
119
+ assert_response_has_tag 'p.end', content: 'erb'
120
120
  end
121
121
 
122
122
  it 'should detect correctly current engine for haml' do
123
- get "/haml/current_engine"
124
- assert_response_has_tag 'p.start', :content => "haml"
125
- assert_response_has_tag 'p.haml', :content => "haml"
126
- assert_response_has_tag 'p.erb', :content => "erb"
127
- assert_response_has_tag 'p.slim', :content => "slim"
128
- assert_response_has_tag 'p.end', :content => "haml"
123
+ get '/haml/current_engine'
124
+ assert_response_has_tag 'p.start', content: 'haml'
125
+ assert_response_has_tag 'p.haml', content: 'haml'
126
+ assert_response_has_tag 'p.erb', content: 'erb'
127
+ assert_response_has_tag 'p.slim', content: 'slim'
128
+ assert_response_has_tag 'p.end', content: 'haml'
129
129
  end
130
130
 
131
131
  it 'should detect correctly current engine for slim' do
132
- get "/slim/current_engine"
133
- assert_response_has_tag 'p.start', :content => "slim"
134
- assert_response_has_tag 'p.haml', :content => "haml"
135
- assert_response_has_tag 'p.erb', :content => "erb"
136
- assert_response_has_tag 'p.slim', :content => "slim"
137
- assert_response_has_tag 'p.end', :content => "slim"
132
+ get '/slim/current_engine'
133
+ assert_response_has_tag 'p.start', content: 'slim'
134
+ assert_response_has_tag 'p.haml', content: 'haml'
135
+ assert_response_has_tag 'p.erb', content: 'erb'
136
+ assert_response_has_tag 'p.slim', content: 'slim'
137
+ assert_response_has_tag 'p.end', content: 'slim'
138
138
  end
139
139
  end
140
140
 
141
141
  describe 'for #partial method in simple sinatra application' do
142
142
  it 'should properly output in erb' do
143
- get "/erb/simple_partial"
144
- assert_response_has_tag 'p.erb', :content => "erb"
143
+ get '/erb/simple_partial'
144
+ assert_response_has_tag 'p.erb', content: 'erb'
145
145
  end
146
146
 
147
147
  it 'should properly output in haml' do
148
- get "/haml/simple_partial"
149
- assert_response_has_tag 'p.haml', :content => "haml"
148
+ get '/haml/simple_partial'
149
+ assert_response_has_tag 'p.haml', content: 'haml'
150
150
  end
151
151
 
152
152
  it 'should properly output in slim' do
153
- get "/slim/simple_partial"
154
- assert_response_has_tag 'p.slim', :content => "slim"
153
+ get '/slim/simple_partial'
154
+ assert_response_has_tag 'p.slim', content: 'slim'
155
155
  end
156
156
  end
157
157
  end
@@ -1,215 +1,215 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
2
- require File.expand_path(File.dirname(__FILE__) + '/fixtures/render_app/app')
1
+ require_relative 'helper'
2
+ require_relative 'fixtures/render_app/app'
3
3
 
4
- describe "RenderHelpers" do
4
+ describe 'RenderHelpers' do
5
5
  def app
6
6
  RenderDemo
7
7
  end
8
8
 
9
9
  describe 'for #partial method and object' do
10
- before { get "/partial/object" }
10
+ before { get '/partial/object' }
11
11
  it 'should render partial html with object' do
12
- assert_response_has_tag "h1", :content => "User name is John"
12
+ assert_response_has_tag 'h1', content: 'User name is John'
13
13
  end
14
14
  it 'should have no counter index for single item' do
15
- assert_response_has_no_tag "p", :content => "My counter is 1", :count => 1
15
+ assert_response_has_no_tag 'p', content: 'My counter is 1', count: 1
16
16
  end
17
17
  it 'should include extra locals information' do
18
- assert_response_has_tag 'p', :content => "Extra is bar"
18
+ assert_response_has_tag 'p', content: 'Extra is bar'
19
19
  end
20
20
  end
21
21
 
22
22
  describe 'for #partial method and collection' do
23
- before { get "/partial/collection" }
23
+ before { get '/partial/collection' }
24
24
  it 'should render partial html with collection' do
25
- assert_response_has_tag "h1", :content => "User name is John"
26
- assert_response_has_tag "h1", :content => "User name is Billy"
25
+ assert_response_has_tag 'h1', content: 'User name is John'
26
+ assert_response_has_tag 'h1', content: 'User name is Billy'
27
27
  end
28
28
  it 'should include counter which contains item index' do
29
- assert_response_has_tag "p", :content => "My counter is 1"
30
- assert_response_has_tag "p", :content => "My counter is 2"
29
+ assert_response_has_tag 'p', content: 'My counter is 1'
30
+ assert_response_has_tag 'p', content: 'My counter is 2'
31
31
  end
32
32
  it 'should include extra locals information' do
33
- assert_response_has_tag 'p', :content => "Extra is bar"
33
+ assert_response_has_tag 'p', content: 'Extra is bar'
34
34
  end
35
35
  end
36
36
 
37
37
  describe 'for #partial with ext and collection' do
38
- before { get "/partial/collection.ext" }
38
+ before { get '/partial/collection.ext' }
39
39
  it 'should not fail horribly with `invalid locals key` RuntimeError' do
40
- assert_response_has_tag "h1", :content => "User name is John"
40
+ assert_response_has_tag 'h1', content: 'User name is John'
41
41
  end
42
42
  end
43
43
 
44
44
  describe 'for #partial method and locals' do
45
- before { get "/partial/locals" }
45
+ before { get '/partial/locals' }
46
46
  it 'should render partial html with locals' do
47
- assert_response_has_tag "h1", :content => "User name is John"
47
+ assert_response_has_tag 'h1', content: 'User name is John'
48
48
  end
49
49
  it 'should have no counter index for single item' do
50
- assert_response_has_no_tag "p", :content => "My counter is 1", :count => 1
50
+ assert_response_has_no_tag 'p', content: 'My counter is 1', count: 1
51
51
  end
52
52
  it 'should include extra locals information' do
53
- assert_response_has_tag 'p', :content => "Extra is bar"
53
+ assert_response_has_tag 'p', content: 'Extra is bar'
54
54
  end
55
55
  end
56
56
 
57
57
  describe 'for #partial method taking a path starting with forward slash' do
58
- before { get "/partial/foward_slash" }
58
+ before { get '/partial/foward_slash' }
59
59
  it 'should render partial without throwing an error' do
60
- assert_response_has_tag "h1", :content => "User name is John"
60
+ assert_response_has_tag 'h1', content: 'User name is John'
61
61
  end
62
62
  end
63
63
 
64
64
  describe 'for #partial method with unsafe engine' do
65
65
  it 'should render partial without escaping it' do
66
- get "/partial/unsafe"
67
- assert_response_has_tag "h1", :content => "User name is John"
66
+ get '/partial/unsafe'
67
+ assert_response_has_tag 'h1', content: 'User name is John'
68
68
  end
69
69
  it 'should render partial object without escaping it' do
70
- get "/partial/unsafe_one"
71
- assert_response_has_tag "h1", :content => "User name is Mary"
70
+ get '/partial/unsafe_one'
71
+ assert_response_has_tag 'h1', content: 'User name is Mary'
72
72
  end
73
73
  it 'should render partial collection without escaping it' do
74
- get "/partial/unsafe_many"
75
- assert_response_has_tag "h1", :content => "User name is John"
76
- assert_response_has_tag "h1", :content => "User name is Mary"
74
+ get '/partial/unsafe_many'
75
+ assert_response_has_tag 'h1', content: 'User name is John'
76
+ assert_response_has_tag 'h1', content: 'User name is Mary'
77
77
  end
78
78
  it 'should render unsafe partial without escaping it' do
79
- get "/partial/unsafe?block=%3Cevil%3E"
80
- assert_response_has_tag "h1", :content => "User name is John"
81
- assert_response_has_tag "evil"
79
+ get '/partial/unsafe?block=%3Cevil%3E'
80
+ assert_response_has_tag 'h1', content: 'User name is John'
81
+ assert_response_has_tag 'evil'
82
82
  end
83
83
  it 'should render unsafe partial object without escaping it' do
84
- get "/partial/unsafe_one?block=%3Cevil%3E"
85
- assert_response_has_tag "h1", :content => "User name is Mary"
86
- assert_response_has_tag "evil"
84
+ get '/partial/unsafe_one?block=%3Cevil%3E'
85
+ assert_response_has_tag 'h1', content: 'User name is Mary'
86
+ assert_response_has_tag 'evil'
87
87
  end
88
88
  it 'should render unsafe partial collection without escaping it' do
89
- get "/partial/unsafe_many?block=%3Cevil%3E"
90
- assert_response_has_tag "h1", :content => "User name is John"
91
- assert_response_has_tag "h1", :content => "User name is Mary"
92
- assert_response_has_tag "evil"
89
+ get '/partial/unsafe_many?block=%3Cevil%3E'
90
+ assert_response_has_tag 'h1', content: 'User name is John'
91
+ assert_response_has_tag 'h1', content: 'User name is Mary'
92
+ assert_response_has_tag 'evil'
93
93
  end
94
94
  end
95
95
 
96
96
  describe 'render with block' do
97
97
  it 'should render slim with block' do
98
- get "/render_block_slim"
99
- assert_response_has_tag 'h1', :content => 'prefix'
100
- assert_response_has_tag 'h3', :content => 'postfix'
98
+ get '/render_block_slim'
99
+ assert_response_has_tag 'h1', content: 'prefix'
100
+ assert_response_has_tag 'h3', content: 'postfix'
101
101
  assert_response_has_tag '.slim-block'
102
- assert_response_has_tag 'div', :content => 'go block!'
102
+ assert_response_has_tag 'div', content: 'go block!'
103
103
  end
104
104
  it 'should render erb with block' do
105
- get "/render_block_erb"
106
- assert_response_has_tag 'h1', :content => 'prefix'
107
- assert_response_has_tag 'h3', :content => 'postfix'
105
+ get '/render_block_erb'
106
+ assert_response_has_tag 'h1', content: 'prefix'
107
+ assert_response_has_tag 'h3', content: 'postfix'
108
108
  assert_response_has_tag '.erb-block'
109
- assert_response_has_tag 'div', :content => 'go block!'
109
+ assert_response_has_tag 'div', content: 'go block!'
110
110
  end
111
111
  it 'should render haml with block' do
112
- get "/render_block_haml"
113
- assert_response_has_tag 'h1', :content => 'prefix'
114
- assert_response_has_tag 'h3', :content => 'postfix'
112
+ get '/render_block_haml'
113
+ assert_response_has_tag 'h1', content: 'prefix'
114
+ assert_response_has_tag 'h3', content: 'postfix'
115
115
  assert_response_has_tag '.haml-block'
116
- assert_response_has_tag 'div', :content => 'go block!'
116
+ assert_response_has_tag 'div', content: 'go block!'
117
117
  end
118
118
  end
119
119
 
120
120
  describe 'partial with block' do
121
121
  it 'should show partial slim with block' do
122
- get "/partial_block_slim"
123
- assert_response_has_tag 'h1', :content => 'prefix'
124
- assert_response_has_tag 'h3', :content => 'postfix'
122
+ get '/partial_block_slim'
123
+ assert_response_has_tag 'h1', content: 'prefix'
124
+ assert_response_has_tag 'h3', content: 'postfix'
125
125
  assert_response_has_tag '.slim-block'
126
- assert_response_has_tag 'div', :content => 'go block!'
127
- assert_response_has_tag 'div.deep', :content => 'Done'
126
+ assert_response_has_tag 'div', content: 'go block!'
127
+ assert_response_has_tag 'div.deep', content: 'Done'
128
128
  end
129
129
  it 'should show partial erb with block' do
130
- get "/partial_block_erb"
131
- assert_response_has_tag 'h1', :content => 'prefix'
132
- assert_response_has_tag 'h3', :content => 'postfix'
130
+ get '/partial_block_erb'
131
+ assert_response_has_tag 'h1', content: 'prefix'
132
+ assert_response_has_tag 'h3', content: 'postfix'
133
133
  assert_response_has_tag '.erb-block'
134
- assert_response_has_tag 'div', :content => 'go block!'
135
- assert_response_has_tag 'div.deep', :content => 'Done'
134
+ assert_response_has_tag 'div', content: 'go block!'
135
+ assert_response_has_tag 'div.deep', content: 'Done'
136
136
  end
137
137
  it 'should show partial haml with block' do
138
- get "/partial_block_haml"
139
- assert_response_has_tag 'h1', :content => 'prefix'
140
- assert_response_has_tag 'h3', :content => 'postfix'
138
+ get '/partial_block_haml'
139
+ assert_response_has_tag 'h1', content: 'prefix'
140
+ assert_response_has_tag 'h3', content: 'postfix'
141
141
  assert_response_has_tag '.haml-block'
142
- assert_response_has_tag 'div', :content => 'go block!'
143
- assert_response_has_tag 'div.deep', :content => 'Done'
142
+ assert_response_has_tag 'div', content: 'go block!'
143
+ assert_response_has_tag 'div.deep', content: 'Done'
144
144
  end
145
145
  end
146
146
 
147
147
  describe 'for #current_engine method' do
148
148
  it 'should detect correctly current engine for a padrino application' do
149
- get "/current_engine"
150
- assert_response_has_tag 'p.start', :content => "haml"
151
- assert_response_has_tag 'p.haml span', :content => "haml"
152
- assert_response_has_tag 'p.erb span', :content => "erb"
153
- assert_response_has_tag 'p.slim span', :content => "slim"
154
- assert_response_has_tag 'p.end', :content => "haml"
149
+ get '/current_engine'
150
+ assert_response_has_tag 'p.start', content: 'haml'
151
+ assert_response_has_tag 'p.haml span', content: 'haml'
152
+ assert_response_has_tag 'p.erb span', content: 'erb'
153
+ assert_response_has_tag 'p.slim span', content: 'slim'
154
+ assert_response_has_tag 'p.end', content: 'haml'
155
155
  end
156
156
 
157
157
  it 'should detect correctly current engine for explicit engine on partials' do
158
- get "/explicit_engine"
159
- assert_response_has_tag 'p.start', :content => "haml"
160
- assert_response_has_tag 'p.haml span', :content => "haml"
161
- assert_response_has_tag 'p.erb span', :content => "erb"
162
- assert_response_has_tag 'p.slim span', :content => "slim"
163
- assert_response_has_tag 'p.end', :content => "haml"
158
+ get '/explicit_engine'
159
+ assert_response_has_tag 'p.start', content: 'haml'
160
+ assert_response_has_tag 'p.haml span', content: 'haml'
161
+ assert_response_has_tag 'p.erb span', content: 'erb'
162
+ assert_response_has_tag 'p.slim span', content: 'slim'
163
+ assert_response_has_tag 'p.end', content: 'haml'
164
164
  end
165
165
 
166
166
  it 'should capture slim template once and only once' do
167
167
  $number_of_captures = 0
168
- get "/double_capture_slim"
169
- assert_equal 1,$number_of_captures
168
+ get '/double_capture_slim'
169
+ assert_equal 1, $number_of_captures
170
170
  end
171
171
 
172
172
  it 'should capture haml template once and only once' do
173
173
  $number_of_captures = 0
174
- get "/double_capture_haml"
175
- assert_equal 1,$number_of_captures
174
+ get '/double_capture_haml'
175
+ assert_equal 1, $number_of_captures
176
176
  end
177
177
 
178
178
  it 'should capture erb template once and only once' do
179
179
  $number_of_captures = 0
180
- get "/double_capture_erb"
181
- assert_equal 1,$number_of_captures
180
+ get '/double_capture_erb'
181
+ assert_equal 1, $number_of_captures
182
182
  end
183
183
 
184
184
  it 'should fail on wrong erb usage' do
185
185
  assert_raises(SyntaxError) do
186
- get "/wrong_capture_erb"
186
+ get '/wrong_capture_erb'
187
187
  end
188
188
  end
189
189
 
190
190
  it 'should ignore wrong haml usage' do
191
- get "/wrong_capture_haml"
192
- assert_response_has_no_tag 'p', :content => 'this is wrong'
191
+ get '/wrong_capture_haml'
192
+ assert_response_has_no_tag 'p', content: 'this is wrong'
193
193
  end
194
194
 
195
195
  it 'should ignore wrong slim usage' do
196
- get "/wrong_capture_slim"
197
- assert_response_has_no_tag 'p', :content => 'this is wrong'
196
+ get '/wrong_capture_slim'
197
+ assert_response_has_no_tag 'p', content: 'this is wrong'
198
198
  end
199
199
 
200
200
  it 'should support weird ruby blocks in erb' do
201
- get "/ruby_block_capture_erb"
202
- assert_response_has_tag 'b', :content => 'c'
201
+ get '/ruby_block_capture_erb'
202
+ assert_response_has_tag 'b', content: 'c'
203
203
  end
204
204
 
205
205
  it 'should support weird ruby blocks in haml' do
206
- get "/ruby_block_capture_haml"
207
- assert_response_has_tag 'b', :content => 'c'
206
+ get '/ruby_block_capture_haml'
207
+ assert_response_has_tag 'b', content: 'c'
208
208
  end
209
-
209
+
210
210
  it 'should support weird ruby blocks in slim' do
211
- get "/ruby_block_capture_slim"
212
- assert_response_has_tag 'b', :content => 'c'
211
+ get '/ruby_block_capture_slim'
212
+ assert_response_has_tag 'b', content: 'c'
213
213
  end
214
214
  end
215
215
 
@@ -218,8 +218,8 @@ describe "RenderHelpers" do
218
218
  class Standalone
219
219
  include Padrino::Helpers::RenderHelpers
220
220
  end
221
- locals = { :user => OpenStruct.new(:name => 'Joe') }
222
- result = Standalone.new.partial(File.join(File.dirname(__FILE__), 'fixtures/render_app/views/template/user'), :engine => :haml, :locals => locals)
221
+ locals = { user: OpenStruct.new(name: 'Joe') }
222
+ result = Standalone.new.partial(File.join(__dir__, 'fixtures/render_app/views/template/user'), engine: :haml, locals: locals)
223
223
  assert_equal '<h1>User name is Joe</h1>', result.chomp
224
224
  end
225
225
 
@@ -227,11 +227,11 @@ describe "RenderHelpers" do
227
227
  class Standalone1
228
228
  include Padrino::Helpers::RenderHelpers
229
229
  def user
230
- OpenStruct.new(:name => 'Jane')
230
+ OpenStruct.new(name: 'Jane')
231
231
  end
232
232
  end
233
233
 
234
- result = Standalone1.new.partial(File.join(File.dirname(__FILE__), 'fixtures/render_app/views/template/user.haml'))
234
+ result = Standalone1.new.partial(File.join(__dir__, 'fixtures/render_app/views/template/user.haml'))
235
235
  assert_equal '<h1>User name is Jane</h1>', result.chomp
236
236
  end
237
237
 
@@ -240,7 +240,7 @@ describe "RenderHelpers" do
240
240
  include Padrino::Helpers::RenderHelpers
241
241
  end
242
242
  assert_raises RuntimeError do
243
- result = Standalone2.new.partial('none')
243
+ Standalone2.new.partial('none')
244
244
  end
245
245
  end
246
246
 
@@ -268,7 +268,7 @@ describe "RenderHelpers" do
268
268
  describe 'partial in an application with layout' do
269
269
  it 'should not render with default layout' do
270
270
  get '/'
271
- assert_response_has_tag 'body', :count => 1
271
+ assert_response_has_tag 'body', count: 1
272
272
  end
273
273
  end
274
274
  end