padrino-helpers 0.12.9 → 0.13.0.beta1

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 +5 -13
  2. data/lib/padrino-helpers.rb +2 -2
  3. data/lib/padrino-helpers/asset_tag_helpers.rb +18 -26
  4. data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +3 -56
  5. data/lib/padrino-helpers/form_builder/standard_form_builder.rb +1 -1
  6. data/lib/padrino-helpers/form_helpers.rb +11 -227
  7. data/lib/padrino-helpers/form_helpers/options.rb +5 -7
  8. data/lib/padrino-helpers/output_helpers.rb +1 -1
  9. data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
  10. data/lib/padrino-helpers/output_helpers/erb_handler.rb +1 -2
  11. data/lib/padrino-helpers/render_helpers.rb +2 -23
  12. data/lib/padrino-helpers/tag_helpers.rb +1 -14
  13. data/lib/padrino/rendering.rb +4 -56
  14. data/lib/padrino/rendering/erb_template.rb +0 -12
  15. data/lib/padrino/rendering/erubis_template.rb +1 -1
  16. data/padrino-helpers.gemspec +1 -1
  17. data/test/fixtures/markup_app/views/form_for.erb +0 -28
  18. data/test/fixtures/markup_app/views/form_for.haml +0 -22
  19. data/test/fixtures/markup_app/views/form_for.slim +0 -21
  20. data/test/fixtures/markup_app/views/form_tag.erb +0 -21
  21. data/test/fixtures/markup_app/views/form_tag.haml +0 -14
  22. data/test/fixtures/markup_app/views/form_tag.slim +0 -14
  23. data/test/helper.rb +17 -6
  24. data/test/test_asset_tag_helpers.rb +92 -110
  25. data/test/test_form_builder.rb +450 -691
  26. data/test/test_form_helpers.rb +457 -770
  27. data/test/test_format_helpers.rb +37 -17
  28. data/test/test_helpers.rb +0 -8
  29. data/test/test_output_helpers.rb +72 -72
  30. data/test/test_render_helpers.rb +100 -142
  31. data/test/test_rendering.rb +1 -58
  32. data/test/test_tag_helpers.rb +39 -41
  33. metadata +118 -34
  34. data/lib/padrino-helpers/form_builder/deprecated_builder_methods.rb +0 -79
@@ -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_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
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
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_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
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
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_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]')
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 }
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_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post')
55
- assert_html_has_tag(actual_html, 'span', :content => "bar")
54
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
55
+ assert_has_tag('span', :content => "bar") { actual_html }
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_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true')
60
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true') { actual_html }
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_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')
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 }
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_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')
78
+ assert_has_no_tag(:form, :as => 'customer') { actual_html }
79
+ assert_has_tag(:input, :type => 'text', :name => 'customer[first_name]', :id => 'customer_first_name') { actual_html }
80
+ assert_has_tag(:input, :type => 'text', :name => 'customer[role_types_attributes][0][name]', :id => 'customer_role_types_attributes_0_name') { actual_html }
81
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_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')
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 }
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_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')
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 }
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_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')
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 }
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_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
103
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
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_html_has_tag(actual_html, 'form p input[type=text]')
113
+ assert_has_tag('form p input[type=text]') { actual_html }
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
- 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'
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'
126
126
  end
127
127
 
128
128
  it 'should display correct form in erb' do
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'
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'
134
134
  end
135
135
 
136
136
  it 'should display correct form in slim' do
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'
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'
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_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid')
146
+ assert_has_tag(:input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid') {actual_html }
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_html_has_no_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid')
151
+ assert_has_no_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid') {actual_html }
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_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name')
158
+ assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name') { actual_html }
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_html_has_tag(actual_html, :input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name')
163
+ assert_has_tag(:input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name') { actual_html }
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
- 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]'
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]'
186
186
  end
187
187
 
188
188
  it 'should display correct simple fields in erb' do
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]'
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]'
194
194
  end
195
195
 
196
196
  it 'should display correct simple fields in slim' do
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]'
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]'
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_empty actual_html
212
+ assert actual_html.blank?
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_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")
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 }
222
222
  end
223
223
 
224
224
  it 'should display correct form in haml' do
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'
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'
235
235
  end
236
236
 
237
237
  it 'should display correct form in erb' do
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'
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'
248
248
  end
