padrino-helpers 0.12.8.1 → 0.12.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +13 -5
  2. data/Rakefile +1 -5
  3. data/lib/padrino-helpers.rb +2 -1
  4. data/lib/padrino-helpers/asset_tag_helpers.rb +16 -4
  5. data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +39 -1
  6. data/lib/padrino-helpers/form_builder/standard_form_builder.rb +1 -1
  7. data/lib/padrino-helpers/form_helpers.rb +220 -1
  8. data/lib/padrino-helpers/form_helpers/options.rb +7 -5
  9. data/lib/padrino-helpers/output_helpers.rb +1 -1
  10. data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
  11. data/lib/padrino-helpers/output_helpers/erb_handler.rb +2 -1
  12. data/lib/padrino-helpers/render_helpers.rb +23 -2
  13. data/lib/padrino-helpers/tag_helpers.rb +13 -0
  14. data/lib/padrino/rendering.rb +2 -1
  15. data/lib/padrino/rendering/erb_template.rb +12 -0
  16. data/lib/padrino/rendering/erubis_template.rb +1 -1
  17. data/padrino-helpers.gemspec +1 -1
  18. data/test/fixtures/markup_app/views/form_for.erb +28 -0
  19. data/test/fixtures/markup_app/views/form_for.haml +22 -0
  20. data/test/fixtures/markup_app/views/form_for.slim +21 -0
  21. data/test/fixtures/markup_app/views/form_tag.erb +21 -0
  22. data/test/fixtures/markup_app/views/form_tag.haml +14 -0
  23. data/test/fixtures/markup_app/views/form_tag.slim +14 -0
  24. data/test/helper.rb +14 -68
  25. data/test/test_asset_tag_helpers.rb +106 -93
  26. data/test/test_form_builder.rb +691 -450
  27. data/test/test_form_helpers.rb +770 -457
  28. data/test/test_format_helpers.rb +17 -37
  29. data/test/test_helpers.rb +8 -0
  30. data/test/test_output_helpers.rb +72 -72
  31. data/test/test_render_helpers.rb +142 -100
  32. data/test/test_rendering.rb +30 -6
  33. data/test/test_tag_helpers.rb +41 -39
  34. metadata +37 -23
@@ -31,33 +31,33 @@ describe "FormBuilder" do
31
31
  describe 'for #form_for method' do
32
32
  it 'should display correct form html' do
33
33
  actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { "Demo" }
34
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post', :content => "Demo") { actual_html }
35
- assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
34
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post', :content => "Demo")
35
+ assert_html_has_tag(actual_html, 'form input[type=hidden]', :name => '_method', :count => 0) # no method action field
36
36
  end
37
37
 
38
38
  it 'should display correct form html with fake object' do
39
39
  actual_html = form_for(:markup_user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
40
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post') { actual_html }
41
- assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
42
- assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
40
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post')
41
+ assert_html_has_tag(actual_html, 'form input', :type => 'text', :name => 'markup_user[username]')
42
+ assert_html_has_tag(actual_html, 'form input[type=hidden]', :name => '_method', :count => 0) # no method action field
43
43
  end
44
44
 
45
45
  it 'should display correct form html for namespaced object' do
46
46
  actual_html = form_for(Outer::UserAccount.new, '/register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
47
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
48
- assert_has_tag('form input', :type => 'text', :name => 'outer_user_account[username]') { actual_html }
47
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post')
48
+ assert_html_has_tag(actual_html, 'form input', :type => 'text', :name => 'outer_user_account[username]')
49
49
  end
50
50
 
51
51
  it 'should display form specifying default builder setting' do
52
52
  self.expects(:settings).returns(stub(:default_builder => 'FakeFormBuilder', :protect_from_csrf => false)).at_least_once
53
53
  actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.foo_field }
54
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
55
- assert_has_tag('span', :content => "bar") { actual_html }
54
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post')
55
+ assert_html_has_tag(actual_html, 'span', :content => "bar")
56
56
  end
57
57
 
58
58
  it 'should display correct form html with remote option' do
59
59
  actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true) { "Demo" }
60
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true') { actual_html }
60
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true')
61
61
  end
62
62
 
63
63
  it 'should display correct form html with namespace option' do
@@ -65,9 +65,9 @@ describe "FormBuilder" do
65
65
  f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
66
66
  end
67
67
 
68
- assert_has_no_tag(:form, :namespace => 'foo') { actual_html }
69
- assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'foo_user_first_name') { actual_html }
70
- assert_has_tag(:input, :type => 'text', :name => 'user[role_types_attributes][0][name]', :id => 'foo_user_role_types_attributes_0_name') { actual_html }
68
+ assert_html_has_no_tag(actual_html, :form, :namespace => 'foo')
69
+ assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'foo_user_first_name')
70
+ assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[role_types_attributes][0][name]', :id => 'foo_user_role_types_attributes_0_name')
71
71
  end
72
72
 
73
73
  it 'should display correct form html with :as option' do
@@ -75,32 +75,32 @@ describe "FormBuilder" do
75
75
  f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
76
76
  end
77
77
 
78
- assert_has_no_tag(:form, :as => 'customer') { actual_html }
79
- assert_has_tag(:input, :type => 'text', :name => 'customer[first_name]', :id => 'customer_first_name') { actual_html }
80
- assert_has_tag(:input, :type => 'text', :name => 'customer[role_types_attributes][0][name]', :id => 'customer_role_types_attributes_0_name') { actual_html }
78
+ assert_html_has_no_tag(actual_html, :form, :as => 'customer')
79
+ assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'customer[first_name]', :id => 'customer_first_name')
80
+ assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'customer[role_types_attributes][0][name]', :id => 'customer_role_types_attributes_0_name')
81
81
  end
82
82
 
83
83
  it 'should display correct form html with remote option and method put' do
84
84
  actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true, :method => 'put') { "Demo" }
85
- assert_has_tag('form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true') { actual_html }
86
- assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
85
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true')
86
+ assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'put')
87
87
  end
88
88
 
89
89
  it 'should display correct form html with method :put' do
90
90
  actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :method => 'put') { "Demo" }
91
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post') { actual_html }
92
- assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
91
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post')
92
+ assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'put')
93
93
  end
94
94
 
95
95
  it 'should display correct form html with method :delete' do
96
96
  actual_html = form_for(@user, '/destroy', :"accept-charset" => "UTF-8", :method => 'delete') { "Demo" }
97
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/destroy', :method => 'post') { actual_html }
98
- assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
97
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/destroy', :method => 'post')
98
+ assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'delete')
99
99
  end
100
100
 
101
101
  it 'should display correct form html with multipart' do
102
102
  actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
103
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
103
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
104
104
  end
105
105
 
106
106
  it 'should support changing form builder type' do
@@ -110,7 +110,7 @@ describe "FormBuilder" do
110
110
 
111
111
  it 'should support using default standard builder' do
112
112
  actual_html = form_for(@user, '/register') { |f| f.text_field_block(:name) }
113
- assert_has_tag('form p input[type=text]') { actual_html }
113
+ assert_html_has_tag(actual_html, 'form p input[type=text]')
114
114
  end
115
115
 
116
116
  it 'should display fail for form with nil object' do
@@ -118,49 +118,49 @@ describe "FormBuilder" do
118
118
  end
119
119
 
120
120
  it 'should display correct form in haml' do
121
- visit '/haml/form_for'
122
- assert_have_selector :form, :action => '/demo', :id => 'demo'
123
- assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
124
- assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
125
- assert_have_selector :input, :name => 'authenticity_token'
121
+ get "/haml/form_for"
122
+ assert_response_has_tag :form, :action => '/demo', :id => 'demo'
123
+ assert_response_has_tag :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
124
+ assert_response_has_tag :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
125
+ assert_response_has_tag :input, :name => 'authenticity_token'
126
126
  end
127
127
 
128
128
  it 'should display correct form in erb' do
129
- visit '/erb/form_for'
130
- assert_have_selector :form, :action => '/demo', :id => 'demo'
131
- assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
132
- assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
133
- assert_have_selector :input, :name => 'authenticity_token'
129
+ get "/erb/form_for"
130
+ assert_response_has_tag :form, :action => '/demo', :id => 'demo'
131
+ assert_response_has_tag :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
132
+ assert_response_has_tag :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
133
+ assert_response_has_tag :input, :name => 'authenticity_token'
134
134
  end
135
135
 
136
136
  it 'should display correct form in slim' do
137
- visit '/slim/form_for'
138
- assert_have_selector :form, :action => '/demo', :id => 'demo'
139
- assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
140
- assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
141
- assert_have_selector :input, :name => 'authenticity_token'
137
+ get "/slim/form_for"
138
+ assert_response_has_tag :form, :action => '/demo', :id => 'demo'
139
+ assert_response_has_tag :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
140
+ assert_response_has_tag :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
141
+ assert_response_has_tag :input, :name => 'authenticity_token'
142
142
  end
143
143
 
144
144
  it 'should have a class of "invalid" for fields with errors' do
145
145
  actual_html = form_for(@user, '/register') {|f| f.text_field(:email) }
