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,7 +1,7 @@
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 "FormHelpers" do
4
+ describe 'FormHelpers' do
5
5
  include Padrino::Helpers::FormHelpers
6
6
 
7
7
  def app
@@ -14,946 +14,946 @@ describe "FormHelpers" do
14
14
 
15
15
  describe 'for #form_tag method' do
16
16
  it 'should display correct forms in ruby' do
17
- actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test', :method => "post") { "Demo" }
18
- assert_html_has_tag(actual_html, :form, :"accept-charset" => "UTF-8", :class => "test")
19
- assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => '_method', :count => 0)
17
+ actual_html = form_tag('/register', "accept-charset": 'UTF-8', class: 'test', method: 'post') { 'Demo' }
18
+ assert_html_has_tag(actual_html, :form, "accept-charset": 'UTF-8', class: 'test')
19
+ assert_html_has_tag(actual_html, 'form input', type: 'hidden', name: '_method', count: 0)
20
20
  end
21
21
 
22
22
  it 'should display correct text inputs within form_tag' do
23
- actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test') { text_field_tag(:username) }
24
- assert_html_has_tag(actual_html, 'form input', :type => 'text', :name => "username")
25
- assert_html_has_no_tag(actual_html, 'form input', :type => 'hidden', :name => "_method")
23
+ actual_html = form_tag('/register', "accept-charset": 'UTF-8', class: 'test') { text_field_tag(:username) }
24
+ assert_html_has_tag(actual_html, 'form input', type: 'text', name: 'username')
25
+ assert_html_has_no_tag(actual_html, 'form input', type: 'hidden', name: '_method')
26
26
  end
27
27
 
28
28
  it 'should display correct form with remote' do
29
- actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :class => 'put-form', :remote => true) { "Demo" }
30
- assert_html_has_tag(actual_html, :form, :class => "put-form", :"accept-charset" => "UTF-8", :"data-remote" => 'true')
31
- assert_html_has_no_tag(actual_html, :form, "data-method" => 'post')
29
+ actual_html = form_tag('/update', "accept-charset": 'UTF-8', class: 'put-form', remote: true) { 'Demo' }
30
+ assert_html_has_tag(actual_html, :form, class: 'put-form', "accept-charset": 'UTF-8', "data-remote": 'true')
31
+ assert_html_has_no_tag(actual_html, :form, 'data-method' => 'post')
32
32
  end
33
33
 
34
34
  it 'should display correct form with remote and method is put' do
35
- actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :method => 'put', :remote => true) { "Demo" }
36
- assert_html_has_tag(actual_html, :form, "data-remote" => 'true', :"accept-charset" => "UTF-8")
37
- assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'put')
35
+ actual_html = form_tag('/update', 'accept-charset' => 'UTF-8', method: 'put', remote: true) { 'Demo' }
36
+ assert_html_has_tag(actual_html, :form, 'data-remote' => 'true', 'accept-charset' => 'UTF-8')
37
+ assert_html_has_tag(actual_html, 'form input', type: 'hidden', name: '_method', value: 'put')
38
38
  end
39
39
 
40
40
  it 'should display correct form with method :put' do
41
- actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :class => 'put-form', :method => "put") { "Demo" }
42
- assert_html_has_tag(actual_html, :form, :class => "put-form", :"accept-charset" => "UTF-8", :method => 'post')
43
- assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'put')
41
+ actual_html = form_tag('/update', 'accept-charset' => 'UTF-8', class: 'put-form', method: 'put') { 'Demo' }
42
+ assert_html_has_tag(actual_html, :form, class: 'put-form', 'accept-charset' => 'UTF-8', method: 'post')
43
+ assert_html_has_tag(actual_html, 'form input', type: 'hidden', name: '_method', value: 'put')
44
44
  end
45
45
 
46
46
  it 'should display correct form with method :delete and charset' do
47
- actual_html = form_tag('/remove', :"accept-charset" => "UTF-8", :class => 'delete-form', :method => "delete") { "Demo" }
48
- assert_html_has_tag(actual_html, :form, :class => "delete-form", :"accept-charset" => "UTF-8", :method => 'post')
49
- assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'delete')
47
+ actual_html = form_tag('/remove', 'accept-charset' => 'UTF-8', class: 'delete-form', method: 'delete') { 'Demo' }
48
+ assert_html_has_tag(actual_html, :form, class: 'delete-form', 'accept-charset' => 'UTF-8', method: 'post')
49
+ assert_html_has_tag(actual_html, 'form input', type: 'hidden', name: '_method', value: 'delete')
50
50
  end
51
51
 
52
52
  it 'should display correct form with charset' do
53
- actual_html = form_tag('/charset', :"accept-charset" => "UTF-8", :class => 'charset-form') { "Demo" }
54
- assert_html_has_tag(actual_html, :form, :class => "charset-form", :"accept-charset" => "UTF-8", :method => 'post')
53
+ actual_html = form_tag('/charset', 'accept-charset' => 'UTF-8', class: 'charset-form') { 'Demo' }
54
+ assert_html_has_tag(actual_html, :form, class: 'charset-form', 'accept-charset' => 'UTF-8', method: 'post')
55
55
  end
56
56
 
57
57
  it 'should display correct form with multipart encoding' do