249
249
 
250
250
  it 'should display correct form in slim' do
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'
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'
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_empty actual_html
267
+ assert actual_html.blank?
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_html_has_tag(actual_html, 'span.error', :content => "foo must be present bar")
272
+ assert_has_tag('span.error', :content => "foo must be present bar") { actual_html }
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_html_has_tag(actual_html, 'span.error', :content => "foo must be bob bar")
278
+ assert_has_tag('span.error', :content => "foo must be bob bar") { actual_html }
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_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')
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 }
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_html_has_tag(actual_html, 'label', :class => 'large', :for => 'user_admin', :content => "Admin: ")
292
- assert_html_has_tag(actual_html, 'label input[type=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 }
293
293
  end
294
294
 
295
295
  it 'should display correct label in haml' do
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'
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'
300
300
  end
301
301
 
302
302
  it 'should display correct label in erb' do
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'
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'
307
307
  end
308
308
 
309
309
  it 'should display correct label in slim' do
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'
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'
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_html_has_tag(actual_html, 'input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]')
320
+ assert_has_tag('input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]') { actual_html }
321
321
  end
322
322
 
323
323
  it 'should display correct hidden field in haml' do
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]'
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]'
327
327
  end
328
328
 
329
329
  it 'should display correct hidden field in erb' do
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]'
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]'
333
333
  end
334
334
 
335
335
  it 'should display correct hidden field in slim' do
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]'
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]'
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_html_has_tag(actual_html, 'input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]')
345
+ assert_has_tag('input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
346
346
  end
347
347
 
348
348
  it 'should display correct text field in haml' do
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]'
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]'
352
352
  end
353
353
 
354
354
  it 'should display correct text field in erb' do
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]'
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]'
358
358
  end
359
359
 
360
360
  it 'should display correct text field in slim' do
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]'
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]'
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_html_has_tag(actual_html, 'input.numeric[type=number]', :id => 'user_age', :name => 'user[age]')
370
+ assert_has_tag('input.numeric[type=number]', :id => 'user_age', :name => 'user[age]') { actual_html }
371
371
  end
372
372
 
373
373
  it 'should display correct number field in haml' do
374
- get "/haml/form_for"
375
- assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
374
+ visit '/haml/form_for'
375
+ assert_have_selector '#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
- get "/erb/form_for"
380
- assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
379
+ visit '/erb/form_for'
380
+ assert_have_selector '#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
- get "/slim/form_for"
385
- assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
384
+ visit '/slim/form_for'
385
+ assert_have_selector '#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_html_has_tag(actual_html, 'input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]')
392
+ assert_has_tag('input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]') { actual_html }
393
393
  end
394
394
 
395
395
  it 'should display correct telephone field in haml' do
396
- get "/haml/form_for"
397
- assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
396
+ visit '/haml/form_for'
397
+ assert_have_selector '#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
- get "/erb/form_for"
402
- assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
401
+ visit '/erb/form_for'
402
+ assert_have_selector '#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
- get "/slim/form_for"
407
- assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
406
+ visit '/slim/form_for'
407
+ assert_have_selector '#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_html_has_tag(actual_html, 'input.string[type=search]', :id => 'user_search', :name => 'user[search]')
414
+ assert_has_tag('input.string[type=search]', :id => 'user_search', :name => 'user[search]') { actual_html }
415
415
  end
416
416
 
417
417
  it 'should display correct search field in haml' do
418
- get "/haml/form_for"
419
- assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
418
+ visit '/haml/form_for'
419
+ assert_have_selector '#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
- get "/erb/form_for"
424
- assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
423
+ visit '/erb/form_for'
424
+ assert_have_selector '#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
- get "/slim/form_for"
429
- assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
428
+ visit '/slim/form_for'
429
+ assert_have_selector '#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_html_has_tag(actual_html, 'input.string[type=email]', :id => 'user_email', :name => 'user[email]')
436
+ assert_has_tag('input.string[type=email]', :id => 'user_email', :name => 'user[email]') { actual_html }
437
437
  end
438
438
 
439
439
  it 'should display correct email field in haml' do