146
- assert_has_tag(:input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid') {actual_html }
146
+ assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid')
147
147
  end
148
148
 
149
149
  it 'should not have a class of "invalid" for fields with no errors' do
150
150
  actual_html = form_for(@user, '/register') {|f| f.text_field(:first_name) }
151
- assert_has_no_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid') {actual_html }
151
+ assert_html_has_no_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid')
152
152
  end
153
153
  end
154
154
 
155
155
  describe 'for #fields_for method' do
156
156
  it 'should display correct fields html' do
157
157
  actual_html = fields_for(@user) { |f| f.text_field(:first_name) }
158
- assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name') { actual_html }
158
+ assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name')
159
159
  end
160
160
 
161
161
  it 'should display correct fields html with symbol object' do
162
162
  actual_html = fields_for(:markup_user) { |f| f.text_field(:first_name) }
163
- assert_has_tag(:input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name') { actual_html }
163
+ assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name')
164
164
  end
165
165
 
166
166
  it 'should display fail for nil object' do
@@ -178,27 +178,27 @@ describe "FormBuilder" do
178
178
  end
179
179
 
180
180
  it 'should display correct simple fields in haml' do
181
- visit '/haml/fields_for'
182
- assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
183
- assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
184
- assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
185
- assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
181
+ get "/haml/fields_for"
182
+ assert_response_has_tag :form, :action => '/demo1', :id => 'demo-fields-for'
183
+ assert_response_has_tag '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
184
+ assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
185
+ assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
186
186
  end
187
187
 
188
188
  it 'should display correct simple fields in erb' do
189
- visit '/erb/fields_for'
190
- assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
191
- assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
192
- assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
193
- assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
189
+ get "/erb/fields_for"
190
+ assert_response_has_tag :form, :action => '/demo1', :id => 'demo-fields-for'
191
+ assert_response_has_tag '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
192
+ assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
193
+ assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
194
194
  end
195
195
 
196
196
  it 'should display correct simple fields in slim' do
197
- visit '/slim/fields_for'
198
- assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
199
- assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
200
- assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
201
- assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
197
+ get "/slim/fields_for"
198
+ assert_response_has_tag :form, :action => '/demo1', :id => 'demo-fields-for'
199
+ assert_response_has_tag '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
200
+ assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
201
+ assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
202
202
  end
203
203
  end
204
204
 
@@ -209,491 +209,491 @@ describe "FormBuilder" do
209
209
  describe 'for #error_messages method' do
210
210
  it 'should display correct form html with no record' do
211
211
  actual_html = standard_builder(@user_none).error_messages(:header_message => "Demo form cannot be saved")
212
- assert actual_html.blank?
212
+ assert_empty actual_html
213
213
  end
214
214
 
215
215
  it 'should display correct form html with valid record' do
216
216
  actual_html = standard_builder.error_messages(:header_message => "Demo form cannot be saved", :style => "foo:bar", :class => "mine")
217
- assert_has_tag('#field-errors h2', :content => "Demo form cannot be saved") { actual_html }
218
- assert_has_tag('#field-errors ul li', :content => "B must be valid") { actual_html }
219
- assert_has_tag('#field-errors ul li', :content => "A must be present") { actual_html }
220
- assert_has_tag('#field-errors', :style => "foo:bar") { actual_html }
221
- assert_has_tag('#field-errors', :class => "mine") { actual_html }
217
+ assert_html_has_tag(actual_html, '#field-errors h2', :content => "Demo form cannot be saved")
218
+ assert_html_has_tag(actual_html, '#field-errors ul li', :content => "B must be valid")
219
+ assert_html_has_tag(actual_html, '#field-errors ul li', :content => "A must be present")
220
+ assert_html_has_tag(actual_html, '#field-errors', :style => "foo:bar")
221
+ assert_html_has_tag(actual_html, '#field-errors', :class => "mine")
222
222
  end
223
223
 
224
224
  it 'should display correct form in haml' do
225
- visit '/haml/form_for'
226
- assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
227
- assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
228
- assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
229
- assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
230
- assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
231
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
232
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
233
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
234
- assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
225
+ get "/haml/form_for"
226
+ assert_response_has_tag '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
227
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Fake must be valid"
228
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Second must be present"
229
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Third must be a number"
230
+ assert_response_has_tag '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
231
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Fake must be valid"
232
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Second must be present"
233
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Third must be a number"
234
+ assert_response_has_tag '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
235
235
  end
236
236
 
237
237
  it 'should display correct form in erb' do
238
- visit '/erb/form_for'
239
- assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
240
- assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
241
- assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
242
- assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
243
- assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
244
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
245
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
246
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
247
- assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
238
+ get "/erb/form_for"
239
+ assert_response_has_tag '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
240
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Fake must be valid"
241
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Second must be present"
242
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Third must be a number"
243
+ assert_response_has_tag '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
244
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Fake must be valid"
245
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Second must be present"
246
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Third must be a number"
247
+ assert_response_has_tag '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
248
248
  end
249
249
 
250
250
  it 'should display correct form in slim' do
251
- visit '/slim/form_for'
252
- assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
253
- assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
254
- assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
255
- assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
256
- assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
257
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
258
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
259
- assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
260
- assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
251
+ get "/slim/form_for"
252
+ assert_response_has_tag '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
253
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Fake must be valid"
254
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Second must be present"
255
+ assert_response_has_tag '#demo div.field-errors ul li', :content => "Third must be a number"
256
+ assert_response_has_tag '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
257
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Fake must be valid"
258
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Second must be present"
259
+ assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Third must be a number"
260
+ assert_response_has_tag '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
261
261
  end
262
262
  end
263
263
 
264
264
  describe 'for #error_message_on method' do
265
265
  it 'should display correct form html with no record' do
266
266
  actual_html = standard_builder(@user_none).error_message_on(:name)
267
- assert actual_html.blank?
267
+ assert_empty actual_html
268
268
  end
269
269
 
270
270
  it 'should display error for specified invalid object' do
271
271
  actual_html = standard_builder(@user).error_message_on(:a, :prepend => "foo", :append => "bar")
272
- assert_has_tag('span.error', :content => "foo must be present bar") { actual_html }
272
+ assert_html_has_tag(actual_html, 'span.error', :content => "foo must be present bar")
273
273
  end
274
274
 
275
275
  it 'should display error for specified invalid object not matching class name' do
276
276
  @bob = mock_model("User", :first_name => "Frank", :errors => { :foo => "must be bob" })
277
277
  actual_html = standard_builder(@bob).error_message_on(:foo, :prepend => "foo", :append => "bar")
278
- assert_has_tag('span.error', :content => "foo must be bob bar") { actual_html }
278
+ assert_html_has_tag(actual_html, 'span.error', :content => "foo must be bob bar")
279
279
  end
280
280
  end
281
281
 
282
282
  describe 'for #label method' do
283
283
  it 'should display correct label html' do
284
284
  actual_html = standard_builder.label(:first_name, :class => 'large', :caption => "F. Name: ")
285
- assert_has_tag('label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ") { actual_html }
286
- assert_has_no_tag('label#user_first_name') { actual_html }
285
+ assert_html_has_tag(actual_html, 'label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ")
286
+ assert_html_has_no_tag(actual_html, 'label#user_first_name')
287
287
  end
288
288
 
289
289
  it 'should set specific content inside the label if a block was provided' do
290
290
  actual_html = standard_builder.label(:admin, :class => 'large') { input_tag :checkbox }
291
- assert_has_tag('label', :class => 'large', :for => 'user_admin', :content => "Admin: ") { actual_html }
292
- assert_has_tag('label input[type=checkbox]') { actual_html }
291
+ assert_html_has_tag(actual_html, 'label', :class => 'large', :for => 'user_admin', :content => "Admin: ")
292
+ assert_html_has_tag(actual_html, 'label input[type=checkbox]')
293
293
  end
294
294
 
295
295
  it 'should display correct label in haml' do
296
- visit '/haml/form_for'
297
- assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
298
- assert_have_selector '#demo label', :content => "About Me: "
299
- assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
296
+ get "/haml/form_for"
297
+ assert_response_has_tag '#demo label', :content => "Login: ", :class => 'user-label'
298
+ assert_response_has_tag '#demo label', :content => "About Me: "
299
+ assert_response_has_tag '#demo2 label', :content => "Nickname: ", :class => 'label'
300
300
  end
301
301
 
302
302
  it 'should display correct label in erb' do
303
- visit '/erb/form_for'
304
- assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
305
- assert_have_selector '#demo label', :content => "About Me: "
306
- assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
303
+ get "/erb/form_for"
304
+ assert_response_has_tag '#demo label', :content => "Login: ", :class => 'user-label'
305
+ assert_response_has_tag '#demo label', :content => "About Me: "
306
+ assert_response_has_tag '#demo2 label', :content => "Nickname: ", :class => 'label'
307
307
  end
308
308
 
309
309
  it 'should display correct label in slim' do
310
- visit '/slim/form_for'
311
- assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
312
- assert_have_selector '#demo label', :content => "About Me: "
313
- assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
310
+ get "/slim/form_for"
311
+ assert_response_has_tag '#demo label', :content => "Login: ", :class => 'user-label'
312
+ assert_response_has_tag '#demo label', :content => "About Me: "
313
+ assert_response_has_tag '#demo2 label', :content => "Nickname: ", :class => 'label'
314
314
  end
315
315
  end
316
316
 
317
317
  describe 'for #hidden_field method' do
318
318
  it 'should display correct hidden field html' do
319
319
  actual_html = standard_builder.hidden_field(:session_id, :class => 'hidden')
320
- assert_has_tag('input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]') { actual_html }
320
+ assert_html_has_tag(actual_html, 'input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]')
321
321
  end
322
322
 
323
323
  it 'should display correct hidden field in haml' do
324
- visit '/haml/form_for'
325
- assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
326
- assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
324
+ get "/haml/form_for"
325
+ assert_response_has_tag '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
326
+ assert_response_has_tag '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
327
327
  end
328
328
 
329
329
  it 'should display correct hidden field in erb' do
330
- visit '/erb/form_for'
331
- assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
332
- assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
330
+ get "/erb/form_for"
331
+ assert_response_has_tag '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
332
+ assert_response_has_tag '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
333
333
  end
334
334
 
335
335
  it 'should display correct hidden field in slim' do
336
- visit '/slim/form_for'
337
- assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
338
- assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
336
+ get "/slim/form_for"
337
+ assert_response_has_tag '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
338
+ assert_response_has_tag '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
339
339
  end
340
340
  end
341
341
 
342
342
  describe 'for #text_field method' do
343
343
  it 'should display correct text field html' do
344
344
  actual_html = standard_builder.text_field(:first_name, :class => 'large')
345
- assert_has_tag('input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
345
+ assert_html_has_tag(actual_html, 'input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]')
346
346
  end
347
347
 
348
348
  it 'should display correct text field in haml' do
349
- visit '/haml/form_for'
350
- assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
351
- assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
349
+ get "/haml/form_for"
350
+ assert_response_has_tag '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
351
+ assert_response_has_tag '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
352
352
  end
353
353
 
354
354
  it 'should display correct text field in erb' do
355
- visit '/erb/form_for'
356
- assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
357
- assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
355
+ get "/erb/form_for"
356
+ assert_response_has_tag '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
357
+ assert_response_has_tag '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
358
358
  end
359
359
 
360
360
  it 'should display correct text field in slim' do
361
- visit '/slim/form_for'
362
- assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
363
- assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
361
+ get "/slim/form_for"
362
+ assert_response_has_tag '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
363
+ assert_response_has_tag '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
364
364
  end
365
365
  end
366
366
 
367
367
  describe 'for #number_field method' do
368
368
  it 'should display correct number field html' do
369
369
  actual_html = standard_builder.number_field(:age, :class => 'numeric')
370
- assert_has_tag('input.numeric[type=number]', :id => 'user_age', :name => 'user[age]') { actual_html }
370
+ assert_html_has_tag(actual_html, 'input.numeric[type=number]', :id => 'user_age', :name => 'user[age]')
371
371
  end
372
372
 
373
373
  it 'should display correct number field in haml' do
374
- visit '/haml/form_for'
375
- assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
374
+ get "/haml/form_for"
375
+ assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
376
376
  end
377
377
 
378
378
  it 'should display correct number field in erb' do
379
- visit '/erb/form_for'
380
- assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
379
+ get "/erb/form_for"
380
+ assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
381
381
  end
382
382
 
383
383
  it 'should display correct number field in slim' do
384
- visit '/slim/form_for'
385
- assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
384
+ get "/slim/form_for"
385
+ assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
386
386
  end
387
387
  end
388
388
 
389
389
  describe 'for #telephone_field method' do
390
390
  it 'should display correct telephone field html' do
391
391
  actual_html = standard_builder.telephone_field(:telephone, :class => 'numeric')
392
- assert_has_tag('input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]') { actual_html }
392
+ assert_html_has_tag(actual_html, 'input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]')
393
393
  end
394
394
 
395
395
  it 'should display correct telephone field in haml' do
396
- visit '/haml/form_for'
397
- assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
396
+ get "/haml/form_for"
397
+ assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
398
398
  end
399
399
 
400
400
  it 'should display correct telephone field in erb' do
401
- visit '/erb/form_for'
402
- assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
401
+ get "/erb/form_for"
402
+ assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
403
403
  end
404
404
 
405
405
  it 'should display correct telephone field in slim' do
406
- visit '/slim/form_for'
407
- assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
406
+ get "/slim/form_for"
407
+ assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
408
408
  end
409
409
  end
410
410
 
411
411
  describe 'for #search_field method' do
412
412
  it 'should display correct search field html' do
413
413
  actual_html = standard_builder.search_field(:search, :class => 'string')
414
- assert_has_tag('input.string[type=search]', :id => 'user_search', :name => 'user[search]') { actual_html }
414
+ assert_html_has_tag(actual_html, 'input.string[type=search]', :id => 'user_search', :name => 'user[search]')
415
415
  end
416
416
 
417
417
  it 'should display correct search field in haml' do
418
- visit '/haml/form_for'
419
- assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
418
+ get "/haml/form_for"
419
+ assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
420
420
  end
421
421
 
422
422
  it 'should display correct search field in erb' do
423
- visit '/erb/form_for'
424
- assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
423
+ get "/erb/form_for"
424
+ assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
425
425
  end
426
426
 
427
427
  it 'should display correct search field in slim' do
428
- visit '/slim/form_for'
429
- assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
428
+ get "/slim/form_for"
429
+ assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
430
430
  end
431
431
  end
432
432
 
433
433
  describe 'for #email_field method' do
434
434
  it 'should display correct email field html' do
435
435
  actual_html = standard_builder.email_field(:email, :class => 'string')
436
- assert_has_tag('input.string[type=email]', :id => 'user_email', :name => 'user[email]') { actual_html }
436
+ assert_html_has_tag(actual_html, 'input.string[type=email]', :id => 'user_email', :name => 'user[email]')
437
437
  end
438
438
 
439
439
  it 'should display correct email field in haml' do
440
- visit '/haml/form_for'
441
- assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
440
+ get "/haml/form_for"
441
+ assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
442
442
  end
443
443
 
444
444
  it 'should display correct email field in erb' do
445
- visit '/erb/form_for'
446
- assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
445
+ get "/erb/form_for"
446
+ assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
447
447
  end
448
448
 
449
449
  it 'should display correct email field in slim' do
450
- visit '/slim/form_for'
451
- assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
450
+ get "/slim/form_for"
451
+ assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
452
452
  end
453
453
  end
454
454
 
455
455
  describe 'for #url_field method' do
456
456
  it 'should display correct url field html' do
457
457
  actual_html = standard_builder.url_field(:webpage, :class => 'string')
458
- assert_has_tag('input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]') { actual_html }
458
+ assert_html_has_tag(actual_html, 'input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]')
459
459
  end
460
460
 
461
461
  it 'should display correct url field in haml' do
462
- visit '/haml/form_for'
463
- assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
462
+ get "/haml/form_for"
463
+ assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
464
464
  end
465
465
 
466
466
  it 'should display correct url field in erb' do
467
- visit '/erb/form_for'
468
- assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
467
+ get "/erb/form_for"
468
+ assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
469
469
  end
470
470
 
471
471
  it 'should display correct url field in slim' do
472
- visit '/slim/form_for'
473
- assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
472
+ get "/slim/form_for"
473
+ assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
474
474
  end
475
475
  end
476
476
 
477
477
  describe 'for #check_box method' do
478
478
  it 'should display correct checkbox html' do
479
479
  actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large')
480
- assert_has_tag('input.large[type=checkbox]', :id => 'user_confirm_destroy', :name => 'user[confirm_destroy]') { actual_html }
481
- assert_has_tag('input[type=hidden]', :name => 'user[confirm_destroy]', :value => '0') { actual_html }
480
+ assert_html_has_tag(actual_html, 'input.large[type=checkbox]', :id => 'user_confirm_destroy', :name => 'user[confirm_destroy]')
481
+ assert_html_has_tag(actual_html, 'input[type=hidden]', :name => 'user[confirm_destroy]', :value => '0')
482
482
  end
483
483
 
484
484
  it 'should display correct checkbox html when checked' do
485
485
  actual_html = standard_builder.check_box(:confirm_destroy, :checked => true)
486
- assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]') { actual_html }
486
+ assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]')
487
487
  end
488
488
 
489
489
  it 'should display correct checkbox html as checked when object value matches' do
490
490
  @user.stubs(:show_favorites => 'human')
491
491
  actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
492
- assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
492
+ assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]')
493
493
  end
494
494
 
495
495
  it 'should display correct checkbox html as checked when object value is true' do
496
496
  @user.stubs(:show_favorites => true)
497
497
  actual_html = standard_builder.check_box(:show_favorites, :value => '1')
498
- assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
498
+ assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]')
499
499
  end
500
500
 
501
501
  it 'should display correct checkbox html as unchecked when object value does not match' do
502
502
  @user.stubs(:show_favorites => 'alien')
503
503
  actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
504
- assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
504
+ assert_html_has_no_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
505
505
  end
506
506
 
507
507
  it 'should display correct checkbox html as unchecked when object value is false' do
508
508
  @user.stubs(:show_favorites => false)
509
509
  actual_html = standard_builder.check_box(:show_favorites, :value => '1')
510
- assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
510
+ assert_html_has_no_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
511
511
  end
512
512
 
513
513
  it 'should display correct unchecked hidden field when specified' do
514
514
  actual_html = standard_builder.check_box(:show_favorites, :value => 'female', :uncheck_value => 'false')
515
- assert_has_tag('input[type=hidden]', :name => 'user[show_favorites]', :value => 'false') { actual_html }
515
+ assert_html_has_tag(actual_html, 'input[type=hidden]', :name => 'user[show_favorites]', :value => 'false')
516
516
  end
517
517
 
518
518
  it 'should display correct checkbox in haml' do
519
- visit '/haml/form_for'
520
- assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
519
+ get "/haml/form_for"
520
+ assert_response_has_tag '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
521
521
  end
522
522
 
523
523
  it 'should display correct checkbox in erb' do
524
- visit '/erb/form_for'
525
- assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
524
+ get "/erb/form_for"
525
+ assert_response_has_tag '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
526
526
  end
527
527
 
528
528
  it 'should display correct checkbox in slim' do
529
- visit '/slim/form_for'
530
- assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
529
+ get "/slim/form_for"
530
+ assert_response_has_tag '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
531
531
  end
532
532
  end
533
533
 
534
534
  describe 'for #check_box_group and #radio_button_group methods' do
535
535
  it 'should display checkbox group html' do
536
536
  checkboxes = standard_builder.check_box_group(:role, :collection => @user.role_types, :fields => [:name, :id], :selected => [2,3])
537
- assert_has_tag('input[type=checkbox]', :value => '1') { checkboxes }
538
- assert_has_no_tag('input[type=checkbox][checked]', :value => '1') { checkboxes }
539
- assert_has_tag('input[type=checkbox]', :checked => 'checked', :value => '2') { checkboxes }
540
- assert_has_tag('label[for=user_role_3] input[name="user[role][]"][value="3"][checked]') { checkboxes }
537
+ assert_html_has_tag(checkboxes, 'input[type=checkbox]', :value => '1')
538
+ assert_html_has_no_tag(checkboxes, 'input[type=checkbox][checked]', :value => '1')
539
+ assert_html_has_tag(checkboxes, 'input[type=checkbox]', :checked => 'checked', :value => '2')
540
+ assert_html_has_tag(checkboxes, 'label[for=user_role_3] input[name="user[role][]"][value="3"][checked]')
541
541
  end
542
542
 
543
543
  it 'should display checkbox group html and extract selected values from the object' do
544
544
  checkboxes = standard_builder.check_box_group(:roles, :collection => @user.role_types, :fields => [:name, :id])
545
- assert_has_tag('input[type=checkbox][name="user[roles][]"][value="1"][checked]') { checkboxes }
546
- assert_has_tag('input[type=checkbox][name="user[roles][]"][value="3"][checked]') { checkboxes }
547
- assert_has_no_tag('input[type=checkbox][name="user[roles][]"][value="2"][checked]') { checkboxes }
545
+ assert_html_has_tag(checkboxes, 'input[type=checkbox][name="user[roles][]"][value="1"][checked]')
546
+ assert_html_has_tag(checkboxes, 'input[type=checkbox][name="user[roles][]"][value="3"][checked]')
547
+ assert_html_has_no_tag(checkboxes, 'input[type=checkbox][name="user[roles][]"][value="2"][checked]')
548
548
  end
549
549
 
550
550
  it 'should display radio group html' do
551
551
  radios = standard_builder.radio_button_group(:role, :options => %W(red yellow blue), :selected => 'yellow')
552
- assert_has_tag('input[type=radio]', :value => 'red') { radios }
553
- assert_has_no_tag('input[type=radio][checked]', :value => 'red') { radios }
554
- assert_has_tag('input[type=radio]', :checked => 'checked', :value => 'yellow') { radios }
555
- assert_has_tag('label[for=user_role_blue] input[name="user[role]"][value=blue]') { radios }
552
+ assert_html_has_tag(radios, 'input[type=radio]', :value => 'red')
553
+ assert_html_has_no_tag(radios, 'input[type=radio][checked]', :value => 'red')
554
+ assert_html_has_tag(radios, 'input[type=radio]', :checked => 'checked', :value => 'yellow')
555
+ assert_html_has_tag(radios, 'label[for=user_role_blue] input[name="user[role]"][value=blue]')
556
556
  end
557
557
 
558
558
  it 'should display radio group html and extract selected value from the object' do
559
559
  radios = standard_builder.radio_button_group(:role, :collection => @user.role_types)
560
- assert_has_tag('input[type=radio][value="1"][checked]') { radios }
561
- assert_has_no_tag('input[type=radio][value="2"][checked]') { radios }
560
+ assert_html_has_tag(radios, 'input[type=radio][value="1"][checked]')
561
+ assert_html_has_no_tag(radios, 'input[type=radio][value="2"][checked]')
562
562
  end
563
563
  end
564
564
 
565
565
  describe 'for #radio_button method' do
566
566
  it 'should display correct radio button html' do
567
567
  actual_html = standard_builder.radio_button(:gender, :value => 'male', :class => 'large')
568
- assert_has_tag('input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male') { actual_html }
568
+ assert_html_has_tag(actual_html, 'input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male')
569
569
  end
570
570
 
571
571
  it 'should display correct radio button html when checked' do
572
572
  actual_html = standard_builder.radio_button(:gender, :checked => true)
573
- assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
573
+ assert_html_has_tag(actual_html, 'input[type=radio]', :checked => 'checked', :name => 'user[gender]')
574
574
  end
575
575
 
576
576
  it 'should display correct radio button html as checked when object value matches' do
577
577
  @user.stubs(:gender => 'male')
578
578
  actual_html = standard_builder.radio_button(:gender, :value => 'male')
579
- assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
579
+ assert_html_has_tag(actual_html, 'input[type=radio]', :checked => 'checked', :name => 'user[gender]')
580
580
  end
581
581
 
582
582
  it 'should display correct radio button html as unchecked when object value does not match' do
583
583
  @user.stubs(:gender => 'male')
584
584
  actual_html = standard_builder.radio_button(:gender, :value => 'female')
585
- assert_has_no_tag('input[type=radio]', :checked => 'checked') { actual_html }
585
+ assert_html_has_no_tag(actual_html, 'input[type=radio]', :checked => 'checked')
586
586
  end
587
587
 
588
588
  it 'should display correct radio button in haml' do
589
- visit '/haml/form_for'
590
- assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
591
- assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
592
- assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
589
+ get "/haml/form_for"
590
+ assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
591
+ assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
592
+ assert_response_has_tag '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
593
593
  end
594
594
 
595
595
  it 'should display correct radio button in erb' do
596
- visit '/erb/form_for'
597
- assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
598
- assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
599
- assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
596
+ get "/erb/form_for"
597
+ assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
598
+ assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
599
+ assert_response_has_tag '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
600
600
  end
601
601
 
602
602
  it 'should display correct radio button in slim' do
603
- visit '/slim/form_for'
604
- assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
605
- assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
606
- assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
603
+ get "/slim/form_for"
604
+ assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
605
+ assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
606
+ assert_response_has_tag '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
607
607
  end
608
608
  end
609
609
 
610
610
  describe 'for #text_area method' do
611
611
  it 'should display correct text_area html' do
612
612
  actual_html = standard_builder.text_area(:about, :class => 'large')
613
- assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html }
613
+ assert_html_has_tag(actual_html, 'textarea.large', :id => 'user_about', :name => 'user[about]')
614
614
  end