58
- actual_html = form_tag('/remove', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
59
- assert_html_has_tag(actual_html, :form, :enctype => "multipart/form-data")
58
+ actual_html = form_tag('/remove', 'accept-charset' => 'UTF-8', multipart: true) { 'Demo' }
59
+ assert_html_has_tag(actual_html, :form, enctype: 'multipart/form-data')
60
60
  end
61
61
 
62
62
  it 'should have an authenticity_token for method :post, :put or :delete' do
63
- %w(post put delete).each do |method|
64
- actual_html = form_tag('/modify', :method => method) { "Demo" }
65
- assert_html_has_tag(actual_html, :input, :name => 'authenticity_token')
63
+ %w[post put delete].each do |method|
64
+ actual_html = form_tag('/modify', method: method) { 'Demo' }
65
+ assert_html_has_tag(actual_html, :input, name: 'authenticity_token')
66
66
  end
67
67
  end
68
68
 
69
69
  it 'should not have an authenticity_token if method: :get' do
70
- actual_html = form_tag('/get', :method => :get) { "Demo" }
71
- assert_html_has_no_tag(actual_html, :input, :name => 'authenticity_token')
70
+ actual_html = form_tag('/get', method: :get) { 'Demo' }
71
+ assert_html_has_no_tag(actual_html, :input, name: 'authenticity_token')
72
72
  end
73
73
 
74
74
  it 'should have an authenticity_token by default' do
75
- actual_html = form_tag('/superadmindelete') { "Demo" }
76
- assert_html_has_tag(actual_html, :input, :name => 'authenticity_token')
75
+ actual_html = form_tag('/superadmindelete') { 'Demo' }
76
+ assert_html_has_tag(actual_html, :input, name: 'authenticity_token')
77
77
  end
78
78
 
79
79
  it 'should create csrf meta tags with token and param - #csrf_meta_tags' do
80
80
  actual_html = csrf_meta_tags
81
- assert_html_has_tag(actual_html, :meta, :name => 'csrf-param')
82
- assert_html_has_tag(actual_html, :meta, :name => 'csrf-token')
81
+ assert_html_has_tag(actual_html, :meta, name: 'csrf-param')
82
+ assert_html_has_tag(actual_html, :meta, name: 'csrf-token')
83
83
  end
84
84
 
85
85
  it 'should have an authenticity_token by default' do
86
- actual_html = form_tag('/superadmindelete') { "Demo" }
87
- assert_html_has_tag(actual_html, :input, :name => 'authenticity_token')
86
+ actual_html = form_tag('/superadmindelete') { 'Demo' }
87
+ assert_html_has_tag(actual_html, :input, name: 'authenticity_token')
88
88
  end
89
89
 
90
90
  it 'should not have an authenticity_token if passing protect_from_csrf: false' do
91
- actual_html = form_tag('/superadmindelete', :protect_from_csrf => false) { "Demo" }
92
- assert_html_has_no_tag(actual_html, :input, :name => 'authenticity_token')
91
+ actual_html = form_tag('/superadmindelete', protect_from_csrf: false) { 'Demo' }
92
+ assert_html_has_no_tag(actual_html, :input, name: 'authenticity_token')
93
93
  end
94
94
 
95
95
  it 'should not have an authenticity_token if protect_from_csrf is false on app settings' do
96
96
  self.expects(:settings).returns(UnprotectedApp.new)
97
- actual_html = form_tag('/superadmindelete') { "Demo" }
98
- assert_html_has_no_tag(actual_html, :input, :name => 'authenticity_token')
97
+ actual_html = form_tag('/superadmindelete') { 'Demo' }
98
+ assert_html_has_no_tag(actual_html, :input, name: 'authenticity_token')
99
99
  end
100
100
 
101
101
  it 'should not include protect_from_csrf as an attribute of form element' do
102
- actual_html = form_tag('/superadmindelete', :protect_from_csrf => true){ "Demo" }
103
- assert_html_has_no_tag(actual_html, :form, protect_from_csrf: "true")
102
+ actual_html = form_tag('/superadmindelete', protect_from_csrf: true) { 'Demo' }
103
+ assert_html_has_no_tag(actual_html, :form, protect_from_csrf: 'true')
104
104
  end
105
105
 
106
106
  it 'should display correct forms in erb' do
107
- get "/erb/form_tag"
108
- assert_response_has_tag 'form.simple-form', :action => '/simple'
109
- assert_response_has_tag 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
110
- assert_response_has_tag 'form.simple-form input', :name => 'authenticity_token'
111
- assert_response_has_no_tag 'form.no-protection input', :name => 'authenticity_token'
107
+ get '/erb/form_tag'
108
+ assert_response_has_tag 'form.simple-form', action: '/simple'
109
+ assert_response_has_tag 'form.advanced-form', action: '/advanced', id: 'advanced', method: 'get'
110
+ assert_response_has_tag 'form.simple-form input', name: 'authenticity_token'
111
+ assert_response_has_no_tag 'form.no-protection input', name: 'authenticity_token'
112
112
  end
113
113
 
114
114
  it 'should display correct forms in haml' do
115
- get "/haml/form_tag"
116
- assert_response_has_tag 'form.simple-form', :action => '/simple'
117
- assert_response_has_tag 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
118
- assert_response_has_tag 'form.simple-form input', :name => 'authenticity_token'
119
- assert_response_has_no_tag 'form.no-protection input', :name => 'authenticity_token'
115
+ get '/haml/form_tag'
116
+ assert_response_has_tag 'form.simple-form', action: '/simple'
117
+ assert_response_has_tag 'form.advanced-form', action: '/advanced', id: 'advanced', method: 'get'
118
+ assert_response_has_tag 'form.simple-form input', name: 'authenticity_token'
119
+ assert_response_has_no_tag 'form.no-protection input', name: 'authenticity_token'
120
120
  end
121
121
 
122
122
  it 'should display correct forms in slim' do
123
- get "/slim/form_tag"
124
- assert_response_has_tag 'form.simple-form', :action => '/simple'
125
- assert_response_has_tag 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
126
- assert_response_has_tag 'form.simple-form input', :name => 'authenticity_token'
127
- assert_response_has_no_tag 'form.no-protection input', :name => 'authenticity_token'
123
+ get '/slim/form_tag'
124
+ assert_response_has_tag 'form.simple-form', action: '/simple'
125
+ assert_response_has_tag 'form.advanced-form', action: '/advanced', id: 'advanced', method: 'get'
126
+ assert_response_has_tag 'form.simple-form input', name: 'authenticity_token'
127
+ assert_response_has_no_tag 'form.no-protection input', name: 'authenticity_token'
128
128
  end
129
129
  end
130
130
 
131
131
  describe 'for #field_set_tag method' do
132
132
  it 'should display correct field_sets in ruby' do
133
- actual_html = field_set_tag("Basic", :class => 'basic') { "Demo" }
134
- assert_html_has_tag(actual_html, :fieldset, :class => 'basic')
135
- assert_html_has_tag(actual_html, 'fieldset legend', :content => "Basic")
133
+ actual_html = field_set_tag('Basic', class: 'basic') { 'Demo' }
134
+ assert_html_has_tag(actual_html, :fieldset, class: 'basic')
135
+ assert_html_has_tag(actual_html, 'fieldset legend', content: 'Basic')
136
136
  end
137
137
 
138
138
  it 'should display correct field_sets in erb' do
139
- get "/erb/form_tag"
140
- assert_response_has_tag 'form.simple-form fieldset', :count => 1
139
+ get '/erb/form_tag'
140
+ assert_response_has_tag 'form.simple-form fieldset', count: 1
141
141
  assert_response_has_no_tag 'form.simple-form fieldset legend'
142
- assert_response_has_tag 'form.advanced-form fieldset', :count => 1, :class => 'advanced-field-set'
143
- assert_response_has_tag 'form.advanced-form fieldset legend', :content => "Advanced"
142
+ assert_response_has_tag 'form.advanced-form fieldset', count: 1, class: 'advanced-field-set'
143
+ assert_response_has_tag 'form.advanced-form fieldset legend', content: 'Advanced'
144
144
  end
145
145
 
146
146
  it 'should display correct field_sets in haml' do
147
- get "/haml/form_tag"
148
- assert_response_has_tag 'form.simple-form fieldset', :count => 1
147
+ get '/haml/form_tag'
148
+ assert_response_has_tag 'form.simple-form fieldset', count: 1
149
149
  assert_response_has_no_tag 'form.simple-form fieldset legend'
150
- assert_response_has_tag 'form.advanced-form fieldset', :count => 1, :class => 'advanced-field-set'
151
- assert_response_has_tag 'form.advanced-form fieldset legend', :content => "Advanced"
150
+ assert_response_has_tag 'form.advanced-form fieldset', count: 1, class: 'advanced-field-set'
151
+ assert_response_has_tag 'form.advanced-form fieldset legend', content: 'Advanced'
152
152
  end
153
153
 
154
154
  it 'should display correct field_sets in slim' do
155
- get "/slim/form_tag"
156
- assert_response_has_tag 'form.simple-form fieldset', :count => 1
155
+ get '/slim/form_tag'
156
+ assert_response_has_tag 'form.simple-form fieldset', count: 1
157
157
  assert_response_has_no_tag 'form.simple-form fieldset legend'
158
- assert_response_has_tag 'form.advanced-form fieldset', :count => 1, :class => 'advanced-field-set'
159
- assert_response_has_tag 'form.advanced-form fieldset legend', :content => "Advanced"
158
+ assert_response_has_tag 'form.advanced-form fieldset', count: 1, class: 'advanced-field-set'
159
+ assert_response_has_tag 'form.advanced-form fieldset legend', content: 'Advanced'
160
160
  end
161
161
  end
162
162
 
163
163
  describe 'for #error_messages_for method' do
164
164
  it 'should display correct error messages list in ruby' do
165
- user = mock_model("User", :errors => { :a => "1", :b => "2" })
165
+ user = mock_model('User', errors: { a: '1', b: '2' })
166
166
  actual_html = error_messages_for(user)
167
167
  assert_html_has_tag(actual_html, 'div.field-errors')
168
- assert_html_has_tag(actual_html, 'div.field-errors h2', :content => "2 errors prohibited this User from being saved")
169
- assert_html_has_tag(actual_html, 'div.field-errors p', :content => "There were problems with the following fields:")
168
+ assert_html_has_tag(actual_html, 'div.field-errors h2', content: '2 errors prohibited this User from being saved')
169
+ assert_html_has_tag(actual_html, 'div.field-errors p', content: 'There were problems with the following fields:')
170
170
  assert_html_has_tag(actual_html, 'div.field-errors ul')
171
- assert_html_has_tag(actual_html, 'div.field-errors ul li', :count => 2)
171
+ assert_html_has_tag(actual_html, 'div.field-errors ul li', count: 2)
172
172
  end
173
173
 
174
174
  it 'should display correct error messages list in erb' do
175
- get "/erb/form_tag"
175
+ get '/erb/form_tag'
176
176
  assert_response_has_no_tag 'form.simple-form .field-errors'
177
177
  assert_response_has_tag 'form.advanced-form .field-errors'
178
- assert_response_has_tag 'form.advanced-form .field-errors h2', :content => "There are problems with saving user!"
179
- assert_response_has_tag 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
178
+ assert_response_has_tag 'form.advanced-form .field-errors h2', content: 'There are problems with saving user!'
179
+ assert_response_has_tag 'form.advanced-form .field-errors p', content: 'There were problems with the following fields:'
180
180
  assert_response_has_tag 'form.advanced-form .field-errors ul'
181
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :count => 4
182
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Email must be an email"
183
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
184
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Second must be present"
185
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
181
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', count: 4
182
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Email must be an email'
183
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Fake must be valid'
184
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Second must be present'
185
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Third must be a number'
186
186
  end
187
187
 
188
188
  it 'should display correct error messages list in haml' do
189
- get "/haml/form_tag"
189
+ get '/haml/form_tag'
190
190
  assert_response_has_no_tag 'form.simple-form .field-errors'
191
191
  assert_response_has_tag 'form.advanced-form .field-errors'
192
- assert_response_has_tag 'form.advanced-form .field-errors h2', :content => "There are problems with saving user!"
193
- assert_response_has_tag 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
192
+ assert_response_has_tag 'form.advanced-form .field-errors h2', content: 'There are problems with saving user!'
193
+ assert_response_has_tag 'form.advanced-form .field-errors p', content: 'There were problems with the following fields:'
194
194
  assert_response_has_tag 'form.advanced-form .field-errors ul'
195
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :count => 4
196
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Email must be an email"
197
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
198
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Second must be present"
199
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
195
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', count: 4
196
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Email must be an email'
197
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Fake must be valid'
198
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Second must be present'
199
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Third must be a number'
200
200
  end
201
201
 
202
202
  it 'should display correct error messages list in slim' do
203
- get "/slim/form_tag"
203
+ get '/slim/form_tag'
204
204
  assert_response_has_no_tag 'form.simple-form .field-errors'
205
205
  assert_response_has_tag 'form.advanced-form .field-errors'
206
- assert_response_has_tag 'form.advanced-form .field-errors h2', :content => "There are problems with saving user!"
207
- assert_response_has_tag 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
206
+ assert_response_has_tag 'form.advanced-form .field-errors h2', content: 'There are problems with saving user!'
207
+ assert_response_has_tag 'form.advanced-form .field-errors p', content: 'There were problems with the following fields:'
208
208
  assert_response_has_tag 'form.advanced-form .field-errors ul'
209
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :count => 4
210
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Email must be an email"
211
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
212
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Second must be present"
213
- assert_response_has_tag 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
209
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', count: 4
210
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Email must be an email'
211
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Fake must be valid'
212
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Second must be present'
213
+ assert_response_has_tag 'form.advanced-form .field-errors ul li', content: 'Third must be a number'
214
214
  end
215
215
  end
216
216
 
217
217
  describe 'for #error_message_on method' do
218
218
  it 'should display correct error message on specified model name in ruby' do
219
- @user = mock_model("User", :errors => { :a => "1", :b => "2" })
220
- actual_html = error_message_on(:user, :a, :prepend => "foo", :append => "bar")
221
- assert_html_has_tag(actual_html, 'span.error', :content => "foo 1 bar")
219
+ @user = mock_model('User', errors: { a: '1', b: '2' })
220
+ actual_html = error_message_on(:user, :a, prepend: 'foo', append: 'bar')
221
+ assert_html_has_tag(actual_html, 'span.error', content: 'foo 1 bar')
222
222
  end
223
223
 
224
224
  it 'should display correct error message on specified object in ruby' do
225
- @bob = mock_model("User", :errors => { :a => "1", :b => "2" })
226
- actual_html = error_message_on(@bob, :a, :prepend => "foo", :append => "bar")
227
- assert_html_has_tag(actual_html, 'span.error', :content => "foo 1 bar")
225
+ @bob = mock_model('User', errors: { a: '1', b: '2' })
226
+ actual_html = error_message_on(@bob, :a, prepend: 'foo', append: 'bar')
227
+ assert_html_has_tag(actual_html, 'span.error', content: 'foo 1 bar')
228
228
  end
229
229
 
230
230
  it 'should display no message when error is not present' do
231
- @user = mock_model("User", :errors => { :a => "1", :b => "2" })
232
- actual_html = error_message_on(:user, :fake, :prepend => "foo", :append => "bar")
231
+ @user = mock_model('User', errors: { a: '1', b: '2' })
232
+ actual_html = error_message_on(:user, :fake, prepend: 'foo', append: 'bar')
233
233
  assert_empty actual_html
234
234
  end
235
235
 
236
236
  it 'should display no message when error is not present in an Array' do
237
- @user = mock_model("User", :errors => { :a => [], :b => "2" })
238
- actual_html = error_message_on(:user, :a, :prepend => "foo", :append => "bar")
237
+ @user = mock_model('User', errors: { a: [], b: '2' })
238
+ actual_html = error_message_on(:user, :a, prepend: 'foo', append: 'bar')
239
239
  assert_empty actual_html
240
240
  end
241
241
  end
242
242
 
243
243
  describe 'for #label_tag method' do
244
244
  it 'should display label tag in ruby' do
245
- actual_html = label_tag(:username, :class => 'long-label', :caption => "Nickname")
246
- assert_html_has_tag(actual_html, :label, :for => 'username', :class => 'long-label', :content => "Nickname")
245
+ actual_html = label_tag(:username, class: 'long-label', caption: 'Nickname')
246
+ assert_html_has_tag(actual_html, :label, for: 'username', class: 'long-label', content: 'Nickname')
247
247
  end
248
248
 
249
249
  it 'should display label tag in ruby with required' do
250
- actual_html = label_tag(:username, :caption => "Nickname", :required => true)
251
- assert_html_has_tag(actual_html, :label, :for => 'username', :content => 'Nickname')
252
- assert_html_has_tag(actual_html, 'label[for=username] span.required', :content => "*")
250
+ actual_html = label_tag(:username, caption: 'Nickname', required: true)
251
+ assert_html_has_tag(actual_html, :label, for: 'username', content: 'Nickname')
252
+ assert_html_has_tag(actual_html, 'label[for=username] span.required', content: '*')
253
253
  end
254
254
 
255
255
  it 'should display label tag in ruby with a block' do
256
- actual_html = label_tag(:admin, :class => 'long-label') { input_tag :checkbox }
257
- assert_html_has_tag(actual_html, :label, :for => 'admin', :class => 'long-label', :content => "Admin")
256
+ actual_html = label_tag(:admin, class: 'long-label') { input_tag :checkbox }
257
+ assert_html_has_tag(actual_html, :label, for: 'admin', class: 'long-label', content: 'Admin')
258
258
  assert_html_has_tag(actual_html, 'label input[type=checkbox]')
259
259
  end
260
260
 
261
261
  it 'should display label tag in erb for simple form' do
262
- get "/erb/form_tag"
263
- assert_response_has_tag 'form.simple-form label', :count => 9
264
- assert_response_has_tag 'form.simple-form label', :content => "Username", :for => 'username'
265
- assert_response_has_tag 'form.simple-form label', :content => "Password", :for => 'password'
266
- assert_response_has_tag 'form.simple-form label', :content => "Gender", :for => 'gender'
262
+ get '/erb/form_tag'
263
+ assert_response_has_tag 'form.simple-form label', count: 9
264
+ assert_response_has_tag 'form.simple-form label', content: 'Username', for: 'username'
265
+ assert_response_has_tag 'form.simple-form label', content: 'Password', for: 'password'
266
+ assert_response_has_tag 'form.simple-form label', content: 'Gender', for: 'gender'
267
267
  end
268
268
 
269
269
  it 'should display label tag in erb for advanced form' do
270
- get "/erb/form_tag"
271
- assert_response_has_tag 'form.advanced-form label', :count => 11
272
- assert_response_has_tag 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
273
- assert_response_has_tag 'form.advanced-form label.first', :content => "Password", :for => 'password'
274
- assert_response_has_tag 'form.advanced-form label.about', :content => "About Me", :for => 'about'
275
- assert_response_has_tag 'form.advanced-form label.photo', :content => "Photo" , :for => 'photo'
276
- assert_response_has_tag 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
270
+ get '/erb/form_tag'
271
+ assert_response_has_tag 'form.advanced-form label', count: 11
272
+ assert_response_has_tag 'form.advanced-form label.first', content: 'Nickname', for: 'username'
273
+ assert_response_has_tag 'form.advanced-form label.first', content: 'Password', for: 'password'
274
+ assert_response_has_tag 'form.advanced-form label.about', content: 'About Me', for: 'about'
275
+ assert_response_has_tag 'form.advanced-form label.photo', content: 'Photo', for: 'photo'
276
+ assert_response_has_tag 'form.advanced-form label.gender', content: 'Gender', for: 'gender'
277
277
  end
278
278
 
279
279
  it 'should display label tag in haml for simple form' do
280
- get "/haml/form_tag"
281
- assert_response_has_tag 'form.simple-form label', :count => 9
282
- assert_response_has_tag 'form.simple-form label', :content => "Username", :for => 'username'
283
- assert_response_has_tag 'form.simple-form label', :content => "Password", :for => 'password'
284
- assert_response_has_tag 'form.simple-form label', :content => "Gender", :for => 'gender'
280
+ get '/haml/form_tag'
281
+ assert_response_has_tag 'form.simple-form label', count: 9
282
+ assert_response_has_tag 'form.simple-form label', content: 'Username', for: 'username'
283
+ assert_response_has_tag 'form.simple-form label', content: 'Password', for: 'password'
284
+ assert_response_has_tag 'form.simple-form label', content: 'Gender', for: 'gender'
285
285
  end
286
286
 
287
287
  it 'should display label tag in haml for advanced form' do
288
- get "/haml/form_tag"
289
- assert_response_has_tag 'form.advanced-form label', :count => 11
290
- assert_response_has_tag 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
291
- assert_response_has_tag 'form.advanced-form label.first', :content => "Password", :for => 'password'
292
- assert_response_has_tag 'form.advanced-form label.about', :content => "About Me", :for => 'about'
293
- assert_response_has_tag 'form.advanced-form label.photo', :content => "Photo" , :for => 'photo'
294
- assert_response_has_tag 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
288
+ get '/haml/form_tag'
289
+ assert_response_has_tag 'form.advanced-form label', count: 11
290
+ assert_response_has_tag 'form.advanced-form label.first', content: 'Nickname', for: 'username'
291
+ assert_response_has_tag 'form.advanced-form label.first', content: 'Password', for: 'password'
292
+ assert_response_has_tag 'form.advanced-form label.about', content: 'About Me', for: 'about'
293
+ assert_response_has_tag 'form.advanced-form label.photo', content: 'Photo', for: 'photo'
294
+ assert_response_has_tag 'form.advanced-form label.gender', content: 'Gender', for: 'gender'
295
295
  end
296
296
 
297
297
  it 'should display label tag in slim for simple form' do
298
- get "/slim/form_tag"
299
- assert_response_has_tag 'form.simple-form label', :count => 9
300
- assert_response_has_tag 'form.simple-form label', :content => "Username", :for => 'username'
301
- assert_response_has_tag 'form.simple-form label', :content => "Password", :for => 'password'
302
- assert_response_has_tag 'form.simple-form label', :content => "Gender", :for => 'gender'
298
+ get '/slim/form_tag'
299
+ assert_response_has_tag 'form.simple-form label', count: 9
300
+ assert_response_has_tag 'form.simple-form label', content: 'Username', for: 'username'
301
+ assert_response_has_tag 'form.simple-form label', content: 'Password', for: 'password'
302
+ assert_response_has_tag 'form.simple-form label', content: 'Gender', for: 'gender'
303
303
  end
304
304
 
305
305
  it 'should display label tag in slim for advanced form' do
306
- get "/slim/form_tag"
307
- assert_response_has_tag 'form.advanced-form label', :count => 11
308
- assert_response_has_tag 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
309
- assert_response_has_tag 'form.advanced-form label.first', :content => "Password", :for => 'password'
310
- assert_response_has_tag 'form.advanced-form label.about', :content => "About Me", :for => 'about'
311
- assert_response_has_tag 'form.advanced-form label.photo', :content => "Photo" , :for => 'photo'
312
- assert_response_has_tag 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
306
+ get '/slim/form_tag'
307
+ assert_response_has_tag 'form.advanced-form label', count: 11
308
+ assert_response_has_tag 'form.advanced-form label.first', content: 'Nickname', for: 'username'
309
+ assert_response_has_tag 'form.advanced-form label.first', content: 'Password', for: 'password'
310
+ assert_response_has_tag 'form.advanced-form label.about', content: 'About Me', for: 'about'
311
+ assert_response_has_tag 'form.advanced-form label.photo', content: 'Photo', for: 'photo'
312
+ assert_response_has_tag 'form.advanced-form label.gender', content: 'Gender', for: 'gender'
313
313
  end
314
314
  end
315
315
 
316
316
  describe 'for #hidden_field_tag method' do
317
317
  it 'should display hidden field in ruby' do
318
- actual_html = hidden_field_tag(:session_key, :id => 'session_id', :value => '56768')
319
- assert_html_has_tag(actual_html, :input, :type => 'hidden', :id => "session_id", :name => 'session_key', :value => '56768')
318
+ actual_html = hidden_field_tag(:session_key, id: 'session_id', value: '56768')
319
+ assert_html_has_tag(actual_html, :input, type: 'hidden', id: 'session_id', name: 'session_key', value: '56768')
320
320
  end
321
321
 
322
322
  it 'should display hidden field in erb' do
323
- get "/erb/form_tag"
324
- assert_response_has_tag 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
325
- assert_response_has_tag 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
323
+ get '/erb/form_tag'
324
+ assert_response_has_tag 'form.simple-form input[type=hidden]', count: 1, name: 'session_id', value: '__secret__'
325
+ assert_response_has_tag 'form.advanced-form input[type=hidden]', count: 1, name: 'session_id', value: '__secret__'
326
326
  end
327
327
 
328
328
  it 'should display hidden field in haml' do
329
- get "/haml/form_tag"
330
- assert_response_has_tag 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
331
- assert_response_has_tag 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
329
+ get '/haml/form_tag'
330
+ assert_response_has_tag 'form.simple-form input[type=hidden]', count: 1, name: 'session_id', value: '__secret__'
331
+ assert_response_has_tag 'form.advanced-form input[type=hidden]', count: 1, name: 'session_id', value: '__secret__'
332
332
  end
333
333
 
334
334
  it 'should display hidden field in slim' do
335
- get "/slim/form_tag"
336
- assert_response_has_tag 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
337
- assert_response_has_tag 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
335
+ get '/slim/form_tag'
336
+ assert_response_has_tag 'form.simple-form input[type=hidden]', count: 1, name: 'session_id', value: '__secret__'
337
+ assert_response_has_tag 'form.advanced-form input[type=hidden]', count: 1, name: 'session_id', value: '__secret__'
338
338
  end
339
339
  end
340
340
 
341
341
  describe 'for #text_field_tag method' do
342
342
  it 'should display text field in ruby' do
343
- actual_html = text_field_tag(:username, :class => 'long')
344
- assert_html_has_tag(actual_html, :input, :type => 'text', :class => "long", :name => 'username')
343
+ actual_html = text_field_tag(:username, class: 'long')
344
+ assert_html_has_tag(actual_html, :input, type: 'text', class: 'long', name: 'username')
345
345
  end
346
346
 
347
347
  it 'should display text field in erb' do
348
- get "/erb/form_tag"
349
- assert_response_has_tag 'form.simple-form input[type=text]', :count => 1, :name => 'username'
350
- assert_response_has_tag 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
348
+ get '/erb/form_tag'
349
+ assert_response_has_tag 'form.simple-form input[type=text]', count: 1, name: 'username'
350
+ assert_response_has_tag 'form.advanced-form fieldset input[type=text]', count: 1, name: 'username', id: 'the_username'
351
351
  end
352
352
 
353
353
  it 'should display text field in haml' do
354
- get "/haml/form_tag"
355
- assert_response_has_tag 'form.simple-form input[type=text]', :count => 1, :name => 'username'
356
- assert_response_has_tag 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
354
+ get '/haml/form_tag'
355
+ assert_response_has_tag 'form.simple-form input[type=text]', count: 1, name: 'username'
356
+ assert_response_has_tag 'form.advanced-form fieldset input[type=text]', count: 1, name: 'username', id: 'the_username'
357
357
  end
358
358
 
359
359
  it 'should display text field in slim' do
360
- get "/slim/form_tag"
361
- assert_response_has_tag 'form.simple-form input[type=text]', :count => 1, :name => 'username'
362
- assert_response_has_tag 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
360
+ get '/slim/form_tag'
361
+ assert_response_has_tag 'form.simple-form input[type=text]', count: 1, name: 'username'
362
+ assert_response_has_tag 'form.advanced-form fieldset input[type=text]', count: 1, name: 'username', id: 'the_username'
363
363
  end
364
364
  end
365
365
 
366
366
  describe 'for #number_field_tag method' do
367
367
  it 'should display number field in ruby' do
368
- actual_html = number_field_tag(:age, :class => 'numeric')
369
- assert_html_has_tag(actual_html, :input, :type => 'number', :class => 'numeric', :name => 'age')
368
+ actual_html = number_field_tag(:age, class: 'numeric')
369
+ assert_html_has_tag(actual_html, :input, type: 'number', class: 'numeric', name: 'age')
370
370
  end
371
371
 
372
372
  it 'should display number field in erb' do
373
- get "/erb/form_tag"
374
- assert_response_has_tag 'form.simple-form input[type=number]', :count => 1, :name => 'age'
375
- assert_response_has_tag 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
373
+ get '/erb/form_tag'
374
+ assert_response_has_tag 'form.simple-form input[type=number]', count: 1, name: 'age'
375
+ assert_response_has_tag 'form.advanced-form fieldset input[type=number]', count: 1, name: 'age', class: 'numeric'
376
376
  end
377
377
 
378
378
  it 'should display number field in haml' do
379
- get "/haml/form_tag"
380
- assert_response_has_tag 'form.simple-form input[type=number]', :count => 1, :name => 'age'
381
- assert_response_has_tag 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
379
+ get '/haml/form_tag'
380
+ assert_response_has_tag 'form.simple-form input[type=number]', count: 1, name: 'age'
381
+ assert_response_has_tag 'form.advanced-form fieldset input[type=number]', count: 1, name: 'age', class: 'numeric'
382
382
  end
383
383
 
384
384
  it 'should display number field in slim' do
385
- get "/slim/form_tag"
386
- assert_response_has_tag 'form.simple-form input[type=number]', :count => 1, :name => 'age'
387
- assert_response_has_tag 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
385
+ get '/slim/form_tag'
386
+ assert_response_has_tag 'form.simple-form input[type=number]', count: 1, name: 'age'
387
+ assert_response_has_tag 'form.advanced-form fieldset input[type=number]', count: 1, name: 'age', class: 'numeric'
388
388
  end
389
389
  end
390
390
 
391
391
  describe 'for #telephone_field_tag method' do
392
392
  it 'should display number field in ruby' do
393
- actual_html = telephone_field_tag(:telephone, :class => 'numeric')
394
- assert_html_has_tag(actual_html, :input, :type => 'tel', :class => 'numeric', :name => 'telephone')
393
+ actual_html = telephone_field_tag(:telephone, class: 'numeric')
394
+ assert_html_has_tag(actual_html, :input, type: 'tel', class: 'numeric', name: 'telephone')
395
395
  end
396
396
 
397
397
  it 'should display telephone field in erb' do
398
- get "/erb/form_tag"
399
- assert_response_has_tag 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
400
- assert_response_has_tag 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
398
+ get '/erb/form_tag'
399
+ assert_response_has_tag 'form.simple-form input[type=tel]', count: 1, name: 'telephone'
400
+ assert_response_has_tag 'form.advanced-form fieldset input[type=tel]', count: 1, name: 'telephone', class: 'numeric'
401
401
  end
402
402
 
403
403
  it 'should display telephone field in haml' do
404
- get "/haml/form_tag"
405
- assert_response_has_tag 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
406
- assert_response_has_tag 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
404
+ get '/haml/form_tag'
405
+ assert_response_has_tag 'form.simple-form input[type=tel]', count: 1, name: 'telephone'
406
+ assert_response_has_tag 'form.advanced-form fieldset input[type=tel]', count: 1, name: 'telephone', class: 'numeric'
407
407
  end
408
408
 
409
409
  it 'should display telephone field in slim' do
410
- get "/slim/form_tag"
411
- assert_response_has_tag 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
412
- assert_response_has_tag 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
410
+ get '/slim/form_tag'
411
+ assert_response_has_tag 'form.simple-form input[type=tel]', count: 1, name: 'telephone'
412
+ assert_response_has_tag 'form.advanced-form fieldset input[type=tel]', count: 1, name: 'telephone', class: 'numeric'
413
413
  end
414
414
  end
415
415
 
416
416
  describe 'for #search_field_tag method' do
417
417
  it 'should display search field in ruby' do
418
- actual_html = search_field_tag(:search, :class => 'string')
419
- assert_html_has_tag(actual_html, :input, :type => 'search', :class => 'string', :name => 'search')
418
+ actual_html = search_field_tag(:search, class: 'string')
419
+ assert_html_has_tag(actual_html, :input, type: 'search', class: 'string', name: 'search')
420
420
  end
421
421
 
422
422
  it 'should display search field in erb' do
423
- get "/erb/form_tag"
424
- assert_response_has_tag 'form.simple-form input[type=search]', :count => 1, :name => 'search'
425
- assert_response_has_tag 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
423
+ get '/erb/form_tag'
424
+ assert_response_has_tag 'form.simple-form input[type=search]', count: 1, name: 'search'
425
+ assert_response_has_tag 'form.advanced-form fieldset input[type=search]', count: 1, name: 'search', class: 'string'
426
426
  end
427
427
 
428
428
  it 'should display search field in haml' do
429
- get "/haml/form_tag"
430
- assert_response_has_tag 'form.simple-form input[type=search]', :count => 1, :name => 'search'
431
- assert_response_has_tag 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
429
+ get '/haml/form_tag'
430
+ assert_response_has_tag 'form.simple-form input[type=search]', count: 1, name: 'search'
431
+ assert_response_has_tag 'form.advanced-form fieldset input[type=search]', count: 1, name: 'search', class: 'string'
432
432
  end
433
433
 
434
434
  it 'should display search field in slim' do
435
- get "/slim/form_tag"
436
- assert_response_has_tag 'form.simple-form input[type=search]', :count => 1, :name => 'search'
437
- assert_response_has_tag 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
435
+ get '/slim/form_tag'
436
+ assert_response_has_tag 'form.simple-form input[type=search]', count: 1, name: 'search'
437
+ assert_response_has_tag 'form.advanced-form fieldset input[type=search]', count: 1, name: 'search', class: 'string'
438
438
  end
439
439
  end
440
440
 
441
441
  describe 'for #email_field_tag method' do
442
442
  it 'should display email field in ruby' do
443
- actual_html = email_field_tag(:email, :class => 'string')
444
- assert_html_has_tag(actual_html, :input, :type => 'email', :class => 'string', :name => 'email')
443
+ actual_html = email_field_tag(:email, class: 'string')
444
+ assert_html_has_tag(actual_html, :input, type: 'email', class: 'string', name: 'email')
445
445
  end
446
446
 
447
447
  it 'should display email field in erb' do
448
- get "/erb/form_tag"
449
- assert_response_has_tag 'form.simple-form input[type=email]', :count => 1, :name => 'email'
450
- assert_response_has_tag 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
448
+ get '/erb/form_tag'
449
+ assert_response_has_tag 'form.simple-form input[type=email]', count: 1, name: 'email'
450
+ assert_response_has_tag 'form.advanced-form fieldset input[type=email]', count: 1, name: 'email', class: 'string'
451
451
  end
452
452
 
453
453
  it 'should display email field in haml' do
454
- get "/haml/form_tag"
455
- assert_response_has_tag 'form.simple-form input[type=email]', :count => 1, :name => 'email'
456
- assert_response_has_tag 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
454
+ get '/haml/form_tag'
455
+ assert_response_has_tag 'form.simple-form input[type=email]', count: 1, name: 'email'
456
+ assert_response_has_tag 'form.advanced-form fieldset input[type=email]', count: 1, name: 'email', class: 'string'
457
457
  end
458
458
 
459
459
  it 'should display email field in slim' do
460
- get "/slim/form_tag"
461
- assert_response_has_tag 'form.simple-form input[type=email]', :count => 1, :name => 'email'
462
- assert_response_has_tag 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
460
+ get '/slim/form_tag'
461
+ assert_response_has_tag 'form.simple-form input[type=email]', count: 1, name: 'email'
462
+ assert_response_has_tag 'form.advanced-form fieldset input[type=email]', count: 1, name: 'email', class: 'string'
463
463
  end
464
464
  end
465
465
 
466
466
  describe 'for #url_field_tag method' do
467
467
  it 'should display url field in ruby' do
468
- actual_html = url_field_tag(:webpage, :class => 'string')
469
- assert_html_has_tag(actual_html, :input, :type => 'url', :class => 'string', :name => 'webpage')
468
+ actual_html = url_field_tag(:webpage, class: 'string')
469
+ assert_html_has_tag(actual_html, :input, type: 'url', class: 'string', name: 'webpage')
470
470
  end
471
471
 
472
472
  it 'should display url field in erb' do
473
- get "/erb/form_tag"
474
- assert_response_has_tag 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
475
- assert_response_has_tag 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
473
+ get '/erb/form_tag'
474
+ assert_response_has_tag 'form.simple-form input[type=url]', count: 1, name: 'webpage'
475
+ assert_response_has_tag 'form.advanced-form fieldset input[type=url]', count: 1, name: 'webpage', class: 'string'
476
476
  end
477
477
 
478
478
  it 'should display url field in haml' do
479
- get "/haml/form_tag"
480
- assert_response_has_tag 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
481
- assert_response_has_tag 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
479
+ get '/haml/form_tag'
480
+ assert_response_has_tag 'form.simple-form input[type=url]', count: 1, name: 'webpage'
481
+ assert_response_has_tag 'form.advanced-form fieldset input[type=url]', count: 1, name: 'webpage', class: 'string'
482
482
  end
483
483
 
484
484
  it 'should display url field in slim' do
485
- get "/slim/form_tag"
486
- assert_response_has_tag 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
487
- assert_response_has_tag 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
485
+ get '/slim/form_tag'
486
+ assert_response_has_tag 'form.simple-form input[type=url]', count: 1, name: 'webpage'
487
+ assert_response_has_tag 'form.advanced-form fieldset input[type=url]', count: 1, name: 'webpage', class: 'string'
488
488
  end
489
489
  end
490
490
 
491
491
  describe 'for #text_area_tag method' do
492
492
  it 'should display text area in ruby' do
493
- actual_html = text_area_tag(:about, :class => 'long')
494
- assert_html_has_tag(actual_html, :textarea, :class => "long", :name => 'about')
493
+ actual_html = text_area_tag(:about, class: 'long')
494
+ assert_html_has_tag(actual_html, :textarea, class: 'long', name: 'about')
495
495
  end
496
496
 
497
497
  it 'should display text area in ruby with specified content' do
498
- actual_html = text_area_tag(:about, :value => "a test", :rows => 5, :cols => 6)
499
- assert_html_has_tag(actual_html, :textarea, :content => "a test", :name => 'about', :rows => "5", :cols => "6")
498
+ actual_html = text_area_tag(:about, value: 'a test', rows: 5, cols: 6)
499
+ assert_html_has_tag(actual_html, :textarea, content: 'a test', name: 'about', rows: '5', cols: '6')
500
500
  end
501
501
 
502
502
  it 'should insert newline to before of content' do
503
- actual_html = text_area_tag(:about, :value => "\na test&".html_safe)
504
- assert_html_has_tag(actual_html, :textarea, :content => "\na test&".html_safe, :name => 'about')
503
+ actual_html = text_area_tag(:about, value: "\na test&".html_safe)
504
+ assert_html_has_tag(actual_html, :textarea, content: "\na test&".html_safe, name: 'about')
505
505
  assert_match(%r{<textarea[^>]*>\n\na test&</textarea>}, actual_html)
506
506
  end
507
507
 
508
508
  it 'should display text area in erb' do
509
- get "/erb/form_tag"
510
- assert_response_has_tag 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
509
+ get '/erb/form_tag'
510
+ assert_response_has_tag 'form.advanced-form textarea', count: 1, name: 'about', class: 'large'
511
511
  end
512
512
 
513
513
  it 'should display text area in haml' do
514
- get "/haml/form_tag"
515
- assert_response_has_tag 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
514
+ get '/haml/form_tag'
515
+ assert_response_has_tag 'form.advanced-form textarea', count: 1, name: 'about', class: 'large'
516
516
  end
517
517
 
518
518
  it 'should display text area in slim' do
519
- get "/slim/form_tag"
520
- assert_response_has_tag 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
519
+ get '/slim/form_tag'
520
+ assert_response_has_tag 'form.advanced-form textarea', count: 1, name: 'about', class: 'large'
521
521
  end
522
522
  end
523
523
 
524
524
  describe 'for #password_field_tag method' do
525
525
  it 'should display password field in ruby' do
526
- actual_html = password_field_tag(:password, :class => 'long')
527
- assert_html_has_tag(actual_html, :input, :type => 'password', :class => "long", :name => 'password')
526
+ actual_html = password_field_tag(:password, class: 'long')
527
+ assert_html_has_tag(actual_html, :input, type: 'password', class: 'long', name: 'password')
528
528
  end
529
529
 
530
530
  it 'should display password field in erb' do
531
- get "/erb/form_tag"
532
- assert_response_has_tag 'form.simple-form input[type=password]', :count => 1, :name => 'password'
533
- assert_response_has_tag 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
531
+ get '/erb/form_tag'
532
+ assert_response_has_tag 'form.simple-form input[type=password]', count: 1, name: 'password'
533
+ assert_response_has_tag 'form.advanced-form input[type=password]', count: 1, name: 'password'
534
534
  end
535
535
 
536
536
  it 'should display password field in haml' do
537
- get "/haml/form_tag"
538
- assert_response_has_tag 'form.simple-form input[type=password]', :count => 1, :name => 'password'
539
- assert_response_has_tag 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
537
+ get '/haml/form_tag'
538
+ assert_response_has_tag 'form.simple-form input[type=password]', count: 1, name: 'password'
539
+ assert_response_has_tag 'form.advanced-form input[type=password]', count: 1, name: 'password'
540
540
  end
541
541
 
542
542
  it 'should display password field in slim' do
543
- get "/slim/form_tag"
544
- assert_response_has_tag 'form.simple-form input[type=password]', :count => 1, :name => 'password'
545
- assert_response_has_tag 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
543
+ get '/slim/form_tag'
544
+ assert_response_has_tag 'form.simple-form input[type=password]', count: 1, name: 'password'
545
+ assert_response_has_tag 'form.advanced-form input[type=password]', count: 1, name: 'password'
546
546
  end
547
547
  end
548
548
 
549
549
  describe 'for #file_field_tag method' do
550
550
  it 'should display file field in ruby' do
551
- actual_html = file_field_tag(:photo, :class => 'photo')
552
- assert_html_has_tag(actual_html, :input, :type => 'file', :class => "photo", :name => 'photo')
551
+ actual_html = file_field_tag(:photo, class: 'photo')
552
+ assert_html_has_tag(actual_html, :input, type: 'file', class: 'photo', name: 'photo')
553
553
  end
554
554
 
555
555
  it 'should have an array name with multiple option' do
556
- actual_html = file_field_tag(:photos, :multiple => true)
557
- assert_html_has_tag(actual_html, :input, :name => 'photos[]')
556
+ actual_html = file_field_tag(:photos, multiple: true)
557
+ assert_html_has_tag(actual_html, :input, name: 'photos[]')
558
558
  end
559
559
 
560
560
  it 'should display file field in erb' do
561
- get "/erb/form_tag"
562
- assert_response_has_tag 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
561
+ get '/erb/form_tag'
562
+ assert_response_has_tag 'form.advanced-form input[type=file]', count: 1, name: 'photo', class: 'upload'
563
563
  end
564
564
 
565
565
  it 'should display file field in haml' do
566
- get "/haml/form_tag"
567
- assert_response_has_tag 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
566
+ get '/haml/form_tag'
567
+ assert_response_has_tag 'form.advanced-form input[type=file]', count: 1, name: 'photo', class: 'upload'
568
568
  end
569
569
 
570
570
  it 'should display file field in slim' do
571
- get "/slim/form_tag"
572
- assert_response_has_tag 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
571
+ get '/slim/form_tag'
572
+ assert_response_has_tag 'form.advanced-form input[type=file]', count: 1, name: 'photo', class: 'upload'
573
573
  end
574
574
  end
575
575
 
576
- describe "for #check_box_tag method" do
576
+ describe 'for #check_box_tag method' do
577
577
  it 'should display check_box tag in ruby' do
578
- actual_html = check_box_tag("clear_session")
579
- assert_html_has_tag(actual_html, :input, :type => 'checkbox', :value => '1', :name => 'clear_session')
580
- assert_html_has_no_tag(actual_html, :input, :type => 'hidden')
578
+ actual_html = check_box_tag('clear_session')
579
+ assert_html_has_tag(actual_html, :input, type: 'checkbox', value: '1', name: 'clear_session')
580
+ assert_html_has_no_tag(actual_html, :input, type: 'hidden')
581
581
  end
582
582
 
583
583
  it 'should display check_box tag in ruby with extended attributes' do
584
- actual_html = check_box_tag("clear_session", :disabled => true, :checked => true)
585
- assert_html_has_tag(actual_html, :input, :type => 'checkbox', :disabled => 'disabled', :checked => 'checked')
584
+ actual_html = check_box_tag('clear_session', disabled: true, checked: true)
585
+ assert_html_has_tag(actual_html, :input, type: 'checkbox', disabled: 'disabled', checked: 'checked')
586
586
  end
587
587
 
588
588
  it 'should display check_box tag in erb' do
589
- get "/erb/form_tag"
590
- assert_response_has_tag 'form.simple-form input[type=checkbox]', :count => 1
591
- assert_response_has_tag 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
589
+ get '/erb/form_tag'
590
+ assert_response_has_tag 'form.simple-form input[type=checkbox]', count: 1
591
+ assert_response_has_tag 'form.advanced-form input[type=checkbox]', value: '1', checked: 'checked'
592
592
  end
593
593
 
594
594
  it 'should display check_box tag in haml' do
595
- get "/haml/form_tag"
596
- assert_response_has_tag 'form.simple-form input[type=checkbox]', :count => 1
597
- assert_response_has_tag 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
595
+ get '/haml/form_tag'
596
+ assert_response_has_tag 'form.simple-form input[type=checkbox]', count: 1
597
+ assert_response_has_tag 'form.advanced-form input[type=checkbox]', value: '1', checked: 'checked'
598
598
  end
599
599
 
600
600
  it 'should display check_box tag in slim' do
601
- get "/slim/form_tag"
602
- assert_response_has_tag 'form.simple-form input[type=checkbox]', :count => 1
603
- assert_response_has_tag 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
601
+ get '/slim/form_tag'
602
+ assert_response_has_tag 'form.simple-form input[type=checkbox]', count: 1
603
+ assert_response_has_tag 'form.advanced-form input[type=checkbox]', value: '1', checked: 'checked'
604
604
  end
605
605
  end
606
606
 
607
- describe "for #radio_button_tag method" do
607
+ describe 'for #radio_button_tag method' do
608
608
  it 'should display radio_button tag in ruby' do
609
- actual_html = radio_button_tag("gender", :value => 'male')
610
- assert_html_has_tag(actual_html, :input, :type => 'radio', :value => 'male', :name => 'gender')
609
+ actual_html = radio_button_tag('gender', value: 'male')
610
+ assert_html_has_tag(actual_html, :input, type: 'radio', value: 'male', name: 'gender')
611
611
  end
612
612
 
613
613
  it 'should display radio_button tag in ruby with extended attributes' do
614
- actual_html = radio_button_tag("gender", :disabled => true, :checked => true)
615
- assert_html_has_tag(actual_html, :input, :type => 'radio', :disabled => 'disabled', :checked => 'checked')
614
+ actual_html = radio_button_tag('gender', disabled: true, checked: true)
615
+ assert_html_has_tag(actual_html, :input, type: 'radio', disabled: 'disabled', checked: 'checked')
616
616
  end
617
617
 
618
618
  it 'should display radio_button tag in erb' do
619
- get "/erb/form_tag"
620
- assert_response_has_tag 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
621
- assert_response_has_tag 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
622
- assert_response_has_tag 'form.advanced-form input[type=radio]', :value => "male", :checked => 'checked'
623
- assert_response_has_tag 'form.advanced-form input[type=radio]', :value => "female"
619
+ get '/erb/form_tag'
620
+ assert_response_has_tag 'form.simple-form input[type=radio]', count: 1, value: 'male'
621
+ assert_response_has_tag 'form.simple-form input[type=radio]', count: 1, value: 'female'
622
+ assert_response_has_tag 'form.advanced-form input[type=radio]', value: 'male', checked: 'checked'
623
+ assert_response_has_tag 'form.advanced-form input[type=radio]', value: 'female'
624
624
  end
625
625
 
626
626
  it 'should display radio_button tag in haml' do
627
- get "/haml/form_tag"
628
- assert_response_has_tag 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
629
- assert_response_has_tag 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
630
- assert_response_has_tag 'form.advanced-form input[type=radio]', :value => "male", :checked => 'checked'
631
- assert_response_has_tag 'form.advanced-form input[type=radio]', :value => "female"
627
+ get '/haml/form_tag'
628
+ assert_response_has_tag 'form.simple-form input[type=radio]', count: 1, value: 'male'
629
+ assert_response_has_tag 'form.simple-form input[type=radio]', count: 1, value: 'female'
630
+ assert_response_has_tag 'form.advanced-form input[type=radio]', value: 'male', checked: 'checked'
631
+ assert_response_has_tag 'form.advanced-form input[type=radio]', value: 'female'
632
632
  end
633
633
 
634
634
  it 'should display radio_button tag in slim' do
635
- get "/slim/form_tag"
636
- assert_response_has_tag 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
637
- assert_response_has_tag 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
638
- assert_response_has_tag 'form.advanced-form input[type=radio]', :value => "male", :checked => 'checked'
639
- assert_response_has_tag 'form.advanced-form input[type=radio]', :value => "female"
635
+ get '/slim/form_tag'
636
+ assert_response_has_tag 'form.simple-form input[type=radio]', count: 1, value: 'male'
637
+ assert_response_has_tag 'form.simple-form input[type=radio]', count: 1, value: 'female'
638
+ assert_response_has_tag 'form.advanced-form input[type=radio]', value: 'male', checked: 'checked'
639
+ assert_response_has_tag 'form.advanced-form input[type=radio]', value: 'female'
640
640
  end
641
641
  end
642
642
 
643
- describe "for #select_tag method" do
643
+ describe 'for #select_tag method' do
644
644
  it 'should display select tag in ruby' do
645
- actual_html = select_tag(:favorite_color, :options => ['green', 'blue', 'black'], :include_blank => true)
646
- assert_html_has_tag(actual_html, :select, :name => 'favorite_color')
647
- assert_html_has_tag(actual_html, 'select option:first-child', :content => '')
648
- assert_html_has_tag(actual_html, 'select option', :content => 'green', :value => 'green')
649
- assert_html_has_tag(actual_html, 'select option', :content => 'blue', :value => 'blue')
650
- assert_html_has_tag(actual_html, 'select option', :content => 'black', :value => 'black')
645
+ actual_html = select_tag(:favorite_color, options: %w[green blue black], include_blank: true)
646
+ assert_html_has_tag(actual_html, :select, name: 'favorite_color')
647
+ assert_html_has_tag(actual_html, 'select option:first-child', content: '')
648
+ assert_html_has_tag(actual_html, 'select option', content: 'green', value: 'green')
649
+ assert_html_has_tag(actual_html, 'select option', content: 'blue', value: 'blue')
650
+ assert_html_has_tag(actual_html, 'select option', content: 'black', value: 'black')
651
651
  end
652
652
 
653
653
  it 'should display select tag in ruby with extended attributes' do
654
- actual_html = select_tag(:favorite_color, :disabled => true, :options => ['only', 'option'])
655
- assert_html_has_tag(actual_html, :select, :disabled => 'disabled')
654
+ actual_html = select_tag(:favorite_color, disabled: true, options: %w[only option])
655
+ assert_html_has_tag(actual_html, :select, disabled: 'disabled')
656
656
  end
657
657
 
658
658
  it 'should take a range as a collection for options' do
659
- actual_html = select_tag(:favorite_color, :options => (1..3))
659
+ actual_html = select_tag(:favorite_color, options: (1..3))
660
660
  assert_html_has_tag(actual_html, :select)
661
- assert_html_has_tag(actual_html, 'select option', :content => '1', :value => '1')
662
- assert_html_has_tag(actual_html, 'select option', :content => '2', :value => '2')
663
- assert_html_has_tag(actual_html, 'select option', :content => '3', :value => '3')
661
+ assert_html_has_tag(actual_html, 'select option', content: '1', value: '1')
662
+ assert_html_has_tag(actual_html, 'select option', content: '2', value: '2')
663
+ assert_html_has_tag(actual_html, 'select option', content: '3', value: '3')
664
664
  end
665
665
 
666
666
  it 'should include blank for grouped options' do
667
- opts = { "Red" => ["Rose","Fire"], "Blue" => ["Sky","Sea"] }
668
- actual_html = select_tag( 'color', :grouped_options => opts, :include_blank => true )
669
- assert_html_has_tag(actual_html, 'select option:first-child', :value => "", :content => "")
667
+ opts = { 'Red' => %w[Rose Fire], 'Blue' => %w[Sky Sea] }
668
+ actual_html = select_tag('color', grouped_options: opts, include_blank: true)
669
+ assert_html_has_tag(actual_html, 'select option:first-child', value: '', content: '')
670
670
  end
671
671
 
672
672
  it 'should include blank as caption' do
673
- opts = { "Red" => ["Rose","Fire"], "Blue" => ["Sky","Sea"] }
674
- actual_html = select_tag( 'color', :grouped_options => opts, :include_blank => 'Choose your destiny' )
675
- assert_html_has_tag(actual_html, 'select option:first-child', :value => "", :content => "Choose your destiny")
673
+ opts = { 'Red' => %w[Rose Fire], 'Blue' => %w[Sky Sea] }
674
+ actual_html = select_tag('color', grouped_options: opts, include_blank: 'Choose your destiny')
675
+ assert_html_has_tag(actual_html, 'select option:first-child', value: '', content: 'Choose your destiny')
676
676
  assert_html_has_no_tag(actual_html, 'select[include_blank]')
677
677
  end
678
678
 
679
679
  it 'should display select tag with grouped options for a nested array' do
680
680
  opts = [
681
- ["Friends",["Yoda",["Obiwan",2]]],
682
- ["Enemies", ["Palpatine",['Darth Vader',3]]]
681
+ ['Friends', ['Yoda', ['Obiwan', 2]]],
682
+ ['Enemies', ['Palpatine', ['Darth Vader', 3]]]
683
683
  ]
684
- actual_html = select_tag( 'name', :grouped_options => opts )
685
- assert_html_has_tag(actual_html, :select, :name => "name")
686
- assert_html_has_tag(actual_html, :optgroup, :label => "Friends")
687
- assert_html_has_tag(actual_html, :option, :value => "Yoda", :content => "Yoda")
688
- assert_html_has_tag(actual_html, :option, :value => "2", :content => "Obiwan")
689
- assert_html_has_tag(actual_html, :optgroup, :label => "Enemies")
690
- assert_html_has_tag(actual_html, :option, :value => "Palpatine", :content => "Palpatine")
691
- assert_html_has_tag(actual_html, :option, :value => "3", :content => "Darth Vader")
684
+ actual_html = select_tag('name', grouped_options: opts)
685
+ assert_html_has_tag(actual_html, :select, name: 'name')
686
+ assert_html_has_tag(actual_html, :optgroup, label: 'Friends')
687
+ assert_html_has_tag(actual_html, :option, value: 'Yoda', content: 'Yoda')
688
+ assert_html_has_tag(actual_html, :option, value: '2', content: 'Obiwan')
689
+ assert_html_has_tag(actual_html, :optgroup, label: 'Enemies')
690
+ assert_html_has_tag(actual_html, :option, value: 'Palpatine', content: 'Palpatine')
691
+ assert_html_has_tag(actual_html, :option, value: '3', content: 'Darth Vader')
692
692
  end
693
693
 
694
694
  it 'should display select tag with grouped options for a nested array and accept disabled groups' do
695
695
  opts = [
696
- ["Friends",["Yoda",["Obiwan",2]]],
697
- ["Enemies", ["Palpatine",['Darth Vader',3]], {:disabled => true}]
696
+ ['Friends', ['Yoda', ['Obiwan', 2]]],
697
+ ['Enemies', ['Palpatine', ['Darth Vader', 3]], { disabled: true }]
698
698
  ]
699
- actual_html = select_tag( 'name', :grouped_options => opts )
700
- assert_html_has_tag(actual_html, :select, :name => "name")
701
- assert_html_has_tag(actual_html, :option, :disabled => 'disabled', :count => 0)
702
- assert_html_has_tag(actual_html, :optgroup, :disabled => 'disabled', :count => 1)
703
- assert_html_has_tag(actual_html, :optgroup, :label => "Enemies", :disabled => 'disabled')
699
+ actual_html = select_tag('name', grouped_options: opts)
700
+ assert_html_has_tag(actual_html, :select, name: 'name')
701
+ assert_html_has_tag(actual_html, :option, disabled: 'disabled', count: 0)
702
+ assert_html_has_tag(actual_html, :optgroup, disabled: 'disabled', count: 1)
703
+ assert_html_has_tag(actual_html, :optgroup, label: 'Enemies', disabled: 'disabled')
704
704
  end
705
705
 
706
706
  it 'should display select tag with grouped options for a nested array and accept disabled groups and/or with disabled options' do
707
707
  opts = [
708
- ["Friends",["Yoda",["Obiwan",2, {:disabled => true}]]],
709
- ["Enemies", [["Palpatine", "Palpatine", {:disabled => true}],['Darth Vader',3]], {:disabled => true}]
708
+ ['Friends', ['Yoda', ['Obiwan', 2, { disabled: true }]]],
709
+ ['Enemies', [['Palpatine', 'Palpatine', { disabled: true }], ['Darth Vader', 3]], { disabled: true }]
710
710
  ]
711
- actual_html = select_tag( 'name', :grouped_options => opts )
712
- assert_html_has_tag(actual_html, :select, :name => "name")
713
- assert_html_has_tag(actual_html, :option, :disabled => 'disabled', :count => 2)
714
- assert_html_has_tag(actual_html, :optgroup, :disabled => 'disabled', :count => 1)
715
- assert_html_has_tag(actual_html, :option, :content => "Obiwan", :disabled => 'disabled')
716
- assert_html_has_tag(actual_html, :optgroup, :label => "Enemies", :disabled => 'disabled')
717
- assert_html_has_tag(actual_html, :option, :value => "Palpatine", :content => "Palpatine", :disabled => 'disabled')
711
+ actual_html = select_tag('name', grouped_options: opts)
712
+ assert_html_has_tag(actual_html, :select, name: 'name')
713
+ assert_html_has_tag(actual_html, :option, disabled: 'disabled', count: 2)
714
+ assert_html_has_tag(actual_html, :optgroup, disabled: 'disabled', count: 1)
715
+ assert_html_has_tag(actual_html, :option, content: 'Obiwan', disabled: 'disabled')
716
+ assert_html_has_tag(actual_html, :optgroup, label: 'Enemies', disabled: 'disabled')
717
+ assert_html_has_tag(actual_html, :option, value: 'Palpatine', content: 'Palpatine', disabled: 'disabled')
718
718
  end
719
719
 
720
720
  it 'should display select tag with grouped options for a hash' do
721
721
  opts = {
722
- "Friends" => ["Yoda",["Obiwan",2]],
723
- "Enemies" => ["Palpatine",['Darth Vader',3]]
722
+ 'Friends' => ['Yoda', ['Obiwan', 2]],
723
+ 'Enemies' => ['Palpatine', ['Darth Vader', 3]]
724
724
  }
725
- actual_html = select_tag( 'name', :grouped_options => opts )
726
- assert_html_has_tag(actual_html, :select, :name => "name")
727
- assert_html_has_tag(actual_html, :optgroup, :label => "Friends")
728
- assert_html_has_tag(actual_html, :option, :value => "Yoda", :content => "Yoda")
729
- assert_html_has_tag(actual_html, :option, :value => "2", :content => "Obiwan")
730
- assert_html_has_tag(actual_html, :optgroup, :label => "Enemies")
731
- assert_html_has_tag(actual_html, :option, :value => "Palpatine", :content => "Palpatine")
732
- assert_html_has_tag(actual_html, :option, :value => "3", :content => "Darth Vader")
725
+ actual_html = select_tag('name', grouped_options: opts)
726
+ assert_html_has_tag(actual_html, :select, name: 'name')
727
+ assert_html_has_tag(actual_html, :optgroup, label: 'Friends')
728
+ assert_html_has_tag(actual_html, :option, value: 'Yoda', content: 'Yoda')
729
+ assert_html_has_tag(actual_html, :option, value: '2', content: 'Obiwan')
730
+ assert_html_has_tag(actual_html, :optgroup, label: 'Enemies')
731
+ assert_html_has_tag(actual_html, :option, value: 'Palpatine', content: 'Palpatine')
732
+ assert_html_has_tag(actual_html, :option, value: '3', content: 'Darth Vader')
733
733
  end
734
734
 
735
735
  it 'should display select tag with grouped options for a hash and accept disabled groups and/or with disabled options' do
736
736
  opts = {
737
- "Friends" => ["Yoda",["Obiwan",2,{:disabled => true}]],
738
- "Enemies" => [["Palpatine","Palpatine",{:disabled => true}],["Darth Vader",3], {:disabled => true}]
737
+ 'Friends' => ['Yoda', ['Obiwan', 2, { disabled: true }]],
738
+ 'Enemies' => [['Palpatine', 'Palpatine', { disabled: true }], ['Darth Vader', 3], { disabled: true }]
739
739
  }
740
- actual_html = select_tag( 'name', :grouped_options => opts )
741
- assert_html_has_tag(actual_html, :select, :name => "name")
742
- assert_html_has_tag(actual_html, :option, :disabled => 'disabled', :count => 2)
743
- assert_html_has_tag(actual_html, :optgroup, :disabled => 'disabled', :count => 1)
744
- assert_html_has_tag(actual_html, :option, :content => "Obiwan", :disabled => 'disabled')
745
- assert_html_has_tag(actual_html, :optgroup, :label => "Enemies", :disabled => 'disabled')
746
- assert_html_has_tag(actual_html, :option, :value => "Palpatine", :content => "Palpatine", :disabled => 'disabled')
740
+ actual_html = select_tag('name', grouped_options: opts)
741
+ assert_html_has_tag(actual_html, :select, name: 'name')
742
+ assert_html_has_tag(actual_html, :option, disabled: 'disabled', count: 2)
743
+ assert_html_has_tag(actual_html, :optgroup, disabled: 'disabled', count: 1)
744
+ assert_html_has_tag(actual_html, :option, content: 'Obiwan', disabled: 'disabled')
745
+ assert_html_has_tag(actual_html, :optgroup, label: 'Enemies', disabled: 'disabled')
746
+ assert_html_has_tag(actual_html, :option, value: 'Palpatine', content: 'Palpatine', disabled: 'disabled')
747
747
  end
748
748
 
749
749
  it 'should display select tag with grouped options for a rails-style attribute hash' do
750
750
  opts = {
751
- "Friends" => ["Yoda",["Obiwan",2,{:magister=>'no'}],{:lame=>'yes'}],
752
- "Enemies" => [["Palpatine","Palpatine",{:scary=>'yes',:old=>'yes'}],["Darth Vader",3,{:disabled=>true}]]
751
+ 'Friends' => ['Yoda', ['Obiwan', 2, { magister: 'no' }], { lame: 'yes' }],
752
+ 'Enemies' => [['Palpatine', 'Palpatine', { scary: 'yes', old: 'yes' }], ['Darth Vader', 3, { disabled: true }]]
753
753
  }
754
- actual_html = select_tag( 'name', :grouped_options => opts, :disabled_options => [2], :selected => ['Yoda'] )
755
- assert_html_has_tag(actual_html, :optgroup, :label => "Friends", :lame => 'yes')
756
- assert_html_has_tag(actual_html, :option, :value => "Palpatine", :content => "Palpatine", :scary => 'yes', :old => 'yes')
757
- assert_html_has_tag(actual_html, :option, :content => "Darth Vader", :disabled => 'disabled')
758
- assert_html_has_tag(actual_html, :option, :content => "Obiwan", :disabled => 'disabled')
759
- assert_html_has_tag(actual_html, :option, :content => "Yoda", :selected => 'selected')
754
+ actual_html = select_tag('name', grouped_options: opts, disabled_options: [2], selected: ['Yoda'])
755
+ assert_html_has_tag(actual_html, :optgroup, label: 'Friends', lame: 'yes')
756
+ assert_html_has_tag(actual_html, :option, value: 'Palpatine', content: 'Palpatine', scary: 'yes', old: 'yes')
757
+ assert_html_has_tag(actual_html, :option, content: 'Darth Vader', disabled: 'disabled')
758
+ assert_html_has_tag(actual_html, :option, content: 'Obiwan', disabled: 'disabled')
759
+ assert_html_has_tag(actual_html, :option, content: 'Yoda', selected: 'selected')
760
760
  end
761
761
 
762
762
  it 'should display select tag in ruby with multiple attribute' do
763
- actual_html = select_tag(:favorite_color, :multiple => true, :options => ['only', 'option'])
764
- assert_html_has_tag(actual_html, :select, :multiple => 'multiple', :name => 'favorite_color[]')
763
+ actual_html = select_tag(:favorite_color, multiple: true, options: %w[only option])
764
+ assert_html_has_tag(actual_html, :select, multiple: 'multiple', name: 'favorite_color[]')
765
765
  end
766
766
 
767
767
  it 'should display options with values and single selected' do
768
- options = [['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
769
- actual_html = select_tag(:favorite_color, :options => options, :selected => 'green1')
770
- assert_html_has_tag(actual_html, :select, :name => 'favorite_color')
771
- assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
772
- assert_html_has_tag(actual_html, 'select option', :content => 'Green', :value => 'green1', :selected => 'selected')
773
- assert_html_has_tag(actual_html, 'select option', :content => 'Blue', :value => 'blue1')
774
- assert_html_has_tag(actual_html, 'select option', :content => 'Black', :value => 'black1')
768
+ options = [%w[Green green1], %w[Blue blue1], %w[Black black1]]
769
+ actual_html = select_tag(:favorite_color, options: options, selected: 'green1')
770
+ assert_html_has_tag(actual_html, :select, name: 'favorite_color')
771
+ assert_html_has_tag(actual_html, 'select option', selected: 'selected', count: 1)
772
+ assert_html_has_tag(actual_html, 'select option', content: 'Green', value: 'green1', selected: 'selected')
773
+ assert_html_has_tag(actual_html, 'select option', content: 'Blue', value: 'blue1')
774
+ assert_html_has_tag(actual_html, 'select option', content: 'Black', value: 'black1')
775
775
  end
776
776
 
777
777
  it 'should display selected options first based on values not content' do
778
- options = [['First', 'one'], ['one', 'two'], ['three', 'three']]
779
- actual_html = select_tag(:number, :options => options, :selected => 'one')
780
- assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
781
- assert_html_has_tag(actual_html, 'select option', :content => 'First', :value => 'one', :selected => 'selected')
778
+ options = [%w[First one], %w[one two], %w[three three]]
779
+ actual_html = select_tag(:number, options: options, selected: 'one')
780
+ assert_html_has_tag(actual_html, 'select option', selected: 'selected', count: 1)
781
+ assert_html_has_tag(actual_html, 'select option', content: 'First', value: 'one', selected: 'selected')
782
782
  end
783
783
 
784
784
  it 'should display selected options falling back to checking content' do
785
- options = [['one', nil, :value => nil], ['two', nil, :value => nil], ['three', 'three']]
786
- actual_html = select_tag(:number, :options => options, :selected => 'one')
787
- assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
788
- assert_html_has_tag(actual_html, 'select option', :content => 'one', :selected => 'selected')
785
+ options = [['one', nil, { value: nil }], ['two', nil, { value: nil }], %w[three three]]
786
+ actual_html = select_tag(:number, options: options, selected: 'one')
787
+ assert_html_has_tag(actual_html, 'select option', selected: 'selected', count: 1)
788
+ assert_html_has_tag(actual_html, 'select option', content: 'one', selected: 'selected')
789
789
  end
790
790
 
791
791
  it 'should display options with values and accept disabled options' do
792
- options = [['Green', 'green1', {:disabled => true}], ['Blue', 'blue1'], ['Black', "black1"]]
793
- actual_html = select_tag(:favorite_color, :options => options)
794
- assert_html_has_tag(actual_html, :select, :name => 'favorite_color')
795
- assert_html_has_tag(actual_html, 'select option', :disabled => 'disabled', :count => 1)
796
- assert_html_has_tag(actual_html, 'select option', :content => 'Green', :value => 'green1', :disabled => 'disabled')
797
- assert_html_has_tag(actual_html, 'select option', :content => 'Blue', :value => 'blue1')
798
- assert_html_has_tag(actual_html, 'select option', :content => 'Black', :value => 'black1')
792
+ options = [['Green', 'green1', { disabled: true }], %w[Blue blue1], %w[Black black1]]
793
+ actual_html = select_tag(:favorite_color, options: options)
794
+ assert_html_has_tag(actual_html, :select, name: 'favorite_color')
795
+ assert_html_has_tag(actual_html, 'select option', disabled: 'disabled', count: 1)
796
+ assert_html_has_tag(actual_html, 'select option', content: 'Green', value: 'green1', disabled: 'disabled')
797
+ assert_html_has_tag(actual_html, 'select option', content: 'Blue', value: 'blue1')
798
+ assert_html_has_tag(actual_html, 'select option', content: 'Black', value: 'black1')
799
799
  end
800
800
 
801
801
  it 'should display option with values and multiple selected' do
802
- options = [['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
803
- actual_html = select_tag(:favorite_color, :options => options, :selected => ['green1', 'black1'])
804
- assert_html_has_tag(actual_html, :select, :name => 'favorite_color')
805
- assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 2)
806
- assert_html_has_tag(actual_html, 'select option', :content => 'Green', :value => 'green1', :selected => 'selected')
807
- assert_html_has_tag(actual_html, 'select option', :content => 'Blue', :value => 'blue1')
808
- assert_html_has_tag(actual_html, 'select option', :content => 'Black', :value => 'black1', :selected => 'selected')
802
+ options = [%w[Green green1], %w[Blue blue1], %w[Black black1]]
803
+ actual_html = select_tag(:favorite_color, options: options, selected: %w[green1 black1])
804
+ assert_html_has_tag(actual_html, :select, name: 'favorite_color')
805
+ assert_html_has_tag(actual_html, 'select option', selected: 'selected', count: 2)
806
+ assert_html_has_tag(actual_html, 'select option', content: 'Green', value: 'green1', selected: 'selected')
807
+ assert_html_has_tag(actual_html, 'select option', content: 'Blue', value: 'blue1')
808
+ assert_html_has_tag(actual_html, 'select option', content: 'Black', value: 'black1', selected: 'selected')
809
809
  end
810
810
 
811
811
  it 'should not misselect options with default value' do
812
- options = ['Green', 'Blue']
813
- actual_html = select_tag(:favorite_color, :options => options, :selected => ['Green', ''])
814
- assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
815
- assert_html_has_tag(actual_html, 'select option', :content => 'Green', :value => 'Green', :selected => 'selected')
812
+ options = %w[Green Blue]
813
+ actual_html = select_tag(:favorite_color, options: options, selected: ['Green', ''])
814
+ assert_html_has_tag(actual_html, 'select option', selected: 'selected', count: 1)
815
+ assert_html_has_tag(actual_html, 'select option', content: 'Green', value: 'Green', selected: 'selected')
816
816
  end
817
817
 
818
818
  it 'should display options selected only for exact match' do
819
- options = [['One', '1'], ['1', '10'], ['Two', "-1"]]
820
- actual_html = select_tag(:range, :options => options, :selected => '-1')
821
- assert_html_has_tag(actual_html, :select, :name => 'range')
822
- assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
823
- assert_html_has_tag(actual_html, 'select option', :content => 'Two', :value => '-1', :selected => 'selected')
819
+ options = [['One', '1'], ['1', '10'], ['Two', '-1']]
820
+ actual_html = select_tag(:range, options: options, selected: '-1')
821
+ assert_html_has_tag(actual_html, :select, name: 'range')
822
+ assert_html_has_tag(actual_html, 'select option', selected: 'selected', count: 1)
823
+ assert_html_has_tag(actual_html, 'select option', content: 'Two', value: '-1', selected: 'selected')
824
824
  end
825
825
 
826
826
  it 'should display select tag in erb' do
827
- get "/erb/form_tag"
828
- assert_response_has_tag 'form.simple-form select', :count => 1, :name => 'color'
829
- assert_response_has_tag('select option', :content => 'green', :value => 'green')
830
- assert_response_has_tag('select option', :content => 'orange', :value => 'orange')
831
- assert_response_has_tag('select option', :content => 'purple', :value => 'purple')
832
- assert_response_has_tag('form.advanced-form select', :name => 'fav_color')
833
- assert_response_has_tag('select option', :content => 'green', :value => '1')
834
- assert_response_has_tag('select option', :content => 'orange', :value => '2', :selected => 'selected')
835
- assert_response_has_tag('select option', :content => 'purple', :value => '3')
836
- assert_response_has_tag('select optgroup', :label => 'foo')
837
- assert_response_has_tag('select optgroup', :label => 'bar')
838
- assert_response_has_tag('select optgroup option', :content => 'foo', :value => 'foo')
839
- assert_response_has_tag('select optgroup option', :content => 'bar', :value => 'bar')
840
- assert_response_has_tag('select optgroup', :label => 'Friends')
841
- assert_response_has_tag('select optgroup', :label => 'Enemies')
842
- assert_response_has_tag('select optgroup option', :content => 'Yoda', :value => 'Yoda')
843
- assert_response_has_tag('select optgroup option', :content => 'Obiwan', :value => '1')
844
- assert_response_has_tag('select optgroup option', :content => 'Palpatine', :value => 'Palpatine')
845
- assert_response_has_tag('select optgroup option', :content => 'Darth Vader', :value => '3')
827
+ get '/erb/form_tag'
828
+ assert_response_has_tag 'form.simple-form select', count: 1, name: 'color'
829
+ assert_response_has_tag('select option', content: 'green', value: 'green')
830
+ assert_response_has_tag('select option', content: 'orange', value: 'orange')
831
+ assert_response_has_tag('select option', content: 'purple', value: 'purple')
832
+ assert_response_has_tag('form.advanced-form select', name: 'fav_color')
833
+ assert_response_has_tag('select option', content: 'green', value: '1')
834
+ assert_response_has_tag('select option', content: 'orange', value: '2', selected: 'selected')
835
+ assert_response_has_tag('select option', content: 'purple', value: '3')
836
+ assert_response_has_tag('select optgroup', label: 'foo')
837
+ assert_response_has_tag('select optgroup', label: 'bar')
838
+ assert_response_has_tag('select optgroup option', content: 'foo', value: 'foo')
839
+ assert_response_has_tag('select optgroup option', content: 'bar', value: 'bar')
840
+ assert_response_has_tag('select optgroup', label: 'Friends')
841
+ assert_response_has_tag('select optgroup', label: 'Enemies')
842
+ assert_response_has_tag('select optgroup option', content: 'Yoda', value: 'Yoda')
843
+ assert_response_has_tag('select optgroup option', content: 'Obiwan', value: '1')
844
+ assert_response_has_tag('select optgroup option', content: 'Palpatine', value: 'Palpatine')
845
+ assert_response_has_tag('select optgroup option', content: 'Darth Vader', value: '3')
846
846
  end
847
847
 
848
848
  it 'should display select tag in haml' do
849
- get "/haml/form_tag"
850
- assert_response_has_tag 'form.simple-form select', :count => 1, :name => 'color'
851
- assert_response_has_tag('select option', :content => 'green', :value => 'green')
852
- assert_response_has_tag('select option', :content => 'orange', :value => 'orange')
853
- assert_response_has_tag('select option', :content => 'purple', :value => 'purple')
854
- assert_response_has_tag('form.advanced-form select', :name => 'fav_color')
855
- assert_response_has_tag('select option', :content => 'green', :value => '1')
856
- assert_response_has_tag('select option', :content => 'orange', :value => '2', :selected => 'selected')
857
- assert_response_has_tag('select option', :content => 'purple', :value => '3')
858
- assert_response_has_tag('select optgroup', :label => 'foo')
859
- assert_response_has_tag('select optgroup', :label => 'bar')
860
- assert_response_has_tag('select optgroup option', :content => 'foo', :value => 'foo')
861
- assert_response_has_tag('select optgroup option', :content => 'bar', :value => 'bar')
862
- assert_response_has_tag('select optgroup', :label => 'Friends')
863
- assert_response_has_tag('select optgroup', :label => 'Enemies')
864
- assert_response_has_tag('select optgroup option', :content => 'Yoda', :value => 'Yoda')
865
- assert_response_has_tag('select optgroup option', :content => 'Obiwan', :value => '1')
866
- assert_response_has_tag('select optgroup option', :content => 'Palpatine', :value => 'Palpatine')
867
- assert_response_has_tag('select optgroup option', :content => 'Darth Vader', :value => '3')
849
+ get '/haml/form_tag'
850
+ assert_response_has_tag 'form.simple-form select', count: 1, name: 'color'
851
+ assert_response_has_tag('select option', content: 'green', value: 'green')
852
+ assert_response_has_tag('select option', content: 'orange', value: 'orange')
853
+ assert_response_has_tag('select option', content: 'purple', value: 'purple')
854
+ assert_response_has_tag('form.advanced-form select', name: 'fav_color')
855
+ assert_response_has_tag('select option', content: 'green', value: '1')
856
+ assert_response_has_tag('select option', content: 'orange', value: '2', selected: 'selected')
857
+ assert_response_has_tag('select option', content: 'purple', value: '3')
858
+ assert_response_has_tag('select optgroup', label: 'foo')
859
+ assert_response_has_tag('select optgroup', label: 'bar')
860
+ assert_response_has_tag('select optgroup option', content: 'foo', value: 'foo')
861
+ assert_response_has_tag('select optgroup option', content: 'bar', value: 'bar')
862
+ assert_response_has_tag('select optgroup', label: 'Friends')
863
+ assert_response_has_tag('select optgroup', label: 'Enemies')
864
+ assert_response_has_tag('select optgroup option', content: 'Yoda', value: 'Yoda')
865
+ assert_response_has_tag('select optgroup option', content: 'Obiwan', value: '1')
866
+ assert_response_has_tag('select optgroup option', content: 'Palpatine', value: 'Palpatine')
867
+ assert_response_has_tag('select optgroup option', content: 'Darth Vader', value: '3')
868
868
  end
869
869
 
870
870
  it 'should display select tag in slim' do
871
- get "/slim/form_tag"
872
- assert_response_has_tag 'form.simple-form select', :count => 1, :name => 'color'
873
- assert_response_has_tag('select option', :content => 'green', :value => 'green')
874
- assert_response_has_tag('select option', :content => 'orange', :value => 'orange')
875
- assert_response_has_tag('select option', :content => 'purple', :value => 'purple')
876
- assert_response_has_tag('form.advanced-form select', :name => 'fav_color')
877
- assert_response_has_tag('select option', :content => 'green', :value => '1')
878
- assert_response_has_tag('select option', :content => 'orange', :value => '2', :selected => 'selected')
879
- assert_response_has_tag('select option', :content => 'purple', :value => '3')
880
- assert_response_has_tag('select optgroup', :label => 'foo')
881
- assert_response_has_tag('select optgroup', :label => 'bar')
882
- assert_response_has_tag('select optgroup option', :content => 'foo', :value => 'foo')
883
- assert_response_has_tag('select optgroup option', :content => 'bar', :value => 'bar')
884
- assert_response_has_tag('select optgroup', :label => 'Friends')
885
- assert_response_has_tag('select optgroup', :label => 'Enemies')
886
- assert_response_has_tag('select optgroup option', :content => 'Yoda', :value => 'Yoda')
887
- assert_response_has_tag('select optgroup option', :content => 'Obiwan', :value => '1')
888
- assert_response_has_tag('select optgroup option', :content => 'Palpatine', :value => 'Palpatine')
889
- assert_response_has_tag('select optgroup option', :content => 'Darth Vader', :value => '3')
871
+ get '/slim/form_tag'
872
+ assert_response_has_tag 'form.simple-form select', count: 1, name: 'color'
873
+ assert_response_has_tag('select option', content: 'green', value: 'green')
874
+ assert_response_has_tag('select option', content: 'orange', value: 'orange')
875
+ assert_response_has_tag('select option', content: 'purple', value: 'purple')
876
+ assert_response_has_tag('form.advanced-form select', name: 'fav_color')
877
+ assert_response_has_tag('select option', content: 'green', value: '1')
878
+ assert_response_has_tag('select option', content: 'orange', value: '2', selected: 'selected')
879
+ assert_response_has_tag('select option', content: 'purple', value: '3')
880
+ assert_response_has_tag('select optgroup', label: 'foo')
881
+ assert_response_has_tag('select optgroup', label: 'bar')
882
+ assert_response_has_tag('select optgroup option', content: 'foo', value: 'foo')
883
+ assert_response_has_tag('select optgroup option', content: 'bar', value: 'bar')
884
+ assert_response_has_tag('select optgroup', label: 'Friends')
885
+ assert_response_has_tag('select optgroup', label: 'Enemies')
886
+ assert_response_has_tag('select optgroup option', content: 'Yoda', value: 'Yoda')
887
+ assert_response_has_tag('select optgroup option', content: 'Obiwan', value: '1')
888
+ assert_response_has_tag('select optgroup option', content: 'Palpatine', value: 'Palpatine')
889
+ assert_response_has_tag('select optgroup option', content: 'Darth Vader', value: '3')
890
890
  end
891
891
  end
892
892
 
893
893
  describe 'for #submit_tag method' do
894
894
  it 'should display submit tag in ruby' do
895
- actual_html = submit_tag("Update", :class => 'success')
896
- assert_html_has_tag(actual_html, :input, :type => 'submit', :class => "success", :value => 'Update')
895
+ actual_html = submit_tag('Update', class: 'success')
896
+ assert_html_has_tag(actual_html, :input, type: 'submit', class: 'success', value: 'Update')
897
897
  end
898
898
 
899
899
  it 'should display submit tag in erb' do
900
- get "/erb/form_tag"
901
- assert_response_has_tag 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
902
- assert_response_has_tag 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
900
+ get '/erb/form_tag'
901
+ assert_response_has_tag 'form.simple-form input[type=submit]', count: 1, value: 'Submit'
902
+ assert_response_has_tag 'form.advanced-form input[type=submit]', count: 1, value: 'Login'
903
903
  end
904
904
 
905
905
  it 'should display submit tag in haml' do
906
- get "/haml/form_tag"
907
- assert_response_has_tag 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
908
- assert_response_has_tag 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
906
+ get '/haml/form_tag'
907
+ assert_response_has_tag 'form.simple-form input[type=submit]', count: 1, value: 'Submit'
908
+ assert_response_has_tag 'form.advanced-form input[type=submit]', count: 1, value: 'Login'
909
909
  end
910
910
 
911
911
  it 'should display submit tag in slim' do
912
- get "/slim/form_tag"
913
- assert_response_has_tag 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
914
- assert_response_has_tag 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
912
+ get '/slim/form_tag'
913
+ assert_response_has_tag 'form.simple-form input[type=submit]', count: 1, value: 'Submit'
914
+ assert_response_has_tag 'form.advanced-form input[type=submit]', count: 1, value: 'Login'
915
915
  end
916
916
 
917
917
  describe 'for omitted args' do
918
918
  it 'should display submit tag with default caption' do
919
- actual_html = submit_tag()
920
- assert_html_has_tag(actual_html, :input, :type => 'submit', :value => 'Submit')
919
+ actual_html = submit_tag
920
+ assert_html_has_tag(actual_html, :input, type: 'submit', value: 'Submit')
921
921
  end
922
922
  end
923
923
 
924
924
  describe 'for omitted caption arg' do
925
925
  it 'should display submit tag with default caption' do
926
- actual_html = submit_tag(:class => 'success')
927
- assert_html_has_tag(actual_html, :input, :type => 'submit', :class => 'success', :value => 'Submit')
926
+ actual_html = submit_tag(class: 'success')
927
+ assert_html_has_tag(actual_html, :input, type: 'submit', class: 'success', value: 'Submit')
928
928
  end
929
929
 
930
930
  it 'should display submit tag without caption value when nil' do
931
- actual_html = submit_tag(nil, :class => 'success')
932
- assert_html_has_tag(actual_html, :input, :type => 'submit', :class => 'success')
933
- assert_html_has_no_tag(actual_html, :input, :type => 'submit', :class => 'success', :value => 'Submit')
931
+ actual_html = submit_tag(nil, class: 'success')
932
+ assert_html_has_tag(actual_html, :input, type: 'submit', class: 'success')
933
+ assert_html_has_no_tag(actual_html, :input, type: 'submit', class: 'success', value: 'Submit')
934
934
  end
935
935
  end
936
936
  end
937
937
 
938
938
  describe 'for #button_tag method' do
939
939
  it 'should display submit tag in ruby' do
940
- actual_html = button_tag("Cancel", :class => 'clear')
941
- assert_html_has_tag(actual_html, :input, :type => 'button', :class => "clear", :value => 'Cancel')
940
+ actual_html = button_tag('Cancel', class: 'clear')
941
+ assert_html_has_tag(actual_html, :input, type: 'button', class: 'clear', value: 'Cancel')
942
942
  end
943
943
 
944
944
  it 'should display submit tag in erb' do
945
- get "/erb/form_tag"
946
- assert_response_has_tag 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
945
+ get '/erb/form_tag'
946
+ assert_response_has_tag 'form.advanced-form input[type=button]', count: 1, value: 'Cancel'
947
947
  end
948
948
 
949
949
  it 'should display submit tag in haml' do
950
- get "/haml/form_tag"
951
- assert_response_has_tag 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
950
+ get '/haml/form_tag'
951
+ assert_response_has_tag 'form.advanced-form input[type=button]', count: 1, value: 'Cancel'
952
952
  end
953
953
 
954
954
  it 'should display submit tag in slim' do
955
- get "/slim/form_tag"
956
- assert_response_has_tag 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
955
+ get '/slim/form_tag'
956
+ assert_response_has_tag 'form.advanced-form input[type=button]', count: 1, value: 'Cancel'
957
957
  end
958
958
  end
959
959
 
@@ -963,119 +963,119 @@ describe "FormHelpers" do
963
963
  end
964
964
 
965
965
  it 'should display image submit tag in ruby with relative path' do
966
- actual_html = image_submit_tag('buttons/ok.png', :class => 'success')
967
- assert_html_has_tag(actual_html, :input, :type => 'image', :class => "success", :src => "/images/buttons/ok.png?#{@stamp}")
966
+ actual_html = image_submit_tag('buttons/ok.png', class: 'success')
967
+ assert_html_has_tag(actual_html, :input, type: 'image', class: 'success', src: "/images/buttons/ok.png?#{@stamp}")
968
968
  end
969
969
 
970
970
  it 'should display image submit tag in ruby with absolute path' do
971
- actual_html = image_submit_tag('/system/ok.png', :class => 'success')
972
- assert_html_has_tag(actual_html, :input, :type => 'image', :class => "success", :src => "/system/ok.png")
971
+ actual_html = image_submit_tag('/system/ok.png', class: 'success')
972
+ assert_html_has_tag(actual_html, :input, type: 'image', class: 'success', src: '/system/ok.png')
973
973
  end
974
974
 
975
975
  it 'should display image submit tag in erb' do
976
- get "/erb/form_tag"
977
- assert_response_has_tag 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
976
+ get '/erb/form_tag'
977
+ assert_response_has_tag 'form.advanced-form input[type=image]', count: 1, src: "/images/buttons/submit.png?#{@stamp}"
978
978
  end
979
979
 
980
980
  it 'should display image submit tag in haml' do
981
- get "/haml/form_tag"
982
- assert_response_has_tag 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
981
+ get '/haml/form_tag'
982
+ assert_response_has_tag 'form.advanced-form input[type=image]', count: 1, src: "/images/buttons/submit.png?#{@stamp}"
983
983
  end
984
984
 
985
985
  it 'should display image submit tag in slim' do
986
- get "/slim/form_tag"
987
- assert_response_has_tag 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
986
+ get '/slim/form_tag'
987
+ assert_response_has_tag 'form.advanced-form input[type=image]', count: 1, src: "/images/buttons/submit.png?#{@stamp}"
988
988
  end
989
989
  end
990
990
 
991
991
  describe 'for #button_to method' do
992
992
  it 'should have a form and set the method properly' do
993
- actual_html = button_to('Delete', '/users/1', :method => :delete)
994
- assert_html_has_tag(actual_html, 'form', :action => '/users/1')
995
- assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'delete')
996
- assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "authenticity_token")
993
+ actual_html = button_to('Delete', '/users/1', method: :delete)
994
+ assert_html_has_tag(actual_html, 'form', action: '/users/1')
995
+ assert_html_has_tag(actual_html, 'form input', type: 'hidden', name: '_method', value: 'delete')
996
+ assert_html_has_tag(actual_html, 'form input', type: 'hidden', name: 'authenticity_token')
997
997
  end
998
998
 
999
999
  it 'should add a submit button by default if no content is specified' do
1000
- actual_html = button_to('My Delete Button', '/users/1', :method => :delete)
1001
- assert_html_has_tag(actual_html, 'form input', :type => 'submit', :value => 'My Delete Button')
1000
+ actual_html = button_to('My Delete Button', '/users/1', method: :delete)
1001
+ assert_html_has_tag(actual_html, 'form input', type: 'submit', value: 'My Delete Button')
1002
1002
  end
1003
1003
 
1004
1004
  it 'should set specific content inside the form if a block was sent' do
1005
- actual_html = button_to('My Delete Button', '/users/1', :method => :delete) do
1006
- content_tag :button, "My button's content", :type => :submit, :title => "My button"
1005
+ actual_html = button_to('My Delete Button', '/users/1', method: :delete) do
1006
+ content_tag :button, "My button's content", type: :submit, title: 'My button'
1007
1007
  end
1008
- assert_html_has_tag(actual_html, 'form button', :type => 'submit', :content => "My button's content", :title => "My button")
1008
+ assert_html_has_tag(actual_html, 'form button', type: 'submit', content: "My button's content", title: 'My button')
1009
1009
  end
1010
1010
 
1011
1011
  it 'should pass options on submit button when submit_options are given' do
1012
- actual_html = button_to("Fancy button", '/users/1', :submit_options => { :class => :fancy })
1013
- assert_html_has_tag(actual_html, 'form input', :type => 'submit', :value => 'Fancy button', :class => 'fancy')
1014
- assert_html_has_no_tag(actual_html, 'form', :"submit_options-class" => 'fancy')
1012
+ actual_html = button_to('Fancy button', '/users/1', submit_options: { class: :fancy })
1013
+ assert_html_has_tag(actual_html, 'form input', type: 'submit', value: 'Fancy button', class: 'fancy')
1014
+ assert_html_has_no_tag(actual_html, 'form', "submit_options-class": 'fancy')
1015
1015
  end
1016
1016
 
1017
1017
  it 'should display correct button_to in erb' do
1018
- get "/erb/button_to"
1019
- assert_response_has_tag('form', :action => '/foo')
1020
- assert_response_has_tag('form button label', :for => 'username', :content => 'Username: ')
1021
- assert_response_has_tag('form', :action => '/bar')
1022
- assert_response_has_tag('#test-point ~ form > input[type=submit]', :value => 'Bar button')
1018
+ get '/erb/button_to'
1019
+ assert_response_has_tag('form', action: '/foo')
1020
+ assert_response_has_tag('form button label', for: 'username', content: 'Username: ')
1021
+ assert_response_has_tag('form', action: '/bar')
1022
+ assert_response_has_tag('#test-point ~ form > input[type=submit]', value: 'Bar button')
1023
1023
  end
1024
1024
 
1025
1025
  it 'should display correct button_to in haml' do
1026
- get "/haml/button_to"
1027
- assert_response_has_tag('form', :action => '/foo')
1028
- assert_response_has_tag('form button label', :for => 'username', :content => 'Username: ')
1029
- assert_response_has_tag('form', :action => '/bar')
1030
- assert_response_has_tag('#test-point ~ form > input[type=submit]', :value => 'Bar button')
1026
+ get '/haml/button_to'
1027
+ assert_response_has_tag('form', action: '/foo')
1028
+ assert_response_has_tag('form button label', for: 'username', content: 'Username: ')
1029
+ assert_response_has_tag('form', action: '/bar')
1030
+ assert_response_has_tag('#test-point ~ form > input[type=submit]', value: 'Bar button')
1031
1031
  end
1032
1032
 
1033
1033
  it 'should display correct button_to in slim' do
1034
- get "/slim/button_to"
1035
- assert_response_has_tag('form', :action => '/foo')
1036
- assert_response_has_tag('form button label', :for => 'username', :content => 'Username: ')
1037
- assert_response_has_tag('form', :action => '/bar')
1038
- assert_response_has_tag('#test-point ~ form > input[type=submit]', :value => 'Bar button')
1034
+ get '/slim/button_to'
1035
+ assert_response_has_tag('form', action: '/foo')
1036
+ assert_response_has_tag('form button label', for: 'username', content: 'Username: ')
1037
+ assert_response_has_tag('form', action: '/bar')
1038
+ assert_response_has_tag('#test-point ~ form > input[type=submit]', value: 'Bar button')
1039
1039
  end
1040
1040
  end
1041
1041
 
1042
1042
  describe 'for #range_field_tag' do
1043
1043
  it 'should create an input tag with min and max options' do
1044
- actual_html = range_field_tag('ranger', :min => 20, :max => 50)
1045
- assert_html_has_tag(actual_html, 'input', :type => 'range', :name => 'ranger', :min => '20', :max => '50')
1044
+ actual_html = range_field_tag('ranger', min: 20, max: 50)
1045
+ assert_html_has_tag(actual_html, 'input', type: 'range', name: 'ranger', min: '20', max: '50')
1046
1046
  end
1047
1047
 
1048
1048
  it 'should create an input tag with range' do
1049
- actual_html = range_field_tag('ranger', :range => 1..20)
1050
- assert_html_has_tag(actual_html, 'input', :min => '1', :max => '20')
1049
+ actual_html = range_field_tag('ranger', range: 1..20)
1050
+ assert_html_has_tag(actual_html, 'input', min: '1', max: '20')
1051
1051
  end
1052
1052
 
1053
1053
  it 'should display correct range_field_tag in erb' do
1054
- get "/erb/form_tag"
1055
- assert_response_has_tag 'input', :type => 'range', :name => 'ranger_with_min_max', :min => '1', :max => '50', :count => 1
1056
- assert_response_has_tag 'input', :type => 'range', :name => 'ranger_with_range', :min => '1', :max => '5', :count => 1
1054
+ get '/erb/form_tag'
1055
+ assert_response_has_tag 'input', type: 'range', name: 'ranger_with_min_max', min: '1', max: '50', count: 1
1056
+ assert_response_has_tag 'input', type: 'range', name: 'ranger_with_range', min: '1', max: '5', count: 1
1057
1057
  end
1058
1058
 
1059
1059
  it 'should display correct range_field_tag in haml' do
1060
- get "/haml/form_tag"
1061
- assert_response_has_tag 'input', :type => 'range', :name => 'ranger_with_min_max', :min => '1', :max => '50', :count => 1
1062
- assert_response_has_tag 'input', :type => 'range', :name => 'ranger_with_range', :min => '1', :max => '5', :count => 1
1060
+ get '/haml/form_tag'
1061
+ assert_response_has_tag 'input', type: 'range', name: 'ranger_with_min_max', min: '1', max: '50', count: 1
1062
+ assert_response_has_tag 'input', type: 'range', name: 'ranger_with_range', min: '1', max: '5', count: 1
1063
1063
  end
1064
1064
 
1065
1065
  it 'should display correct range_field_tag in slim' do
1066
- get "/slim/form_tag"
1067
- assert_response_has_tag 'input', :type => 'range', :name => 'ranger_with_min_max', :min => '1', :max => '50', :count => 1
1068
- assert_response_has_tag 'input', :type => 'range', :name => 'ranger_with_range', :min => '1', :max => '5', :count => 1
1066
+ get '/slim/form_tag'
1067
+ assert_response_has_tag 'input', type: 'range', name: 'ranger_with_min_max', min: '1', max: '50', count: 1
1068
+ assert_response_has_tag 'input', type: 'range', name: 'ranger_with_range', min: '1', max: '5', count: 1
1069
1069
  end
1070
1070
  end
1071
1071
 
1072
1072
  describe 'for #datetime_field_tag' do
1073
1073
  before do
1074
1074
  @expected = {
1075
- :name => 'datetime',
1076
- :max => "2000-04-01T12:00:00.000+0000",
1077
- :min => "1993-02-24T12:30:45.000+0000",
1078
- :value => "2000-04-01T12:00:00.000+0000"
1075
+ name: 'datetime',
1076
+ max: '2000-04-01T12:00:00.000+0000',
1077
+ min: '1993-02-24T12:30:45.000+0000',
1078
+ value: '2000-04-01T12:00:00.000+0000'
1079
1079
  }
1080
1080
  end
1081
1081
 
@@ -1083,7 +1083,7 @@ describe "FormHelpers" do
1083
1083
  max = DateTime.new(2000, 4, 1, 12, 0, 0)
1084
1084
  min = DateTime.new(1993, 2, 24, 12, 30, 45)
1085
1085
  value = DateTime.new(2000, 4, 1, 12, 0, 0)
1086
- actual_html = datetime_field_tag('datetime', :max => max, :min => min, :value => value)
1086
+ actual_html = datetime_field_tag('datetime', max: max, min: min, value: value)
1087
1087
  assert_html_has_tag(actual_html, 'input', @expected)
1088
1088
  end
1089
1089
 
@@ -1093,22 +1093,22 @@ describe "FormHelpers" do
1093
1093
  end
1094
1094
 
1095
1095
  it 'should create an input tag when the format string passed as datetime option value' do
1096
- actual_html = datetime_field_tag('datetime', :value => '1993-02-24T12:30:45+00:00')
1097
- assert_html_has_tag(actual_html, 'input[type=datetime]', :value => "1993-02-24T12:30:45.000+0000")
1096
+ actual_html = datetime_field_tag('datetime', value: '1993-02-24T12:30:45+00:00')
1097
+ assert_html_has_tag(actual_html, 'input[type=datetime]', value: '1993-02-24T12:30:45.000+0000')
1098
1098
  end
1099
1099
 
1100
1100
  it 'should display correct datetime_field_tag in erb' do
1101
- get "/erb/form_tag"
1101
+ get '/erb/form_tag'
1102
1102
  assert_response_has_tag 'input', @expected
1103
1103
  end
1104
1104
 
1105
1105
  it 'should display correct datetime_field_tag in haml' do
1106
- get "/haml/form_tag"
1106
+ get '/haml/form_tag'
1107
1107
  assert_response_has_tag 'input', @expected
1108
1108
  end
1109
1109
 
1110
1110
  it 'should display correct datetime_field_tag in slim' do
1111
- get "/slim/form_tag"
1111
+ get '/slim/form_tag'
1112
1112
  assert_response_has_tag 'input', @expected
1113
1113
  end
1114
1114
  end
@@ -1116,10 +1116,10 @@ describe "FormHelpers" do
1116
1116
  describe 'for #datetime_local_field_tag' do
1117
1117
  before do
1118
1118
  @expected = {
1119
- :name => 'datetime_local',
1120
- :max => "2000-04-01T12:00:00",
1121
- :min => "1993-02-24T12:30:45",
1122
- :value => "2000-04-01T12:00:00"
1119
+ name: 'datetime_local',
1120
+ max: '2000-04-01T12:00:00',
1121
+ min: '1993-02-24T12:30:45',
1122
+ value: '2000-04-01T12:00:00'
1123
1123
  }
1124
1124
  end
1125
1125
 
@@ -1127,7 +1127,7 @@ describe "FormHelpers" do
1127
1127
  max = DateTime.new(2000, 4, 1, 12, 0, 0)
1128
1128
  min = DateTime.new(1993, 2, 24, 12, 30, 45)
1129
1129
  value = DateTime.new(2000, 4, 1, 12, 0, 0)
1130
- actual_html = datetime_local_field_tag('datetime_local', :max => max, :min => min, :value => value)
1130
+ actual_html = datetime_local_field_tag('datetime_local', max: max, min: min, value: value)
1131
1131
  assert_html_has_tag(actual_html, 'input', @expected)
1132
1132
  end
1133
1133
 
@@ -1137,22 +1137,22 @@ describe "FormHelpers" do
1137
1137
  end
1138
1138
 
1139
1139
  it 'should create an input tag when the format string passed as datetime-local option value' do
1140
- actual_html = datetime_local_field_tag('datetime_local', :value => '1993-02-24T12:30:45')
1141
- assert_html_has_tag(actual_html, 'input[type="datetime-local"]', :value => "1993-02-24T12:30:45")
1140
+ actual_html = datetime_local_field_tag('datetime_local', value: '1993-02-24T12:30:45')
1141
+ assert_html_has_tag(actual_html, 'input[type="datetime-local"]', value: '1993-02-24T12:30:45')
1142
1142
  end
1143
1143
 
1144
1144
  it 'should display correct datetime_local_field_tag in erb' do
1145
- get "/erb/form_tag"
1145
+ get '/erb/form_tag'
1146
1146
  assert_response_has_tag 'input', @expected
1147
1147
  end
1148
1148
 
1149
1149
  it 'should display correct datetime_local_field_tag in haml' do
1150
- get "/haml/form_tag"
1150
+ get '/haml/form_tag'
1151
1151
  assert_response_has_tag 'input', @expected
1152
1152
  end
1153
1153
 
1154
1154
  it 'should display correct datetime_local_field_tag in slim' do
1155
- get "/slim/form_tag"
1155
+ get '/slim/form_tag'
1156
1156
  assert_response_has_tag 'input', @expected
1157
1157
  end
1158
1158
  end
@@ -1160,10 +1160,10 @@ describe "FormHelpers" do
1160
1160
  describe 'for #date_field_tag' do
1161
1161
  before do
1162
1162
  @expected = {
1163
- :name => 'date',
1164
- :max => "2000-04-01",
1165
- :min => "1993-02-24",
1166
- :value => "2000-04-01"
1163
+ name: 'date',
1164
+ max: '2000-04-01',
1165
+ min: '1993-02-24',
1166
+ value: '2000-04-01'
1167
1167
  }
1168
1168
  end
1169
1169
 
@@ -1171,7 +1171,7 @@ describe "FormHelpers" do
1171
1171
  max = DateTime.new(2000, 4, 1)
1172
1172
  min = DateTime.new(1993, 2, 24)
1173
1173
  value = DateTime.new(2000, 4, 1)
1174
- actual_html = date_field_tag('date', :max => max, :min => min, :value => value)
1174
+ actual_html = date_field_tag('date', max: max, min: min, value: value)
1175
1175
  assert_html_has_tag(actual_html, 'input', @expected)
1176
1176
  end
1177
1177
 
@@ -1181,22 +1181,22 @@ describe "FormHelpers" do
1181
1181
  end
1182
1182
 
1183
1183
  it 'should create an input tag when the format string passed as date option value' do
1184
- actual_html = date_field_tag('date', :value => '1993-02-24')
1185
- assert_html_has_tag(actual_html, 'input[type="date"]', :value => "1993-02-24")
1184
+ actual_html = date_field_tag('date', value: '1993-02-24')
1185
+ assert_html_has_tag(actual_html, 'input[type="date"]', value: '1993-02-24')
1186
1186
  end
1187
1187
 
1188
1188
  it 'should display correct date_field_tag in erb' do
1189
- get "/erb/form_tag"
1189
+ get '/erb/form_tag'
1190
1190
  assert_response_has_tag 'input', @expected
1191
1191
  end
1192
1192
 
1193
1193
  it 'should display correct date_field_tag in haml' do
1194
- get "/haml/form_tag"
1194
+ get '/haml/form_tag'
1195
1195
  assert_response_has_tag 'input', @expected
1196
1196
  end
1197
1197
 
1198
1198
  it 'should display correct date_field_tag in slim' do
1199
- get "/slim/form_tag"
1199
+ get '/slim/form_tag'
1200
1200
  assert_response_has_tag 'input', @expected
1201
1201
  end
1202
1202
  end
@@ -1204,10 +1204,10 @@ describe "FormHelpers" do
1204
1204
  describe 'for #month_field_tag' do
1205
1205
  before do
1206
1206
  @expected = {
1207
- :name => 'month',
1208
- :max => "2000-04",
1209
- :min => "1993-02",
1210
- :value => "2000-04"
1207
+ name: 'month',
1208
+ max: '2000-04',
1209
+ min: '1993-02',
1210
+ value: '2000-04'
1211
1211
  }
1212
1212
  end
1213
1213
 
@@ -1215,7 +1215,7 @@ describe "FormHelpers" do
1215
1215
  max = DateTime.new(2000, 4, 1)
1216
1216
  min = DateTime.new(1993, 2, 24)
1217
1217
  value = DateTime.new(2000, 4, 1)
1218
- actual_html = month_field_tag('month', :max => max, :min => min, :value => value)
1218
+ actual_html = month_field_tag('month', max: max, min: min, value: value)
1219
1219
  assert_html_has_tag(actual_html, 'input', @expected)
1220
1220
  end
1221
1221
 
@@ -1225,22 +1225,22 @@ describe "FormHelpers" do
1225
1225
  end
1226
1226
 
1227
1227
  it 'should create an input tag when the format string passed as month option value' do
1228
- actual_html = month_field_tag('month', :value => '1993-02-24')
1229
- assert_html_has_tag(actual_html, 'input[type="month"]', :value => "1993-02")
1228
+ actual_html = month_field_tag('month', value: '1993-02-24')
1229
+ assert_html_has_tag(actual_html, 'input[type="month"]', value: '1993-02')
1230
1230
  end
1231
1231
 
1232
1232
  it 'should display correct month_field_tag in erb' do
1233
- get "/erb/form_tag"
1233
+ get '/erb/form_tag'
1234
1234
  assert_response_has_tag 'input', @expected
1235
1235
  end
1236
1236
 
1237
1237
  it 'should display correct month_field_tag in haml' do
1238
- get "/haml/form_tag"
1238
+ get '/haml/form_tag'
1239
1239
  assert_response_has_tag 'input', @expected
1240
1240
  end
1241
1241
 
1242
1242
  it 'should display correct month_field_tag in slim' do
1243
- get "/slim/form_tag"
1243
+ get '/slim/form_tag'
1244
1244
  assert_response_has_tag 'input', @expected
1245
1245
  end
1246
1246
  end
@@ -1248,10 +1248,10 @@ describe "FormHelpers" do
1248
1248
  describe 'for #week_field_tag' do
1249
1249
  before do
1250
1250
  @expected = {
1251
- :name => 'week',
1252
- :max => "2000-W13",
1253
- :min => "1993-W08",
1254
- :value => "2000-W13"
1251
+ name: 'week',
1252
+ max: '2000-W13',
1253
+ min: '1993-W08',
1254
+ value: '2000-W13'
1255
1255
  }
1256
1256
  end
1257
1257
 
@@ -1259,7 +1259,7 @@ describe "FormHelpers" do
1259
1259
  max = DateTime.new(2000, 4, 1)
1260
1260
  min = DateTime.new(1993, 2, 24)
1261
1261
  value = DateTime.new(2000, 4, 1)
1262
- actual_html = week_field_tag('week', :max => max, :min => min, :value => value)
1262
+ actual_html = week_field_tag('week', max: max, min: min, value: value)
1263
1263
  assert_html_has_tag(actual_html, 'input', @expected)
1264
1264
  end
1265
1265
 
@@ -1269,22 +1269,22 @@ describe "FormHelpers" do
1269
1269
  end
1270
1270
 
1271
1271
  it 'should create an input tag when the format string passed as week option value' do
1272
- actual_html = week_field_tag('week', :value => '1993-02-24')
1273
- assert_html_has_tag(actual_html, 'input[type="week"]', :value => "1993-W08")
1272
+ actual_html = week_field_tag('week', value: '1993-02-24')
1273
+ assert_html_has_tag(actual_html, 'input[type="week"]', value: '1993-W08')
1274
1274
  end
1275
1275
 
1276
1276
  it 'should display correct week_field_tag in erb' do
1277
- get "/erb/form_tag"
1277
+ get '/erb/form_tag'
1278
1278
  assert_response_has_tag 'input', @expected
1279
1279
  end
1280
1280
 
1281
1281
  it 'should display correct week_field_tag in haml' do
1282
- get "/haml/form_tag"
1282
+ get '/haml/form_tag'
1283
1283
  assert_response_has_tag 'input', @expected
1284
1284
  end
1285
1285
 
1286
1286
  it 'should display correct week_field_tag in slim' do
1287
- get "/slim/form_tag"
1287
+ get '/slim/form_tag'
1288
1288
  assert_response_has_tag 'input', @expected
1289
1289
  end
1290
1290
  end
@@ -1292,10 +1292,10 @@ describe "FormHelpers" do
1292
1292
  describe 'for #time_field_tag' do
1293
1293
  before do
1294
1294
  @expected = {
1295
- :name => 'time',
1296
- :max => "13:30:00.000",
1297
- :min => "01:19:12.000",
1298
- :value => "13:30:00.000"
1295
+ name: 'time',
1296
+ max: '13:30:00.000',
1297
+ min: '01:19:12.000',
1298
+ value: '13:30:00.000'
1299
1299
  }
1300
1300
  end
1301
1301
 
@@ -1303,7 +1303,7 @@ describe "FormHelpers" do
1303
1303
  max = Time.new(2008, 6, 21, 13, 30, 0)
1304
1304
  min = Time.new(1993, 2, 24, 1, 19, 12)
1305
1305
  value = Time.new(2008, 6, 21, 13, 30, 0)
1306
- actual_html = time_field_tag('time', :max => max, :min => min, :value => value)
1306
+ actual_html = time_field_tag('time', max: max, min: min, value: value)
1307
1307
  assert_html_has_tag(actual_html, 'input', @expected)
1308
1308
  end
1309
1309
 
@@ -1313,22 +1313,22 @@ describe "FormHelpers" do
1313
1313
  end
1314
1314
 
1315
1315
  it 'should create an input tag when the format string passed as time option value' do
1316
- actual_html = time_field_tag('time', :value => '1993-02-24 01:19:12')
1317
- assert_html_has_tag(actual_html, 'input[type="time"]', :value => "01:19:12.000")
1316
+ actual_html = time_field_tag('time', value: '1993-02-24 01:19:12')
1317
+ assert_html_has_tag(actual_html, 'input[type="time"]', value: '01:19:12.000')
1318
1318
  end
1319
1319
 
1320
1320
  it 'should display correct time_field_tag in erb' do
1321
- get "/erb/form_tag"
1321
+ get '/erb/form_tag'
1322
1322
  assert_response_has_tag 'input', @expected
1323
1323
  end
1324
1324
 
1325
1325
  it 'should display correct time_field_tag in haml' do
1326
- get "/haml/form_tag"
1326
+ get '/haml/form_tag'
1327
1327
  assert_response_has_tag 'input', @expected
1328
1328
  end
1329
1329
 
1330
1330
  it 'should display correct time_field_tag in slim' do
1331
- get "/slim/form_tag"
1331
+ get '/slim/form_tag'
1332
1332
  assert_response_has_tag 'input', @expected
1333
1333
  end
1334
1334
  end
@@ -1336,33 +1336,33 @@ describe "FormHelpers" do
1336
1336
  describe 'for #color_field_tag' do
1337
1337
  before do
1338
1338
  @expected = {
1339
- :name => 'color',
1340
- :value => '#ff0000'
1339
+ name: 'color',
1340
+ value: '#ff0000'
1341
1341
  }
1342
1342
  end
1343
1343
 
1344
1344
  it 'should create an input tag with value option' do
1345
- actual_html = color_field_tag('color', :value => "#ff0000")
1345
+ actual_html = color_field_tag('color', value: '#ff0000')
1346
1346
  assert_html_has_tag(actual_html, 'input[type="color"]', @expected)
1347
1347
  end
1348
1348
 
1349
1349
  it 'should create an input tag with short color code' do
1350
- actual_html = color_field_tag('color', :value => "#f00")
1350
+ actual_html = color_field_tag('color', value: '#f00')
1351
1351
  assert_html_has_tag(actual_html, 'input[type="color"]', @expected)
1352
1352
  end
1353
1353
 
1354
1354
  it 'should display correct color_field_tag in erb' do
1355
- get "/erb/form_tag"
1355
+ get '/erb/form_tag'
1356
1356
  assert_response_has_tag 'input', @expected
1357
1357
  end
1358
1358
 
1359
1359
  it 'should display correct color_field_tag in haml' do
1360
- get "/haml/form_tag"
1360
+ get '/haml/form_tag'
1361
1361
  assert_response_has_tag 'input', @expected
1362
1362
  end
1363
1363
 
1364
1364
  it 'should display correct color_field_tag in slim' do
1365
- get "/slim/form_tag"
1365
+ get '/slim/form_tag'
1366
1366
  assert_response_has_tag 'input', @expected
1367
1367
  end
1368
1368
  end