440
- get "/haml/form_for"
441
- assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
440
+ visit '/haml/form_for'
441
+ assert_have_selector '#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
- get "/erb/form_for"
446
- assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
445
+ visit '/erb/form_for'
446
+ assert_have_selector '#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
- get "/slim/form_for"
451
- assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
450
+ visit '/slim/form_for'
451
+ assert_have_selector '#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_html_has_tag(actual_html, 'input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]')
458
+ assert_has_tag('input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]') { actual_html }
459
459
  end
460
460
 
461
461
  it 'should display correct url field in haml' do
462
- get "/haml/form_for"
463
- assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
462
+ visit '/haml/form_for'
463
+ assert_have_selector '#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
- get "/erb/form_for"
468
- assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
467
+ visit '/erb/form_for'
468
+ assert_have_selector '#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
- get "/slim/form_for"
473
- assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
472
+ visit '/slim/form_for'
473
+ assert_have_selector '#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_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')
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 }
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_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]')
486
+ assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]') { actual_html }
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_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]')
492
+ assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
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_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]')
498
+ assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
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_html_has_no_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
504
+ assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
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_html_has_no_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
510
+ assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
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_html_has_tag(actual_html, 'input[type=hidden]', :name => 'user[show_favorites]', :value => 'false')
515
+ assert_has_tag('input[type=hidden]', :name => 'user[show_favorites]', :value => 'false') { actual_html }
516
516
  end
517
517
 
518
518
  it 'should display correct checkbox in haml' do
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]'
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]'
521
521
  end
522
522
 
523
523
  it 'should display correct checkbox in erb' do
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]'
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]'
526
526
  end
527
527
 
528
528
  it 'should display correct checkbox in slim' do
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]'
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]'
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_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]')
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 }
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_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]')
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 }
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_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]')
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 }
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_html_has_tag(radios, 'input[type=radio][value="1"][checked]')
561
- assert_html_has_no_tag(radios, 'input[type=radio][value="2"][checked]')
560
+ assert_has_tag('input[type=radio][value="1"][checked]') { radios }
561
+ assert_has_no_tag('input[type=radio][value="2"][checked]') { radios }
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_html_has_tag(actual_html, 'input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male')
568
+ assert_has_tag('input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male') { actual_html }
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_html_has_tag(actual_html, 'input[type=radio]', :checked => 'checked', :name => 'user[gender]')
573
+ assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
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_html_has_tag(actual_html, 'input[type=radio]', :checked => 'checked', :name => 'user[gender]')
579
+ assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
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_html_has_no_tag(actual_html, 'input[type=radio]', :checked => 'checked')
585
+ assert_has_no_tag('input[type=radio]', :checked => 'checked') { actual_html }
586
586
  end
587
587
 
588
588
  it 'should display correct radio button in haml' do
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'
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'
593
593
  end
594
594
 
595
595
  it 'should display correct radio button in erb' do
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'
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'
600
600
  end
601
601
 
602
602
  it 'should display correct radio button in slim' do
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'
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'
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_html_has_tag(actual_html, 'textarea.large', :id => 'user_about', :name => 'user[about]')
613
+ assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html }
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_html_has_tag(actual_html, 'textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6')
618
+ assert_has_tag('textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6') { actual_html }
619
619
  end
620
620
 
621
621
  it 'should display correct text_area in haml' do
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'
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'
625
625
  end
626
626
 
627
627
  it 'should display correct text_area in erb' do
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'
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'
631
631
  end
632
632
 
633
633
  it 'should display correct text_area in slim' do
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'
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'
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_html_has_tag(actual_html, 'input.large[type=password]', :id => 'user_code', :name => 'user[code]')
643
+ assert_has_tag('input.large[type=password]', :id => 'user_code', :name => 'user[code]') { actual_html }
644
644
  end
645
645
 
646
646
  it 'should display correct password_field in haml' do
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]'
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]'
650
650
  end
651
651
 
652
652
  it 'should display correct password_field in erb' do
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]'
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]'
656
656
  end
657
657
 