615
615
 
616
616
  it 'should display correct text_area html and content' do
617
617
  actual_html = standard_builder.text_area(:about, :value => "Demo", :rows => '5', :cols => '6')
618
- assert_has_tag('textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6') { actual_html }
618
+ assert_html_has_tag(actual_html, 'textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6')
619
619
  end
620
620
 
621
621
  it 'should display correct text_area in haml' do
622
- visit '/haml/form_for'
623
- assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
624
- assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
622
+ get "/haml/form_for"
623
+ assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
624
+ assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
625
625
  end
626
626
 
627
627
  it 'should display correct text_area in erb' do
628
- visit '/erb/form_for'
629
- assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
630
- assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
628
+ get "/erb/form_for"
629
+ assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
630
+ assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
631
631
  end
632
632
 
633
633
  it 'should display correct text_area in slim' do
634
- visit '/slim/form_for'
635
- assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
636
- assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
634
+ get "/slim/form_for"
635
+ assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
636
+ assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
637
637
  end
638
638
  end
639
639
 
640
640
  describe 'for #password_field method' do
641
641
  it 'should display correct password_field html' do
642
642
  actual_html = standard_builder.password_field(:code, :class => 'large')
643
- assert_has_tag('input.large[type=password]', :id => 'user_code', :name => 'user[code]') { actual_html }
643
+ assert_html_has_tag(actual_html, 'input.large[type=password]', :id => 'user_code', :name => 'user[code]')
644
644
  end