658
658
  it 'should display correct password_field in slim' do
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]'
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]'
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_html_has_tag(actual_html, 'input.large[type=file]', :id => 'user_photo', :name => 'user[photo]')
668
+ assert_has_tag('input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
669
669
  end
670
670
 
671
671
  it 'should display correct file_field in haml' do
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'
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'
675
675
  end
676
676
 
677
677
  it 'should display correct file_field in erb' do
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'
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'
681
681
  end
682
682
 
683
683
  it 'should display correct file_field in slim' do
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'
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'
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_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
691
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
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_html_has_no_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
696
+ assert_has_no_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
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_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')
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 }
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_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')
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 }
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_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')
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 }
726
726
  end
727
727
 
728
728
  it 'should display correct select html with multiple selected items' do
@@ -730,95 +730,92 @@ 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_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')
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 }
737
737
  end
738
738
 
739
- it 'should display correct select html with include_blank true' do
739
+ it 'should display correct select html with include_blank' do
740
740
  actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => true)
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
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 }
748
745
  actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => 'Select')
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 => '')
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 }
753
750
  end
754
751
 
755
752
  it 'should display correct select html with collection passed in' do
756
753
  actual_html = standard_builder.select(:role, :collection => @user.role_types, :fields => [:name, :id])
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')
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 }
762
759
  end
763
760
 
764
761
  it 'should display correct select in haml' do
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'
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'
768
765
  end
769
766
 
770
767
  it 'should display correct select in erb' do
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'
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'
774
771
  end
775
772
 
776
773
  it 'should display correct select in slim' do
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'
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'
780
777
  end
781
778
  end
782
779
 
783
780
  describe 'for #submit method' do
784
781
  it 'should display correct submit button html with no options' do
785
782
  actual_html = standard_builder.submit
786
- assert_html_has_tag(actual_html, 'input[type=submit]', :value => "Submit")
783
+ assert_has_tag('input[type=submit]', :value => "Submit") { actual_html }
787
784
  end
788
785
 
789
786
 
790
787
  it 'should display correct submit button html with no caption' do
791
788
  actual_html = standard_builder.submit(:class => 'btn')
792
- assert_html_has_tag(actual_html, 'input.btn[type=submit]', :value => "Submit")
789
+ assert_has_tag('input.btn[type=submit]', :value => "Submit") { actual_html }
793
790
  end
794
791
 
795
792
  it 'should display correct submit button html with nil caption' do
796
793
  actual_html = standard_builder.submit(nil, :class => 'btn')
797
- assert_html_has_tag(actual_html, 'input.btn[type=submit]')
794
+ assert_has_tag('input.btn[type=submit]') { actual_html }
798
795
  assert actual_html !~ %r{ value \* = }x
799
796
  end
800
797
 
801
798
  it 'should display correct submit button html' do
802
799
  actual_html = standard_builder.submit("Commit", :class => 'large')
803
- assert_html_has_tag(actual_html, 'input.large[type=submit]', :value => "Commit")
800
+ assert_has_tag('input.large[type=submit]', :value => "Commit") { actual_html }
804
801
  end
805
802
 
806
803
  it 'should display correct submit button in haml' do
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"
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"
810
807
  end
811
808
 
812
809
  it 'should display correct submit button in erb' do
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"
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"
816
813
  end
817
814
 
818
815
  it 'should display correct submit button in slim' do
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"
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"
822
819
  end
823
820
  end
824
821
 
@@ -829,30 +826,30 @@ describe "FormBuilder" do
829
826
 
830
827
  it 'should display correct image submit button html with no options' do
831
828
  actual_html = standard_builder.image_submit('buttons/ok.png')
832
- assert_html_has_tag(actual_html, 'input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}")
829
+ assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
833
830
  end
834
831
 
835
832
  it 'should display correct image submit button html' do
836
833
  actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
837
- assert_html_has_tag(actual_html, 'input.large[type=image]', :src => "/system/ok.png")
834
+ assert_has_tag('input.large[type=image]', :src => "/system/ok.png") { actual_html }
838
835
  end
839
836
 
840
837
  it 'should display correct image submit button in haml' do
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}"
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}"
844
841
  end
845
842
 
846
843
  it 'should display correct image submit button in erb' do
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}"
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}"
850
847
  end
851
848
 
852
849
  it 'should display correct image submit button in slim' do
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}"
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}"
856
853
  end
857
854
  end
858
855
 
@@ -873,10 +870,10 @@ describe "FormBuilder" do
873
870
  child_form.text_field(:number) +
874
871
  child_form.check_box('_destroy')
875
872
  end
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')
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 }
880
877
  end
881
878
 
882
879
  it 'should display nested children fields one-to-many within form' do
@@ -886,15 +883,15 @@ describe "FormBuilder" do
886
883
  html << child_form.text_field(:name)
887
884
  end
888
885
  # Address 1 (Saved)
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]')
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 }
893
890
  # Address 2 (New)
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')
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 }
898
895
  end
899
896
 
900
897
  it 'should display fields for explicit instance object' do
@@ -904,10 +901,10 @@ describe "FormBuilder" do
904
901
  html << child_form.text_field(:name)
905
902
  html << child_form.check_box('_destroy')
906
903
  end
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')
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 }
911
908
  end
912
909
 
913
910
  it 'should display fields for collection object' do
@@ -918,15 +915,15 @@ describe "FormBuilder" do
918
915
  child_form.check_box('_destroy')
919
916
  end
920
917
  # Address 1
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]')
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 }
925
922
  # Address 3
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')
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 }
930
927
  end
931
928
 
932
929
  it 'should display fields for arbitrarily deep nested forms' do
@@ -937,8 +934,8 @@ describe "FormBuilder" do
937
934
  second_child_form.check_box('_destroy')
938
935
  end
939
936
  end
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]')
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 }
942
939
  end
943
940
 
944
941
  it 'should display fields for nested forms with custom indices' do
@@ -954,59 +951,59 @@ describe "FormBuilder" do
954
951
  html
955
952
  end
956
953
 
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]')
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 }
959
956
  end
960
957
 
961
958
  it 'should display nested children fields in erb' do
962
- get "/erb/fields_for"
959
+ visit '/erb/fields_for'
963
960
  # Telephone
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")
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")
966
963
  # Address 1 (Saved)
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]')
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]')
971
968
  # Address 2 (New)
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')
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')
976
973
  end
977
974
 
978
975
  it 'should display nested children fields in haml' do
979
- get "/haml/fields_for"
976
+ visit '/haml/fields_for'
980
977
  # Telephone
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")
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")
983
980
  # Address 1 (Saved)
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]')
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]')
988
985
  # Address 2 (New)
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')
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')
993
990
  end
994
991
 
995
992
  it 'should display nested children fields in slim' do
996
- get "/slim/fields_for"
993
+ visit '/slim/fields_for'
997
994
  # Telephone
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")
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")
1000
997
  # Address 1 (Saved)
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]')
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]')
1005
1002
  # Address 2 (New)
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')
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')
1010
1007
  end
1011
1008
  end
1012
1009
 
@@ -1017,182 +1014,182 @@ describe "FormBuilder" do
1017
1014
  describe 'for #text_field_block method' do
1018
1015
  it 'should display correct text field block html' do
1019
1016
  actual_html = standard_builder.text_field_block(:first_name, :class => 'large', :caption => "FName")
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]')
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 }
1022
1019
  end
1023
1020
 
1024
1021
  it 'should display correct text field block in haml' do
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'
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'
1028
1025
  end
1029
1026
 
1030
1027
  it 'should display correct text field block in erb' do
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'
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'
1034
1031
  end
1035
1032
 
1036
1033
  it 'should display correct text field block in slim' do
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'
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'
1040
1037
  end
1041
1038
  end
1042
1039
 
1043
1040
  describe 'for #text_area_block method' do
1044
1041
  it 'should display correct text area block html' do
1045
1042
  actual_html = standard_builder.text_area_block(:about, :class => 'large', :caption => "About Me")
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]')
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 }
1048
1045
  end
1049
1046
 
1050
1047
  it 'should display correct text area block in haml' do
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'
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'
1054
1051
  end
1055
1052
 
1056
1053
  it 'should display correct text area block in erb' do
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'
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'
1060
1057
  end
1061
1058
 
1062
1059
  it 'should display correct text area block in slim' do
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'
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'
1066
1063
  end
1067
1064
  end
1068
1065
 
1069
1066
  describe 'for #password_field_block method' do
1070
1067
  it 'should display correct password field block html' do
1071
1068
  actual_html = standard_builder.password_field_block(:keycode, :class => 'large', :caption => "Code: ")
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]')
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 }
1074
1071
  end
1075
1072
 