645
645
 
646
646
  it 'should display correct password_field in haml' do
647
- visit '/haml/form_for'
648
- assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
649
- assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
647
+ get "/haml/form_for"
648
+ assert_response_has_tag '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
649
+ assert_response_has_tag '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
650
650
  end
651
651
 
652
652
  it 'should display correct password_field in erb' do
653
- visit '/erb/form_for'
654
- assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
655
- assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
653
+ get "/erb/form_for"
654
+ assert_response_has_tag '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
655
+ assert_response_has_tag '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
656
656
  end
657
657
 
658
658
  it 'should display correct password_field in slim' do
659
- visit '/slim/form_for'
660
- assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
661
- assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
659
+ get "/slim/form_for"
660
+ assert_response_has_tag '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
661
+ assert_response_has_tag '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
662
662
  end
663
663
  end
664
664
 
665
665
  describe 'for #file_field method' do
666
666
  it 'should display correct file_field html' do
667
667
  actual_html = standard_builder.file_field(:photo, :class => 'large')
668
- assert_has_tag('input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
668
+ assert_html_has_tag(actual_html, 'input.large[type=file]', :id => 'user_photo', :name => 'user[photo]')
669
669
  end
670
670
 
671
671
  it 'should display correct file_field in haml' do
672
- visit '/haml/form_for'
673
- assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
674
- assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
672
+ get "/haml/form_for"
673
+ assert_response_has_tag '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
674
+ assert_response_has_tag '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
675
675
  end
676
676
 
677
677
  it 'should display correct file_field in erb' do
678
- visit '/erb/form_for'
679
- assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
680
- assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
678
+ get "/erb/form_for"
679
+ assert_response_has_tag '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
680
+ assert_response_has_tag '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
681
681
  end
682
682
 
683
683
  it 'should display correct file_field in slim' do
684
- visit '/slim/form_for'
685
- assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
686
- assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
684
+ get "/slim/form_for"
685
+ assert_response_has_tag '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
686
+ assert_response_has_tag '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
687
687
  end
688
688
 
689
689
  it 'should display correct form html with multipart, even if no multipart option is specified' do
690
690
  actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8") { |f| f.file_field :photo }
691
- assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
691
+ assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
692
692
  end
693
693
 
694
694
  it 'should display correct form html without multipart, if multipart option is specified false' do
695
695
  actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => false) { |f| f.file_field :photo }
696
- assert_has_no_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
696
+ assert_html_has_no_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
697
697
  end
698
698
 
699
699
  end
@@ -701,28 +701,28 @@ describe "FormBuilder" do
701
701
  describe 'for #select method' do
702
702
  it 'should display correct select html' do
703
703
  actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :class => 'selecty')
704
- assert_has_tag('select.selecty', :id => 'user_state', :name => 'user[state]') { actual_html }
705
- assert_has_tag('select.selecty option', :count => 3) { actual_html }
706
- assert_has_tag('select.selecty option', :value => 'California', :content => 'California') { actual_html }
707
- assert_has_tag('select.selecty option', :value => 'Texas', :content => 'Texas') { actual_html }
708
- assert_has_tag('select.selecty option', :value => 'Wyoming', :content => 'Wyoming') { actual_html }
704
+ assert_html_has_tag(actual_html, 'select.selecty', :id => 'user_state', :name => 'user[state]')
705
+ assert_html_has_tag(actual_html, 'select.selecty option', :count => 3)
706
+ assert_html_has_tag(actual_html, 'select.selecty option', :value => 'California', :content => 'California')
707
+ assert_html_has_tag(actual_html, 'select.selecty option', :value => 'Texas', :content => 'Texas')
708
+ assert_html_has_tag(actual_html, 'select.selecty option', :value => 'Wyoming', :content => 'Wyoming')
709
709
  end
710
710
 
711
711
  it 'should display correct select html with selected item if it matches value' do
712
712
  @user.stubs(:state => 'California')
713
713
  actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'])
714
- assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
715
- assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
716
- assert_has_tag('select option', :value => 'California', :selected => 'selected') { actual_html }
714
+ assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
715
+ assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
716
+ assert_html_has_tag(actual_html, 'select option', :value => 'California', :selected => 'selected')
717
717
  end
718
718
 
719
719
  it 'should display correct select html with selected item if it matches full value' do
720
720
  @user.stubs(:state => 'Cali')
721
721
  actual_html = standard_builder.select(:state, :options => ['Cali', 'California', 'Texas', 'Wyoming'])
722
- assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
723
- assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
724
- assert_has_tag('select option', :value => 'Cali', :selected => 'selected') { actual_html }
725
- assert_has_tag('select option', :value => 'California') { actual_html }
722
+ assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
723
+ assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
724
+ assert_html_has_tag(actual_html, 'select option', :value => 'Cali', :selected => 'selected')
725
+ assert_html_has_tag(actual_html, 'select option', :value => 'California')
726
726
  end
727
727
 
728
728
  it 'should display correct select html with multiple selected items' do
@@ -730,92 +730,95 @@ describe "FormBuilder" do
730
730
  actual_html = standard_builder.select(
731
731
  :pickles, :options => [ ['Foo', 'foo'], ['Bar', 'bar'], ['Baz', 'baz'], ['Bar Buz', 'bar buz'] ]
732
732
  )
733
- assert_has_tag('option', :value => 'foo', :content => 'Foo', :selected => 'selected') { actual_html }
734
- assert_has_tag('option', :value => 'bar', :content => 'Bar', :selected => 'selected') { actual_html }
735
- assert_has_tag('option', :value => 'baz', :content => 'Baz') { actual_html }
736
- assert_has_tag('option', :value => 'bar buz', :content => 'Bar Buz') { actual_html }
733
+ assert_html_has_tag(actual_html, 'option', :value => 'foo', :content => 'Foo', :selected => 'selected')
734
+ assert_html_has_tag(actual_html, 'option', :value => 'bar', :content => 'Bar', :selected => 'selected')
735
+ assert_html_has_tag(actual_html, 'option', :value => 'baz', :content => 'Baz')
736
+ assert_html_has_tag(actual_html, 'option', :value => 'bar buz', :content => 'Bar Buz')
737
737
  end
738
738
 
739
- it 'should display correct select html with include_blank' do
739
+ it 'should display correct select html with include_blank true' do
740
740
  actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => true)
741
- assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
742
- assert_has_tag('select option', :count => 4) { actual_html }
743
- assert_has_tag('select option:first-child', :content => '') { actual_html }
744
- assert_has_tag('select option:first-child', :value => '') { actual_html }
741
+ assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
742
+ assert_html_has_tag(actual_html, 'select option', :count => 4)
743
+ assert_html_has_tag(actual_html, 'select option:first-child', :content => '')
744
+ assert_html_has_tag(actual_html, 'select option:first-child', :value => '')
745
+ end
746
+
747
+ it 'should display correct select html with include_blank string' do
745
748
  actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => 'Select')
746
- assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
747
- assert_has_tag('select option', :count => 4) { actual_html }
748
- assert_has_tag('select option:first-child', :content => 'Select') { actual_html }
749
- assert_has_tag('select option:first-child', :value => '') { actual_html }
749
+ assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
750
+ assert_html_has_tag(actual_html, 'select option', :count => 4)
751
+ assert_html_has_tag(actual_html, 'select option:first-child', :content => 'Select')
752
+ assert_html_has_tag(actual_html, 'select option:first-child', :value => '')
750
753
  end
751
754
 
752
755
  it 'should display correct select html with collection passed in' do
753
756
  actual_html = standard_builder.select(:role, :collection => @user.role_types, :fields => [:name, :id])
754
- assert_has_tag('select', :id => 'user_role', :name => 'user[role]') { actual_html }
755
- assert_has_tag('select option', :count => 3) { actual_html }
756
- assert_has_tag('select option', :value => '1', :content => 'Admin', :selected => 'selected') { actual_html }
757
- assert_has_tag('select option', :value => '2', :content => 'Moderate') { actual_html }
758
- assert_has_tag('select option', :value => '3', :content => 'Limited') { actual_html }
757
+ assert_html_has_tag(actual_html, 'select', :id => 'user_role', :name => 'user[role]')
758
+ assert_html_has_tag(actual_html, 'select option', :count => 3)
759
+ assert_html_has_tag(actual_html, 'select option', :value => '1', :content => 'Admin', :selected => 'selected')
760
+ assert_html_has_tag(actual_html, 'select option', :value => '2', :content => 'Moderate')
761
+ assert_html_has_tag(actual_html, 'select option', :value => '3', :content => 'Limited')
759
762
  end
760
763
 
761
764
  it 'should display correct select in haml' do
762
- visit '/haml/form_for'
763
- assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
764
- assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
765
+ get "/haml/form_for"
766
+ assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
767
+ assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
765
768
  end
766
769
 
767
770
  it 'should display correct select in erb' do
768
- visit '/erb/form_for'
769
- assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
770
- assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
771
+ get "/erb/form_for"
772
+ assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
773
+ assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
771
774
  end
772
775
 
773
776
  it 'should display correct select in slim' do
774
- visit '/slim/form_for'
775
- assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
776
- assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
777
+ get "/slim/form_for"
778
+ assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
779
+ assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
777
780
  end
778
781
  end
779
782
 
780
783
  describe 'for #submit method' do
781
784
  it 'should display correct submit button html with no options' do
782
785
  actual_html = standard_builder.submit
783
- assert_has_tag('input[type=submit]', :value => "Submit") { actual_html }
786
+ assert_html_has_tag(actual_html, 'input[type=submit]', :value => "Submit")
784
787
  end
785
788
 
786
789
 
787
790
  it 'should display correct submit button html with no caption' do
788
791
  actual_html = standard_builder.submit(:class => 'btn')
789
- assert_has_tag('input.btn[type=submit]', :value => "Submit") { actual_html }
792
+ assert_html_has_tag(actual_html, 'input.btn[type=submit]', :value => "Submit")
790
793
  end
791
794
 
792
795
  it 'should display correct submit button html with nil caption' do
793
796
  actual_html = standard_builder.submit(nil, :class => 'btn')
794
- assert_has_tag('input.btn[type=submit]') { actual_html }
797
+ assert_html_has_tag(actual_html, 'input.btn[type=submit]')
795
798
  assert actual_html !~ %r{ value \* = }x
796
799
  end
797
800
 
798
801
  it 'should display correct submit button html' do
799
802
  actual_html = standard_builder.submit("Commit", :class => 'large')
800
- assert_has_tag('input.large[type=submit]', :value => "Commit") { actual_html }
803
+ assert_html_has_tag(actual_html, 'input.large[type=submit]', :value => "Commit")
801
804
  end
802
805
 
803
806
  it 'should display correct submit button in haml' do
804
- visit '/haml/form_for'
805
- assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
806
- assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
807
+ get "/haml/form_for"
808
+ assert_response_has_tag '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
809
+ assert_response_has_tag '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
807
810
  end
808
811
 
809
812
  it 'should display correct submit button in erb' do
810
- visit '/erb/form_for'
811
- assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
812
- assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
813
+ get "/erb/form_for"
814
+ assert_response_has_tag '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
815
+ assert_response_has_tag '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
813
816
  end
814
817
 
815
818
  it 'should display correct submit button in slim' do
816
- visit '/slim/form_for'
817
- assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
818
- assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
819
+ get "/slim/form_for"
820
+ assert_response_has_tag '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
821
+ assert_response_has_tag '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
819
822
  end
820
823
  end
821
824
 
@@ -826,30 +829,30 @@ describe "FormBuilder" do
826
829
 
827
830
  it 'should display correct image submit button html with no options' do
828
831
  actual_html = standard_builder.image_submit('buttons/ok.png')
829
- assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
832
+ assert_html_has_tag(actual_html, 'input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}")
830
833
  end
831
834
 
832
835
  it 'should display correct image submit button html' do
833
836
  actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
834
- assert_has_tag('input.large[type=image]', :src => "/system/ok.png") { actual_html }
837
+ assert_html_has_tag(actual_html, 'input.large[type=image]', :src => "/system/ok.png")
835
838
  end
836
839
 
837
840
  it 'should display correct image submit button in haml' do
838
- visit '/haml/form_for'
839
- assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
840
- assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
841
+ get "/haml/form_for"
842
+ assert_response_has_tag '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
843
+ assert_response_has_tag '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
841
844
  end
842
845
 
843
846
  it 'should display correct image submit button in erb' do
844
- visit '/erb/form_for'
845
- assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
846
- assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
847
+ get "/erb/form_for"
848
+ assert_response_has_tag '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
849
+ assert_response_has_tag '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
847
850
  end
848
851
 
849
852
  it 'should display correct image submit button in slim' do
850
- visit '/slim/form_for'
851
- assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
852
- assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
853
+ get "/slim/form_for"
854
+ assert_response_has_tag '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
855
+ assert_response_has_tag '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
853
856
  end
854
857
  end
855
858
 
@@ -870,10 +873,10 @@ describe "FormBuilder" do
870
873
  child_form.text_field(:number) +
871
874
  child_form.check_box('_destroy')
872
875
  end
873
- assert_has_tag('label', :for => 'user_telephone_attributes_number') { actual_html }
874
- assert_has_tag('input', :type => 'text', :id => 'user_telephone_attributes_number', :name => 'user[telephone_attributes][number]', :value => "4568769876") { actual_html }
875
- assert_has_tag('input', :type => 'hidden', :name => 'user[telephone_attributes][_destroy]', :value => '0') { actual_html }
876
- assert_has_tag('input', :type => 'checkbox', :id => 'user_telephone_attributes__destroy', :name => 'user[telephone_attributes][_destroy]', :value => '1') { actual_html }
876
+ assert_html_has_tag(actual_html, 'label', :for => 'user_telephone_attributes_number')
877
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_telephone_attributes_number', :name => 'user[telephone_attributes][number]', :value => "4568769876")
878
+ assert_html_has_tag(actual_html, 'input', :type => 'hidden', :name => 'user[telephone_attributes][_destroy]', :value => '0')
879
+ assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_telephone_attributes__destroy', :name => 'user[telephone_attributes][_destroy]', :value => '1')
877
880
  end
878
881
 
879
882
  it 'should display nested children fields one-to-many within form' do
@@ -883,15 +886,15 @@ describe "FormBuilder" do
883
886
  html << child_form.text_field(:name)
884
887
  end
885
888
  # Address 1 (Saved)
886
- assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
887
- assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
888
- assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]') { actual_html }
889
- assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
889
+ assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20')
890
+ assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_0_name', :content => 'Name')
891
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]')
892
+ assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]')
890
893
  # Address 2 (New)