1076
1073
  it 'should display correct password field block in haml' do
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'
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'
1080
1077
  end
1081
1078
 
1082
1079
  it 'should display correct password field block in erb' do
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'
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'
1086
1083
  end
1087
1084
 
1088
1085
  it 'should display correct password field block in slim' do
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'
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'
1092
1089
  end
1093
1090
  end
1094
1091
 
1095
1092
  describe 'for #file_field_block method' do
1096
1093
  it 'should display correct file field block html' do
1097
1094
  actual_html = standard_builder.file_field_block(:photo, :class => 'large', :caption => "Photo: ")
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]')
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 }
1100
1097
  end
1101
1098
 
1102
1099
  it 'should display correct file field block in haml' do
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'
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'
1106
1103
  end
1107
1104
 
1108
1105
  it 'should display correct file field block in erb' do
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'
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'
1112
1109
  end
1113
1110
 
1114
1111
  it 'should display correct file field block in slim' do
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'
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'
1118
1115
  end
1119
1116
  end
1120
1117
 
1121
1118
  describe 'for #check_box_block method' do
1122
1119
  it 'should display correct check box block html' do
1123
1120
  actual_html = standard_builder.check_box_block(:remember_me, :class => 'large', :caption => "Remember session?")
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]')
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 }
1126
1123
  end
1127
1124
 
1128
1125
  it 'should display correct check box block in haml' do
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]'
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]'
1132
1129
  end
1133
1130
 
1134
1131
  it 'should display correct check box block in erb' do
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]'
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]'
1138
1135
  end
1139
1136
 
1140
1137
  it 'should display correct check box block in slim' do
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]'
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]'
1144
1141
  end
1145
1142
  end
1146
1143
 
1147
1144
  describe 'for #select_block method' do
1148
1145
  it 'should display correct select_block block html' do
1149
1146
  actual_html = standard_builder.select_block(:country, :options => ['USA', 'Canada'], :class => 'large', :caption => "Your country")
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')
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 }
1154
1151
  end
1155
1152
 
1156
1153
  it 'should display correct select_block block in haml' do
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'
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'
1162
1159
  end
1163
1160
 
1164
1161
  it 'should display correct select_block block in erb' do
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'
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'
1168
1165
  end
1169
1166
 
1170
1167
  it 'should display correct select_block block in slim' do
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'
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'
1174
1171
  end
1175
1172
  end
1176
1173
 
1177
1174
  describe 'for #submit_block method' do
1178
1175
  it 'should display correct submit block html' do
1179
1176
  actual_html = standard_builder.submit_block("Update", :class => 'large')
1180
- assert_html_has_tag(actual_html, 'p input.large[type=submit]', :value => 'Update')
1177
+ assert_has_tag('p input.large[type=submit]', :value => 'Update') { actual_html }
1181
1178
  end
1182
1179
 
1183
1180
  it 'should display correct submit block in haml' do
1184
- get "/haml/form_for"
1185
- assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
1181
+ visit '/haml/form_for'
1182
+ assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
1186
1183
  end
1187
1184
 
1188
1185
  it 'should display correct submit block in erb' do
1189
- get "/erb/form_for"
1190
- assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
1186
+ visit '/erb/form_for'
1187
+ assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
1191
1188
  end
1192
1189
 
1193
1190
  it 'should display correct submit block in slim' do
1194
- get "/slim/form_for"
1195
- assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
1191
+ visit '/slim/form_for'
1192
+ assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
1196
1193
  end
1197
1194
  end
1198
1195
 
@@ -1203,255 +1200,17 @@ describe "FormBuilder" do
1203
1200
 
1204
1201
  it 'should display correct image submit block html' do
1205
1202
  actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
1206
- assert_html_has_tag(actual_html, 'p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}")
1203
+ assert_has_tag('p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
1207
1204
  end
1208
1205
 
1209
1206
  it 'should display correct image submit block in haml' do
1210
- get "/haml/form_for"
1211
- assert_response_has_tag '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
1207
+ visit '/haml/form_for'
1208
+ assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
1212
1209
  end
1213
1210
 
1214
1211
  it 'should display correct image submit block in slim' do
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"
1212
+ visit '/slim/form_for'
1213
+ assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
1455
1214
  end
1456
1215
  end
1457
1216
  end