891
- assert_has_no_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_1_id') { actual_html }
892
- assert_has_tag('label', :for => 'user_addresses_attributes_1_name', :content => 'Name') { actual_html }
893
- assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_name', :name => 'user[addresses_attributes][1][name]') { actual_html }
894
- assert_has_no_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_1__destroy') { actual_html }
894
+ assert_html_has_no_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_1_id')
895
+ assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_1_name', :content => 'Name')
896
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_1_name', :name => 'user[addresses_attributes][1][name]')
897
+ assert_html_has_no_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_1__destroy')
895
898
  end
896
899
 
897
900
  it 'should display fields for explicit instance object' do
@@ -901,10 +904,10 @@ describe "FormBuilder" do
901
904
  html << child_form.text_field(:name)
902
905
  html << child_form.check_box('_destroy')
903
906
  end
904
- assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '40') { actual_html }
905
- assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
906
- assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Page") { actual_html }
907
- assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]', :value => '1') { actual_html }
907
+ assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '40')
908
+ assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_0_name', :content => 'Name')
909
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Page")
910
+ assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]', :value => '1')
908
911
  end
909
912
 
910
913
  it 'should display fields for collection object' do
@@ -915,15 +918,15 @@ describe "FormBuilder" do
915
918
  child_form.check_box('_destroy')
916
919
  end
917
920
  # Address 1
918
- assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
919
- assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
920
- assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Foo") { actual_html }
921
- assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
921
+ assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20')
922
+ assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_0_name', :content => 'Name')
923
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Foo")
924
+ assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]')
922
925
  # Address 3
923
- assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_2_id', :value => '50') { actual_html }
924
- assert_has_tag('label', :for => 'user_addresses_attributes_2_name', :content => 'Name') { actual_html }
925
- assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_2_name', :name => 'user[addresses_attributes][2][name]', :value => "Walter") { actual_html }
926
- assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_2__destroy') { actual_html }
926
+ assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_2_id', :value => '50')
927
+ assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_2_name', :content => 'Name')
928
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_2_name', :name => 'user[addresses_attributes][2][name]', :value => "Walter")
929
+ assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_2__destroy')
927
930
  end
928
931
 
929
932
  it 'should display fields for arbitrarily deep nested forms' do
@@ -934,8 +937,8 @@ describe "FormBuilder" do
934
937
  second_child_form.check_box('_destroy')
935
938
  end
936
939
  end
937
- assert_has_tag('label', :for => 'user_addresses_attributes_1_businesses_attributes_0_name', :content => 'Name') { actual_html }
938
- assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]') { actual_html }
940
+ assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_1_businesses_attributes_0_name', :content => 'Name')
941
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]')
939
942
  end
940
943
 
941
944
  it 'should display fields for nested forms with custom indices' do
@@ -951,59 +954,59 @@ describe "FormBuilder" do
951
954
  html
952
955
  end
953
956
 
954
- assert_has_tag('label', :for => 'user_addresses_attributes_1_businesses_attributes_a_name', :content => 'Name') { actual_html }
955
- assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_a_name', :name => 'user[addresses_attributes][1][businesses_attributes][a][name]') { actual_html }
957
+ assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_1_businesses_attributes_a_name', :content => 'Name')
958
+ assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_a_name', :name => 'user[addresses_attributes][1][businesses_attributes][a][name]')
956
959
  end
957
960
 
958
961
  it 'should display nested children fields in erb' do
959
- visit '/erb/fields_for'
962
+ get "/erb/fields_for"
960
963
  # Telephone
961
- assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
962
- assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
964
+ assert_response_has_tag('label', :for => 'markup_user_telephone_attributes_number')
965
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
963
966
  # Address 1 (Saved)
964
- assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
965
- assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
966
- assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
967
- assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
967
+ assert_response_has_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
968
+ assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
969
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
970
+ assert_response_has_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
968
971
  # Address 2 (New)
969
- assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
970
- assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
971
- assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
972
- assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
972
+ assert_response_has_no_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
973
+ assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
974
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
975
+ assert_response_has_no_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
973
976
  end
974
977
 
975
978
  it 'should display nested children fields in haml' do
976
- visit '/haml/fields_for'
979
+ get "/haml/fields_for"
977
980
  # Telephone
978
- assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
979
- assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
981
+ assert_response_has_tag('label', :for => 'markup_user_telephone_attributes_number')
982
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
980
983
  # Address 1 (Saved)
981
- assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
982
- assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
983
- assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
984
- assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
984
+ assert_response_has_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
985
+ assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
986
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
987
+ assert_response_has_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
985
988
  # Address 2 (New)
986
- assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
987
- assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
988
- assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
989
- assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
989
+ assert_response_has_no_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
990
+ assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
991
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
992
+ assert_response_has_no_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
990
993
  end
991
994
 
992
995
  it 'should display nested children fields in slim' do
993
- visit '/slim/fields_for'
996
+ get "/slim/fields_for"
994
997
  # Telephone
995
- assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
996
- assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
998
+ assert_response_has_tag('label', :for => 'markup_user_telephone_attributes_number')
999
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
997
1000
  # Address 1 (Saved)
998
- assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
999
- assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
1000
- assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
1001
- assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
1001
+ assert_response_has_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
1002
+ assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
1003
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
1004
+ assert_response_has_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
1002
1005
  # Address 2 (New)
1003
- assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
1004
- assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
1005
- assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
1006
- assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
1006
+ assert_response_has_no_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
1007
+ assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
1008
+ assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
1009
+ assert_response_has_no_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
1007
1010
  end
1008
1011
  end
1009
1012
 
@@ -1014,182 +1017,182 @@ describe "FormBuilder" do
1014
1017
  describe 'for #text_field_block method' do
1015
1018
  it 'should display correct text field block html' do
1016
1019
  actual_html = standard_builder.text_field_block(:first_name, :class => 'large', :caption => "FName")
1017
- assert_has_tag('p label', :for => 'user_first_name', :content => "FName") { actual_html }
1018
- assert_has_tag('p input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
1020
+ assert_html_has_tag(actual_html, 'p label', :for => 'user_first_name', :content => "FName")
1021
+ assert_html_has_tag(actual_html, 'p input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]')
1019
1022
  end
1020
1023
 
1021
1024
  it 'should display correct text field block in haml' do
1022
- visit '/haml/form_for'
1023
- assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
1024
- assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
1025
+ get "/haml/form_for"
1026
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
1027
+ assert_response_has_tag '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
1025
1028
  end
1026
1029
 
1027
1030
  it 'should display correct text field block in erb' do
1028
- visit '/erb/form_for'
1029
- assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
1030
- assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
1031
+ get "/erb/form_for"
1032
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
1033
+ assert_response_has_tag '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
1031
1034
  end
1032
1035
 
1033
1036
  it 'should display correct text field block in slim' do
1034
- visit '/slim/form_for'
1035
- assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
1036
- assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
1037
+ get "/slim/form_for"
1038
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
1039
+ assert_response_has_tag '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
1037
1040
  end
1038
1041
  end
1039
1042
 
1040
1043
  describe 'for #text_area_block method' do
1041
1044
  it 'should display correct text area block html' do
1042
1045
  actual_html = standard_builder.text_area_block(:about, :class => 'large', :caption => "About Me")
1043
- assert_has_tag('p label', :for => 'user_about', :content => "About Me") { actual_html }
1044
- assert_has_tag('p textarea', :id => 'user_about', :name => 'user[about]') { actual_html }
1046
+ assert_html_has_tag(actual_html, 'p label', :for => 'user_about', :content => "About Me")
1047
+ assert_html_has_tag(actual_html, 'p textarea', :id => 'user_about', :name => 'user[about]')
1045
1048
  end
1046
1049
 
1047
1050
  it 'should display correct text area block in haml' do
1048
- visit '/haml/form_for'
1049
- assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
1050
- assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
1051
+ get "/haml/form_for"
1052
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_about', :content => "About: "
1053
+ assert_response_has_tag '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
1051
1054
  end
1052
1055
 
1053
1056
  it 'should display correct text area block in erb' do
1054
- visit '/erb/form_for'
1055
- assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
1056
- assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
1057
+ get "/erb/form_for"
1058
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_about', :content => "About: "
1059
+ assert_response_has_tag '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
1057
1060
  end
1058
1061
 
1059
1062
  it 'should display correct text area block in slim' do
1060
- visit '/slim/form_for'
1061
- assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
1062
- assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
1063
+ get "/slim/form_for"
1064
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_about', :content => "About: "
1065
+ assert_response_has_tag '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
1063
1066
  end
1064
1067
  end
1065
1068
 
1066
1069
  describe 'for #password_field_block method' do
1067
1070
  it 'should display correct password field block html' do
1068
1071
  actual_html = standard_builder.password_field_block(:keycode, :class => 'large', :caption => "Code: ")
1069
- assert_has_tag('p label', :for => 'user_keycode', :content => "Code: ") { actual_html }
1070
- assert_has_tag('p input.large[type=password]', :id => 'user_keycode', :name => 'user[keycode]') { actual_html }
1072
+ assert_html_has_tag(actual_html, 'p label', :for => 'user_keycode', :content => "Code: ")
1073
+ assert_html_has_tag(actual_html, 'p input.large[type=password]', :id => 'user_keycode', :name => 'user[keycode]')
1071
1074
  end
1072
1075
 
1073
1076
  it 'should display correct password field block in haml' do
1074
- visit '/haml/form_for'
1075
- assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
1076
- assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
1077
+ get "/haml/form_for"
1078
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
1079
+ assert_response_has_tag '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
1077
1080
  end
1078
1081
 
1079
1082
  it 'should display correct password field block in erb' do
1080
- visit '/erb/form_for'
1081
- assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
1082
- assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
1083
+ get "/erb/form_for"
1084
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
1085
+ assert_response_has_tag '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
1083
1086
  end
1084
1087
 
1085
1088
  it 'should display correct password field block in slim' do
1086
- visit '/slim/form_for'
1087
- assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
1088
- assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
1089
+ get "/slim/form_for"
1090
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
1091
+ assert_response_has_tag '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
1089
1092
  end
1090
1093
  end
1091
1094
 
1092
1095
  describe 'for #file_field_block method' do
1093
1096
  it 'should display correct file field block html' do
1094
1097
  actual_html = standard_builder.file_field_block(:photo, :class => 'large', :caption => "Photo: ")
1095
- assert_has_tag('p label', :for => 'user_photo', :content => "Photo: ") { actual_html }
1096
- assert_has_tag('p input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
1098
+ assert_html_has_tag(actual_html, 'p label', :for => 'user_photo', :content => "Photo: ")
1099
+ assert_html_has_tag(actual_html, 'p input.large[type=file]', :id => 'user_photo', :name => 'user[photo]')
1097
1100
  end
1098
1101
 
1099
1102
  it 'should display correct file field block in haml' do
1100
- visit '/haml/form_for'
1101
- assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
1102
- assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
1103
+ get "/haml/form_for"
1104
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
1105
+ assert_response_has_tag '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
1103
1106
  end
1104
1107
 
1105
1108
  it 'should display correct file field block in erb' do
1106
- visit '/erb/form_for'
1107
- assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
1108
- assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
1109
+ get "/erb/form_for"
1110
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
1111
+ assert_response_has_tag '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
1109
1112
  end
1110
1113
 
1111
1114
  it 'should display correct file field block in slim' do
1112
- visit '/slim/form_for'
1113
- assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
1114
- assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
1115
+ get "/slim/form_for"
1116
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
1117
+ assert_response_has_tag '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
1115
1118
  end
1116
1119
  end
1117
1120
 
1118
1121
  describe 'for #check_box_block method' do
1119
1122
  it 'should display correct check box block html' do
1120
1123
  actual_html = standard_builder.check_box_block(:remember_me, :class => 'large', :caption => "Remember session?")
1121
- assert_has_tag('p label', :for => 'user_remember_me', :content => "Remember session?") { actual_html }
1122
- assert_has_tag('p input.large[type=checkbox]', :id => 'user_remember_me', :name => 'user[remember_me]') { actual_html }
1124
+ assert_html_has_tag(actual_html, 'p label', :for => 'user_remember_me', :content => "Remember session?")
1125
+ assert_html_has_tag(actual_html, 'p input.large[type=checkbox]', :id => 'user_remember_me', :name => 'user[remember_me]')
1123
1126
  end
1124
1127
 
1125
1128
  it 'should display correct check box block in haml' do
1126
- visit '/haml/form_for'
1127
- assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
1128
- assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
1129
+ get "/haml/form_for"
1130
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
1131
+ assert_response_has_tag '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
1129
1132
  end
1130
1133
 
1131
1134
  it 'should display correct check box block in erb' do
1132
- visit '/erb/form_for'
1133
- assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
1134
- assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
1135
+ get "/erb/form_for"
1136
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
1137
+ assert_response_has_tag '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
1135
1138
  end
1136
1139
 
1137
1140
  it 'should display correct check box block in slim' do
1138
- visit '/slim/form_for'
1139
- assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
1140
- assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
1141
+ get "/slim/form_for"
1142
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
1143
+ assert_response_has_tag '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
1141
1144
  end
1142
1145
  end
1143
1146
 
1144
1147
  describe 'for #select_block method' do
1145
1148
  it 'should display correct select_block block html' do
1146
1149
  actual_html = standard_builder.select_block(:country, :options => ['USA', 'Canada'], :class => 'large', :caption => "Your country")
1147
- assert_has_tag('p label', :for => 'user_country', :content => "Your country") { actual_html }
1148
- assert_has_tag('p select', :id => 'user_country', :name => 'user[country]') { actual_html }
1149
- assert_has_tag('p select option', :content => 'USA') { actual_html }
1150
- assert_has_tag('p select option', :content => 'Canada') { actual_html }
1150
+ assert_html_has_tag(actual_html, 'p label', :for => 'user_country', :content => "Your country")
1151
+ assert_html_has_tag(actual_html, 'p select', :id => 'user_country', :name => 'user[country]')
1152
+ assert_html_has_tag(actual_html, 'p select option', :content => 'USA')
1153
+ assert_html_has_tag(actual_html, 'p select option', :content => 'Canada')
1151
1154
  end
1152
1155
 
1153
1156
  it 'should display correct select_block block in haml' do
1154
- visit '/haml/form_for'
1155
- assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
1156
- assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
1157
- assert_have_selector '#demo2 p select option', :content => 'California'
1158
- assert_have_selector '#demo2 p select option', :content => 'Texas'
1157
+ get "/haml/form_for"
1158
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_state', :content => "State: "
1159
+ assert_response_has_tag '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
1160
+ assert_response_has_tag '#demo2 p select option', :content => 'California'
1161
+ assert_response_has_tag '#demo2 p select option', :content => 'Texas'
1159
1162
  end
1160
1163
 
1161
1164
  it 'should display correct select_block block in erb' do
1162
- visit '/erb/form_for'
1163
- assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
1164
- assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
1165
+ get "/erb/form_for"
1166
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_state', :content => "State: "
1167
+ assert_response_has_tag '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
1165
1168
  end
1166
1169
 
1167
1170
  it 'should display correct select_block block in slim' do
1168
- visit '/slim/form_for'
1169
- assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
1170
- assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
1171
+ get "/slim/form_for"
1172
+ assert_response_has_tag '#demo2 p label', :for => 'markup_user_state', :content => "State: "
1173
+ assert_response_has_tag '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
1171
1174
  end
1172
1175
  end
1173
1176
 
1174
1177
  describe 'for #submit_block method' do
1175
1178
  it 'should display correct submit block html' do
1176
1179
  actual_html = standard_builder.submit_block("Update", :class => 'large')
1177
- assert_has_tag('p input.large[type=submit]', :value => 'Update') { actual_html }
1180
+ assert_html_has_tag(actual_html, 'p input.large[type=submit]', :value => 'Update')
1178
1181
  end
1179
1182
 
1180
1183
  it 'should display correct submit block in haml' do
1181
- visit '/haml/form_for'
1182
- assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
1184
+ get "/haml/form_for"
1185
+ assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
1183
1186
  end
1184
1187
 
1185
1188
  it 'should display correct submit block in erb' do
1186
- visit '/erb/form_for'
1187
- assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
1189
+ get "/erb/form_for"
1190
+ assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
1188
1191
  end
1189
1192
 
1190
1193
  it 'should display correct submit block in slim' do
1191
- visit '/slim/form_for'
1192
- assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
1194
+ get "/slim/form_for"
1195
+ assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
1193
1196
  end
1194
1197
  end
1195
1198
 
@@ -1200,17 +1203,255 @@ describe "FormBuilder" do
1200
1203
 
1201
1204
  it 'should display correct image submit block html' do
1202
1205
  actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
1203
- assert_has_tag('p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
1206
+ assert_html_has_tag(actual_html, 'p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}")
1204
1207
  end
1205
1208
 
1206
1209
  it 'should display correct image submit block in haml' do
1207
- visit '/haml/form_for'
1208
- assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
1210
+ get "/haml/form_for"
1211
+ assert_response_has_tag '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
1209
1212
  end
1210
1213
 
1211
1214
  it 'should display correct image submit block in slim' do
1212
- visit '/slim/form_for'
1213
- assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
1215
+ get "/slim/form_for"
1216
+ assert_response_has_tag '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
1217
+ end
1218
+ end
1219
+
1220
+ describe 'for #datetime_field method' do
1221
+ it 'should display correct datetime field html' do
1222
+ actual_html = standard_builder.datetime_field(:datetime)
1223
+ assert_html_has_tag(actual_html, 'input[type=datetime]', :id => 'user_datetime', :name => 'user[datetime]')
1224
+ end
1225
+
1226
+ it 'should format DateTime to correct value if min and max and value options exist' do
1227
+ max = DateTime.new(2000, 4, 1, 12, 0, 0)
1228
+ min = DateTime.new(1993, 2, 24, 12, 30, 45)
1229
+ value = DateTime.new(2000, 4, 1, 12, 0, 0)
1230
+ actual_html = standard_builder.datetime_field(:datetime, :max => max, :min => min, :value => value)
1231
+ expected = {
1232
+ :id => 'user_datetime',
1233
+ :max => "2000-04-01T12:00:00.000+0000",
1234
+ :min => "1993-02-24T12:30:45.000+0000",
1235
+ :value => "2000-04-01T12:00:00.000+0000"
1236
+ }
1237
+ assert_html_has_tag(actual_html, 'input[type=datetime]', expected)
1238
+ end
1239
+
1240
+ it 'should display correct datetime field in haml' do
1241
+ get "/haml/form_for"
1242
+ assert_response_has_tag '#demo input[type=datetime]', :id => 'markup_user_datetime', :max => "2000-04-01T12:00:00.000+0000"
1243
+ end
1244
+
1245
+ it 'should display correct datetime field in erb' do
1246
+ get "/erb/form_for"
1247
+ assert_response_has_tag '#demo input[type=datetime]', :id => 'markup_user_datetime', :max => "2000-04-01T12:00:00.000+0000"
1248
+ end
1249
+
1250
+ it 'should display correct datetime field in slim' do
1251
+ get "/slim/form_for"
1252
+ assert_response_has_tag '#demo input[type=datetime]', :id => 'markup_user_datetime', :max => "2000-04-01T12:00:00.000+0000"
1253
+ end
1254
+ end
1255
+
1256
+ describe 'for #datetime_local_field method' do
1257
+ it 'should display correct datetime-local field html' do
1258
+ actual_html = standard_builder.datetime_local_field(:datetime_local)
1259
+ assert_html_has_tag(actual_html, 'input[type=datetime-local]', :id => 'user_datetime_local', :name => 'user[datetime_local]')
1260
+ end
1261
+
1262
+ it 'should format DateTime to correct value if min and max and value options exist' do
1263
+ max = DateTime.new(2000, 4, 1, 12, 0, 0)
1264
+ min = DateTime.new(1993, 2, 24, 12, 30, 45)
1265
+ value = DateTime.new(2000, 4, 1, 12, 0, 0)
1266
+ actual_html = standard_builder.datetime_local_field(:datetime_local, :max => max, :min => min, :value => value)
1267
+ expected = {
1268
+ :id => 'user_datetime_local',
1269
+ :max => "2000-04-01T12:00:00",
1270
+ :min => "1993-02-24T12:30:45",
1271
+ :value => "2000-04-01T12:00:00"
1272
+ }
1273
+ assert_html_has_tag(actual_html, 'input[type=datetime-local]', expected)
1274
+ end
1275
+
1276
+ it 'should display correct datetime-local field in haml' do
1277
+ get "/haml/form_for"
1278
+ assert_response_has_tag '#demo input[type=datetime-local]', :id => 'markup_user_datetime_local'
1279
+ end
1280
+
1281
+ it 'should display correct datetime-local field in erb' do
1282
+ get "/erb/form_for"
1283
+ assert_response_has_tag '#demo input[type=datetime-local]', :id => 'markup_user_datetime_local'
1284
+ end
1285
+
1286
+ it 'should display correct datetime-local field in slim' do
1287
+ get "/slim/form_for"
1288
+ assert_response_has_tag '#demo input[type=datetime-local]', :id => 'markup_user_datetime_local'
1289
+ end
1290
+ end
1291
+
1292
+ describe 'for #date_field method' do
1293
+ it 'should display correct date field html' do
1294
+ actual_html = standard_builder.date_field(:date)
1295
+ assert_html_has_tag(actual_html, 'input[type=date]', :id => 'user_date', :name => 'user[date]')
1296
+ end
1297
+
1298
+ it 'should format DateTime to correct value if min and max and value options exist' do
1299
+ max = DateTime.new(2000, 4, 1)
1300
+ min = DateTime.new(1993, 2, 24)
1301
+ value = DateTime.new(2000, 4, 1)
1302
+ actual_html = standard_builder.date_field(:date, :max => max, :min => min, :value => value)
1303
+ expected = {
1304
+ :id => 'user_date',
1305
+ :max => "2000-04-01",
1306
+ :min => "1993-02-24",
1307
+ :value => "2000-04-01"
1308
+ }
1309
+ assert_html_has_tag(actual_html, 'input[type=date]', expected)
1310
+ end
1311
+
1312
+ it 'should display correct date field in haml' do
1313
+ get "/haml/form_for"
1314
+ assert_response_has_tag '#demo input[type=date]', :id => 'markup_user_date'
1315
+ end
1316
+
1317
+ it 'should display correct date field in erb' do
1318
+ get "/erb/form_for"
1319
+ assert_response_has_tag '#demo input[type=date]', :id => 'markup_user_date'
1320
+ end
1321
+
1322
+ it 'should display correct date field in slim' do
1323
+ get "/slim/form_for"
1324
+ assert_response_has_tag '#demo input[type=date]', :id => 'markup_user_date'
1325
+ end
1326
+ end
1327
+
1328
+ describe 'for #month_field method' do
1329
+ it 'should display correct month field html' do
1330
+ actual_html = standard_builder.month_field(:month)
1331
+ assert_html_has_tag(actual_html, 'input[type=month]', :id => 'user_month', :name => 'user[month]')
1332
+ end
1333
+
1334
+ it 'should format DateTime to correct value if min and max and value options exist' do
1335
+ max = DateTime.new(2000, 4, 1)
1336
+ min = DateTime.new(1993, 2, 24)
1337
+ value = DateTime.new(2000, 4, 1)
1338
+ actual_html = standard_builder.month_field(:month, :max => max, :min => min, :value => value)
1339
+ expected = {
1340
+ :id => 'user_month',
1341
+ :max => "2000-04",
1342
+ :min => "1993-02",
1343
+ :value => "2000-04"
1344
+ }
1345
+ assert_html_has_tag(actual_html, 'input[type=month]', expected)
1346
+ end
1347
+
1348
+ it 'should display correct month field in haml' do
1349
+ get "/haml/form_for"
1350
+ assert_response_has_tag '#demo input[type=month]', :id => 'markup_user_month'
1351
+ end
1352
+
1353
+ it 'should display correct month field in erb' do
1354
+ get "/erb/form_for"
1355
+ assert_response_has_tag '#demo input[type=month]', :id => 'markup_user_month'
1356
+ end
1357
+
1358
+ it 'should display correct month field in slim' do
1359
+ get "/slim/form_for"
1360
+ assert_response_has_tag '#demo input[type=month]', :id => 'markup_user_month'
1361
+ end
1362
+ end
1363
+
1364
+ describe 'for #week_field method' do
1365
+ it 'should display correct week field html' do
1366
+ actual_html = standard_builder.week_field(:week)
1367
+ assert_html_has_tag(actual_html, 'input[type=week]', :id => 'user_week', :name => 'user[week]')
1368
+ end
1369
+
1370
+ it 'should format DateTime to correct value if min and max and value options exist' do
1371
+ max = DateTime.new(2000, 4, 1)
1372
+ min = DateTime.new(1993, 2, 24)
1373
+ value = DateTime.new(2000, 4, 1)
1374
+ actual_html = standard_builder.week_field(:week, :max => max, :min => min, :value => value)
1375
+ expected = {
1376
+ :id => 'user_week',
1377
+ :max => "2000-W13",
1378
+ :min => "1993-W08",
1379
+ :value => "2000-W13"
1380
+ }
1381
+ assert_html_has_tag(actual_html, 'input[type=week]', expected)
1382
+ end
1383
+
1384
+ it 'should display correct week field in haml' do
1385
+ get "/haml/form_for"
1386
+ assert_response_has_tag '#demo input[type=week]', :id => 'markup_user_week'
1387
+ end
1388
+
1389
+ it 'should display correct week field in erb' do
1390
+ get "/erb/form_for"
1391
+ assert_response_has_tag '#demo input[type=week]', :id => 'markup_user_week'
1392
+ end
1393
+
1394
+ it 'should display correct week field in slim' do
1395
+ get "/slim/form_for"
1396
+ assert_response_has_tag '#demo input[type=week]', :id => 'markup_user_week'
1397
+ end
1398
+ end
1399
+
1400
+ describe 'for #time_field method' do
1401
+ it 'should display correct time field html' do
1402
+ actual_html = standard_builder.time_field(:time)
1403
+ assert_html_has_tag(actual_html, 'input[type=time]', :id => 'user_time', :name => 'user[time]')
1404
+ end
1405
+
1406
+ it 'should format DateTime to correct value if min and max and value options exist' do
1407
+ max = Time.new(2008, 6, 21, 13, 30, 0)
1408
+ min = Time.new(1993, 2, 24, 1, 19, 12)
1409
+ value = Time.new(2008, 6, 21, 13, 30, 0)
1410
+ actual_html = standard_builder.time_field(:time, :max => max, :min => min, :value => value)
1411
+ expected = {
1412
+ :id => 'user_time',
1413
+ :max => "13:30:00.000",
1414
+ :min => "01:19:12.000",
1415
+ :value => "13:30:00.000"
1416
+ }
1417
+ assert_html_has_tag(actual_html, 'input[type=time]', expected)
1418
+ end
1419
+
1420
+ it 'should display correct time field in haml' do
1421
+ get "/haml/form_for"
1422
+ assert_response_has_tag '#demo input[type=time]', :id => 'markup_user_time'
1423
+ end
1424
+
1425
+ it 'should display correct time field in erb' do
1426
+ get "/erb/form_for"
1427
+ assert_response_has_tag '#demo input[type=time]', :id => 'markup_user_time'
1428
+ end
1429
+
1430
+ it 'should display correct time field in slim' do
1431
+ get "/slim/form_for"
1432
+ assert_response_has_tag '#demo input[type=time]', :id => 'markup_user_time'
1433
+ end
1434
+ end
1435
+
1436
+ describe 'for #color_field method' do
1437
+ it 'should display correct color field html' do
1438
+ actual_html = standard_builder.color_field(:color)
1439
+ assert_html_has_tag(actual_html, 'input[type=color]', :id => 'user_color', :name => 'user[color]')
1440
+ end
1441
+
1442
+ it 'should display correct color field in haml' do
1443
+ get "/haml/form_for"
1444
+ assert_response_has_tag '#demo input[type=color]', :id => 'markup_user_color', :value => "#ff0000"
1445
+ end
1446
+
1447
+ it 'should display correct color field in erb' do
1448
+ get "/erb/form_for"
1449
+ assert_response_has_tag '#demo input[type=color]', :id => 'markup_user_color', :value => "#ff0000"
1450
+ end
1451
+
1452
+ it 'should display correct color field in slim' do
1453
+ get "/slim/form_for"
1454
+ assert_response_has_tag '#demo input[type=color]', :id => 'markup_user_color', :value => "#ff0000"
1214
1455
  end
1215
1456
  end
1216
1457
  end