foundation_rails_helper 2.0.0 → 3.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe "FoundationRailsHelper::FormHelper" do
@@ -20,22 +21,24 @@ describe "FoundationRailsHelper::FormHelper" do
20
21
  end
21
22
  end
22
23
 
23
- it "should display labels if auto_labels: true is set" do
24
+ it "should display labels if auto_labels option is true" do
24
25
  form_for(@author, auto_labels: true) do |builder|
25
26
  node = Capybara.string builder.text_field(:login)
26
27
  expect(node).to have_css('label[for="author_login"]', text: "Login")
27
28
  end
28
29
  end
29
30
 
30
- it "should not display labels by if there are options without auto_labels: false" do
31
+ it "should display labels if no auto_labels option" do
31
32
  form_for(@author, html: { class: "myclass" }) do |builder|
32
33
  node = Capybara.string builder.text_field(:login)
33
34
  expect(node).to have_css('label[for="author_login"]', text: "Login")
34
35
  end
35
36
  end
36
37
 
37
- it "should not display labels if there are options with auto_labels: false" do
38
- form_for(@author, html: { class: "myclass" }, auto_labels: false) do |builder|
38
+ it "shouldn't display labels if auto_labels option is false" do
39
+ options = { html: { class: "myclass" }, auto_labels: false }
40
+
41
+ form_for(@author, options) do |builder|
39
42
  node = Capybara.string builder.text_field(:login)
40
43
  expect(node).to_not have_css('label[for="author_login"]', text: "Login")
41
44
  end
@@ -55,6 +58,16 @@ describe "FoundationRailsHelper::FormHelper" do
55
58
  end
56
59
  end
57
60
 
61
+ it "shouldn't display labels if :auto_labels false at configuration time" do
62
+ allow(FoundationRailsHelper)
63
+ .to receive_message_chain(:configuration, :auto_labels).and_return(false)
64
+
65
+ form_for(@author) do |builder|
66
+ node = Capybara.string builder.text_field(:login)
67
+ expect(node).not_to have_css('label[for="author_login"]', text: "Login")
68
+ end
69
+ end
70
+
58
71
  describe "label" do
59
72
  context "when there aren't any errors and no class option is passed" do
60
73
  it "should not have a class attribute" do
@@ -69,7 +82,9 @@ describe "FoundationRailsHelper::FormHelper" do
69
82
  form_for(@author) do |builder|
70
83
  allow(@author).to receive(:errors).and_return(login: ["required"])
71
84
  node = Capybara.string builder.text_field(:login)
72
- error_class = node.find("label")["class"].split(/\s+/).keep_if { |v| v == "error" }
85
+ error_class = node.find("label")["class"].split(/\s+/).keep_if do |v|
86
+ v == "is-invalid-label"
87
+ end
73
88
  expect(error_class.size).to eq 1
74
89
  end
75
90
  end
@@ -78,8 +93,10 @@ describe "FoundationRailsHelper::FormHelper" do
78
93
  describe "prefix" do
79
94
  context "when input field has a prefix" do
80
95
  before do
96
+ prefix = { small: 2, medium: 4, large: 6, value: "Prefix" }
97
+
81
98
  form_for(@author) do |builder|
82
- @node = Capybara.string builder.text_field(:login, prefix: { small: 2, medium: 4, large: 6, value: "Prefix" })
99
+ @node = Capybara.string builder.text_field(:login, prefix: prefix)
83
100
  end
84
101
  end
85
102
 
@@ -88,11 +105,14 @@ describe "FoundationRailsHelper::FormHelper" do
88
105
  end
89
106
 
90
107
  it "wraps prefix in the div with the right column size" do
91
- expect(@node.find(".row.collapse")).to have_css("div.small-2.medium-4.large-6.columns")
108
+ expect(@node.find(".row.collapse"))
109
+ .to have_css("div.small-2.medium-4.large-6.columns")
92
110
  end
93
111
 
94
112
  it "creates prefix span with right value" do
95
- expect(@node.find(".row.collapse").find("div.small-2.medium-4.large-6.columns").find("span").text).to eq "Prefix"
113
+ selector = "div.small-2.medium-4.large-6.columns"
114
+ expect(@node.find(".row.collapse").find(selector).find("span").text)
115
+ .to eq("Prefix")
96
116
  end
97
117
 
98
118
  it "creates prefix span with right class" do
@@ -100,11 +120,15 @@ describe "FoundationRailsHelper::FormHelper" do
100
120
  end
101
121
 
102
122
  it "wraps input in the div with the right column size" do
103
- expect(@node.find(".row.collapse")).to have_css("div.small-10.medium-8.large-6.columns")
123
+ expect(@node.find(".row.collapse"))
124
+ .to have_css("div.small-10.medium-8.large-6.columns")
104
125
  end
105
126
 
106
127
  it "has right value for the input" do
107
- expect(@node.find(".row.collapse").find("div.small-10.medium-8.large-6.columns")).to have_css('input[type="text"][name="author[login]"]')
128
+ selector = "div.small-10.medium-8.large-6.columns"
129
+
130
+ expect(@node.find(".row.collapse").find(selector))
131
+ .to have_css('input[type="text"][name="author[login]"]')
108
132
  end
109
133
  end
110
134
 
@@ -121,8 +145,10 @@ describe "FoundationRailsHelper::FormHelper" do
121
145
  describe "postfix" do
122
146
  context "when input field has a postfix" do
123
147
  before do
148
+ postfix = { small: 2, medium: 4, large: 6, value: "Postfix" }
149
+
124
150
  form_for(@author) do |builder|
125
- @node = Capybara.string builder.text_field(:login, postfix: { small: 2, medium: 4, large: 6, value: "Postfix" })
151
+ @node = Capybara.string builder.text_field(:login, postfix: postfix)
126
152
  end
127
153
  end
128
154
 
@@ -131,11 +157,15 @@ describe "FoundationRailsHelper::FormHelper" do
131
157
  end
132
158
 
133
159
  it "wraps postfix in the div with the right column size" do
134
- expect(@node.find(".row.collapse")).to have_css("div.small-2.medium-4.large-6.columns")
160
+ expect(@node.find(".row.collapse"))
161
+ .to have_css("div.small-2.medium-4.large-6.columns")
135
162
  end
136
163
 
137
164
  it "creates postfix span with right value" do
138
- expect(@node.find(".row.collapse").find("div.small-2.medium-4.large-6.columns").find("span").text).to eq "Postfix"
165
+ selector = "div.small-2.medium-4.large-6.columns"
166
+
167
+ expect(@node.find(".row.collapse").find(selector).find("span").text)
168
+ .to eq("Postfix")
139
169
  end
140
170
 
141
171
  it "creates postfix span with right class" do
@@ -143,44 +173,65 @@ describe "FoundationRailsHelper::FormHelper" do
143
173
  end
144
174
 
145
175
  it "wraps input in the div with the right column size" do
146
- expect(@node.find(".row.collapse")).to have_css("div.small-10.medium-8.large-6.columns")
176
+ expect(@node.find(".row.collapse"))
177
+ .to have_css("div.small-10.medium-8.large-6.columns")
147
178
  end
148
179
 
149
180
  it "has right value for the input" do
150
- expect(@node.find(".row.collapse").find("div.small-10.medium-8.large-6.columns")).to have_css('input[type="text"][name="author[login]"]')
181
+ selector = "div.small-10.medium-8.large-6.columns"
182
+
183
+ expect(@node.find(".row.collapse").find(selector))
184
+ .to have_css('input[type="text"][name="author[login]"]')
151
185
  end
152
186
  end
153
187
 
154
188
  context "with only one column size" do
155
189
  before do
156
190
  form_for(@author) do |builder|
157
- @small_node = Capybara.string builder.text_field(:login, postfix: { small: 2, value: "Postfix" })
158
- @medium_node = Capybara.string builder.text_field(:login, postfix: { medium: 2, value: "Postfix" })
159
- @large_node = Capybara.string builder.text_field(:login, postfix: { large: 2, value: "Postfix" })
191
+ @small_node = Capybara.string(
192
+ builder.text_field(:login, postfix: { small: 2, value: "Postfix" })
193
+ )
194
+ @medium_node = Capybara.string(
195
+ builder.text_field(:login, postfix: { medium: 2, value: "Postfix" })
196
+ )
197
+ @large_node = Capybara.string(
198
+ builder.text_field(:login, postfix: { large: 2, value: "Postfix" })
199
+ )
160
200
  end
161
201
  end
162
202
 
163
203
  it "wraps postfix in the div with the right column size" do
164
- expect(@small_node.find(".row.collapse")).to have_css("div.small-2.columns")
165
- expect(@medium_node.find(".row.collapse")).to have_css("div.medium-2.columns")
166
- expect(@large_node.find(".row.collapse")).to have_css("div.large-2.columns")
204
+ expect(@small_node.find(".row.collapse"))
205
+ .to have_css("div.small-2.columns")
206
+ expect(@medium_node.find(".row.collapse"))
207
+ .to have_css("div.medium-2.columns")
208
+ expect(@large_node.find(".row.collapse"))
209
+ .to have_css("div.large-2.columns")
167
210
  end
168
211
 
169
212
  it "wraps input in the div with the right column size" do
170
- expect(@small_node.find(".row.collapse")).to have_css("div.small-10.columns")
171
- expect(@medium_node.find(".row.collapse")).to have_css("div.medium-10.columns")
172
- expect(@large_node.find(".row.collapse")).to have_css("div.large-10.columns")
213
+ expect(@small_node.find(".row.collapse"))
214
+ .to have_css("div.small-10.columns")
215
+ expect(@medium_node.find(".row.collapse"))
216
+ .to have_css("div.medium-10.columns")
217
+ expect(@large_node.find(".row.collapse"))
218
+ .to have_css("div.large-10.columns")
173
219
  end
174
220
 
175
221
  it "excludes other classes from the prefix" do
176
- expect(@small_node.find(".row.collapse")).to_not have_css("div.medium-2.columns")
177
- expect(@small_node.find(".row.collapse")).to_not have_css("div.large-2.columns")
222
+ expect(@small_node.find(".row.collapse"))
223
+ .to_not have_css("div.medium-2.columns")
224
+ expect(@small_node.find(".row.collapse"))
225
+ .to_not have_css("div.large-2.columns")
178
226
  end
179
227
 
180
228
  it "excludes other classes from the input" do
181
- expect(@small_node.find(".row.collapse")).to have_css("div.small-10.columns")
182
- expect(@small_node.find(".row.collapse")).to_not have_css("div.medium-12.columns")
183
- expect(@small_node.find(".row.collapse")).to_not have_css("div.large-12.columns")
229
+ expect(@small_node.find(".row.collapse"))
230
+ .to have_css("div.small-10.columns")
231
+ expect(@small_node.find(".row.collapse"))
232
+ .to_not have_css("div.medium-12.columns")
233
+ expect(@small_node.find(".row.collapse"))
234
+ .to_not have_css("div.large-12.columns")
184
235
  end
185
236
  end
186
237
  end
@@ -188,15 +239,19 @@ describe "FoundationRailsHelper::FormHelper" do
188
239
  describe "with both prefix and postfix" do
189
240
  context "when input field has a prefix" do
190
241
  before do
242
+ prefix = { small: 2, medium: 3, large: 4, value: "Prefix" }
243
+ postfix = { small: 2, medium: 3, large: 4, value: "Postfix" }
244
+
191
245
  form_for(@author) do |builder|
192
- @node = Capybara.string builder.text_field(:login,
193
- prefix: { small: 2, medium: 3, large: 4, value: "Prefix" },
194
- postfix: { small: 2, medium: 3, large: 4, value: "Postfix" })
246
+ @node = Capybara.string(
247
+ builder.text_field(:login, prefix: prefix, postfix: postfix)
248
+ )
195
249
  end
196
250
  end
197
251
 
198
252
  it "wraps input in the div with the right column size" do
199
- expect(@node.find(".row.collapse")).to have_css("div.small-8.medium-6.large-4.columns")
253
+ expect(@node.find(".row.collapse"))
254
+ .to have_css("div.small-8.medium-6.large-4.columns")
200
255
  end
201
256
  end
202
257
  end
@@ -223,15 +278,18 @@ describe "FoundationRailsHelper::FormHelper" do
223
278
  it "should generate text_field with class from options" do
224
279
  form_for(@author) do |builder|
225
280
  node = Capybara.string builder.text_field(:login, class: "righteous")
226
- expect(node).to have_css('input.righteous[type="text"][name="author[login]"]')
281
+ expect(node)
282
+ .to have_css('input.righteous[type="text"][name="author[login]"]')
227
283
  end
228
284
  end
229
285
 
230
286
  it "should generate password_field input" do
231
287
  form_for(@author) do |builder|
232
288
  node = Capybara.string builder.password_field(:password)
233
- expect(node).to have_css('label[for="author_password"]', text: "Password")
234
- expect(node).to have_css('input[type="password"][name="author[password]"]')
289
+ expect(node)
290
+ .to have_css('label[for="author_password"]', text: "Password")
291
+ expect(node)
292
+ .to have_css('input[type="password"][name="author[password]"]')
235
293
  expect(node.find_field("author_password").value).to be_nil
236
294
  end
237
295
  end
@@ -266,18 +324,23 @@ describe "FoundationRailsHelper::FormHelper" do
266
324
  it "should generate number_field input" do
267
325
  form_for(@author) do |builder|
268
326
  node = Capybara.string builder.number_field(:some_number)
269
- expect(node).to have_css('label[for="author_some_number"]', text: "Some number")
270
- expect(node).to have_css('input[type="number"][name="author[some_number]"]')
271
- expect(node.find_field("author_some_number").value).to eq @author.some_number
327
+ expect(node)
328
+ .to have_css('label[for="author_some_number"]', text: "Some number")
329
+ expect(node)
330
+ .to have_css('input[type="number"][name="author[some_number]"]')
331
+ expect(node.find_field("author_some_number").value)
332
+ .to eq @author.some_number
272
333
  end
273
334
  end
274
335
 
275
336
  it "should generate text_area input" do
276
337
  form_for(@author) do |builder|
277
338
  node = Capybara.string builder.text_area(:description)
278
- expect(node).to have_css('label[for="author_description"]', text: "Description")
339
+ expect(node)
340
+ .to have_css('label[for="author_description"]', text: "Description")
279
341
  expect(node).to have_css('textarea[name="author[description]"]')
280
- expect(node.find_field("author_description").value.strip).to eq @author.description
342
+ expect(node.find_field("author_description").value.strip)
343
+ .to eq @author.description
281
344
  end
282
345
  end
283
346
 
@@ -291,32 +354,63 @@ describe "FoundationRailsHelper::FormHelper" do
291
354
  end
292
355
 
293
356
  it "should generate select input" do
357
+ choices = [["Choice #1", :a], ["Choice #2", :b]]
358
+
294
359
  form_for(@author) do |builder|
295
- node = Capybara.string builder.select(:description, [["Choice #1", :a], ["Choice #2", :b]])
296
- expect(node).to have_css('label[for="author_description"]', text: "Description")
360
+ node = Capybara.string builder.select(:description, choices)
361
+ expect(node)
362
+ .to have_css('label[for="author_description"]', text: "Description")
297
363
  expect(node).to have_css('select[name="author[description]"]')
298
- expect(node).to have_css('select[name="author[description]"] option[value="a"]', text: "Choice #1")
299
- expect(node).to have_css('select[name="author[description]"] option[value="b"]', text: "Choice #2")
364
+ expect(node)
365
+ .to have_css('select[name="author[description]"] option[value="a"]',
366
+ text: "Choice #1")
367
+ expect(node)
368
+ .to have_css('select[name="author[description]"] option[value="b"]',
369
+ text: "Choice #2")
300
370
  end
301
371
  end
302
372
 
303
373
  it "should generate check_box input" do
374
+ label = 'label[for="author_active"]'
375
+ name = '[name="author[active]"]'
376
+
304
377
  form_for(@author) do |builder|
305
378
  node = Capybara.string builder.check_box(:active)
306
- expect(node).to have_css('label[for="author_active"] input[type="hidden"][name="author[active]"][value="0"]', visible: false)
307
- expect(node).to have_css('label[for="author_active"] input[type="checkbox"][name="author[active]"]')
308
- expect(node).to have_css('label[for="author_active"]', text: "Active")
379
+ expect(node).to have_css(
380
+ "#{label} input[type=\"hidden\"]#{name}[value=\"0\"]",
381
+ visible: false
382
+ )
383
+ expect(node)
384
+ .to have_css("#{label} input[type=\"checkbox\"]#{name}")
385
+ expect(node).to have_css(label, text: "Active")
309
386
  end
310
387
  end
388
+
311
389
  it "should generate check_box input without a label" do
312
390
  form_for(@author) do |builder|
313
391
  node = Capybara.string builder.check_box(:active, label: false)
314
- expect(node).to have_css('input[type="hidden"][name="author[active]"][value="0"]', visible: false)
315
- expect(node).to have_css('input[type="checkbox"][name="author[active]"]')
392
+ expect(node)
393
+ .to have_css('input[type="hidden"][name="author[active]"][value="0"]',
394
+ visible: false)
395
+ expect(node)
396
+ .to have_css('input[type="checkbox"][name="author[active]"]')
316
397
  expect(node).to_not have_css('label[for="author_active"]')
317
398
  end
318
399
  end
319
400
 
401
+ it "should generate check_box input with a label with HTML content" do
402
+ label_text = "Accepts terms and conditions"
403
+
404
+ form_for(@author) do |builder|
405
+ node = Capybara.string(
406
+ builder.check_box(:active, label: "<a href='/'>#{label_text}</a>")
407
+ )
408
+
409
+ expect(node)
410
+ .to have_css('label[for="author_active"] a', text: label_text)
411
+ end
412
+ end
413
+
320
414
  it "should generate radio_button input" do
321
415
  form_for(@author) do |builder|
322
416
  node = Capybara.string builder.radio_button(:active, "ok")
@@ -324,13 +418,19 @@ describe "FoundationRailsHelper::FormHelper" do
324
418
  expect(node).to have_css('input[type="radio"][name="author[active]"]')
325
419
  end
326
420
  end
421
+
327
422
  it "should generate radio_button input with a label" do
328
423
  form_for(@author) do |builder|
329
- node = Capybara.string builder.radio_button(:active, true, label: "Functioning")
330
- expect(node).to have_css('label[for="author_active_true"]', text: "Functioning")
331
- expect(node).to have_css('input[type="radio"][name="author[active]"]')
424
+ node = Capybara.string(
425
+ builder.radio_button(:active, true, label: "Functioning")
426
+ )
427
+ expect(node)
428
+ .to have_css('label[for="author_active_true"]', text: "Functioning")
429
+ expect(node)
430
+ .to have_css('input[type="radio"][name="author[active]"]')
332
431
  end
333
432
  end
433
+
334
434
  it "should generate radio_button without a label" do
335
435
  form_for(@author) do |builder|
336
436
  node = Capybara.string builder.radio_button(:active, "ok", label: false)
@@ -339,88 +439,152 @@ describe "FoundationRailsHelper::FormHelper" do
339
439
  expect(node).to have_css('input[type="radio"][name="author[active]"]')
340
440
  end
341
441
  end
442
+
342
443
  it "should generate radio_button with label options" do
343
444
  form_for(@author) do |builder|
344
- node = Capybara.string builder.radio_button(:active, "ok", class: "very", label_options: { class: "special" })
445
+ node = Capybara.string(
446
+ builder.radio_button(
447
+ :active,
448
+ "ok",
449
+ class: "very",
450
+ label_options: { class: "special" }
451
+ )
452
+ )
453
+
345
454
  expect(node).to have_css('label.special[for="author_active_ok"]')
346
- expect(node).to have_css('input.very[type="radio"][name="author[active]"]')
455
+ expect(node)
456
+ .to have_css('input.very[type="radio"][name="author[active]"]')
347
457
  end
348
458
  end
349
459
 
350
460
  it "should generate date_select input" do
461
+ select = "select#author_birthdate_"
462
+ option = 'option[selected="selected"]'
463
+
351
464
  form_for(@author) do |builder|
352
- node = Capybara.string builder.label(:birthdate) + builder.date_select(:birthdate)
353
- expect(node).to have_css('label[for="author_birthdate"]', text: "Birthdate")
354
- %w(1 2 3).each { |i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
355
- expect(node).to have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
356
- expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
357
- expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
358
- %w(4 5).each { |i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
465
+ node = Capybara.string(
466
+ builder.label(:birthdate) + builder.date_select(:birthdate)
467
+ )
468
+ expect(node)
469
+ .to have_css('label[for="author_birthdate"]', text: "Birthdate")
470
+ %w(1 2 3).each do |i|
471
+ expect(node).to have_css("select[name='author[birthdate(#{i}i)]']")
472
+ end
473
+ expect(node)
474
+ .to have_css("#{select}1i #{option}[value=\"1969\"]")
475
+ expect(node)
476
+ .to have_css("#{select}2i #{option}[value=\"6\"]")
477
+ expect(node)
478
+ .to have_css("#{select}3i #{option}[value=\"18\"]")
479
+ %w(4 5).each do |i|
480
+ expect(node)
481
+ .to_not have_css("select[name='author[birthdate(#{i}i)]']")
482
+ end
359
483
  end
360
484
  end
361
485
 
362
486
  it "should generate date_select input with :discard_year => true" do
363
- form_for(@author) do |builder|
364
- node = Capybara.string builder.label(:birthdate) + builder.date_select(:birthdate, discard_year: true)
365
- expect(node).to have_css('label[for="author_birthdate"]', text: "Birthdate")
366
- %w(2 3).each { |i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
367
- expect(node).to_not have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
368
- expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
369
- expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
370
- %w(1 4 5).each { |i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
487
+ select = "select#author_birthdate_"
488
+ option = 'option[selected="selected"]'
489
+
490
+ form_for(@author) do |builder|
491
+ node = Capybara.string(
492
+ builder.label(:birthdate) +
493
+ builder.date_select(:birthdate, discard_year: true)
494
+ )
495
+ expect(node)
496
+ .to have_css('label[for="author_birthdate"]', text: "Birthdate")
497
+ %w(2 3).each do |i|
498
+ expect(node).to have_css("select[name='author[birthdate(#{i}i)]']")
499
+ end
500
+ expect(node).to_not have_css("#{select}1i #{option}[value=\"1969\"]")
501
+ expect(node).to have_css("#{select}2i #{option}[value=\"6\"]")
502
+ expect(node).to have_css("#{select}3i #{option}[value=\"18\"]")
503
+ %w(1 4 5).each do |i|
504
+ expect(node)
505
+ .to_not have_css("select[name='author[birthdate(#{i}i)]']")
506
+ end
371
507
  end
372
508
  end
373
509
 
374
510
  it "should generate datetime_select input" do
375
- form_for(@author) do |builder|
376
- node = Capybara.string builder.label(:birthdate) + builder.datetime_select(:birthdate)
377
- expect(node).to have_css('label[for="author_birthdate"]', text: "Birthdate")
378
- %w(1 2 3 4 5).each { |i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
379
- expect(node).to have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
380
- expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
381
- expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
382
- expect(node).to have_css('select#author_birthdate_4i option[selected="selected"][value="20"]')
383
- expect(node).to have_css('select#author_birthdate_5i option[selected="selected"][value="30"]')
511
+ select = "select#author_birthdate_"
512
+ option = 'option[selected="selected"]'
513
+
514
+ form_for(@author) do |builder|
515
+ node = Capybara.string(
516
+ builder.label(:birthdate) +
517
+ builder.datetime_select(:birthdate)
518
+ )
519
+ expect(node)
520
+ .to have_css('label[for="author_birthdate"]', text: "Birthdate")
521
+ %w(1 2 3 4 5).each do |i|
522
+ expect(node).to have_css("select[name='author[birthdate(#{i}i)]']")
523
+ end
524
+ expect(node).to have_css("#{select}1i #{option}[value=\"1969\"]")
525
+ expect(node).to have_css("#{select}2i #{option}[value=\"6\"]")
526
+ expect(node).to have_css("#{select}3i #{option}[value=\"18\"]")
527
+ expect(node).to have_css("#{select}4i #{option}[value=\"20\"]")
528
+ expect(node).to have_css("#{select}5i #{option}[value=\"30\"]")
384
529
  end
385
530
  end
386
531
 
387
532
  it "should generate datetime_select input with :discard_year => true" do
388
- form_for(@author) do |builder|
389
- node = Capybara.string builder.label(:birthdate) + builder.datetime_select(:birthdate, discard_year: true)
390
- expect(node).to have_css('label[for="author_birthdate"]', text: "Birthdate")
391
- %w(2 3 4 5).each { |i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
392
- expect(node).to_not have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
393
- expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
394
- expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
395
- expect(node).to have_css('select#author_birthdate_4i option[selected="selected"][value="20"]')
396
- expect(node).to have_css('select#author_birthdate_5i option[selected="selected"][value="30"]')
397
- %w(1).each { |i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
533
+ select = "select#author_birthdate_"
534
+ option = 'option[selected="selected"]'
535
+
536
+ form_for(@author) do |builder|
537
+ node = Capybara.string(
538
+ builder.label(:birthdate) +
539
+ builder.datetime_select(:birthdate, discard_year: true)
540
+ )
541
+ expect(node)
542
+ .to have_css('label[for="author_birthdate"]', text: "Birthdate")
543
+ %w(2 3 4 5).each do |i|
544
+ expect(node).to have_css("select[name='author[birthdate(#{i}i)]']")
545
+ end
546
+ expect(node).to_not have_css("#{select}1i #{option}[value=\"1969\"]")
547
+ expect(node).to have_css("#{select}2i #{option}[value=\"6\"]")
548
+ expect(node).to have_css("#{select}3i #{option}[value=\"18\"]")
549
+ expect(node).to have_css("#{select}4i #{option}[value=\"20\"]")
550
+ expect(node).to have_css("#{select}5i #{option}[value=\"30\"]")
551
+ expect(node).to_not have_css("select[name='author[birthdate(#1i)]']")
398
552
  end
399
553
  end
400
554
 
401
555
  it "should generate time_zone_select input" do
402
556
  form_for(@author) do |builder|
403
- node = Capybara.string builder.label(:time_zone) + builder.time_zone_select(:time_zone)
404
- expect(node).to have_css('label[for="author_time_zone"]', text: "Time zone")
557
+ node = Capybara.string(
558
+ builder.label(:time_zone) + builder.time_zone_select(:time_zone)
559
+ )
560
+ expect(node)
561
+ .to have_css('label[for="author_time_zone"]', text: "Time zone")
405
562
  expect(node).to have_css('select[name="author[time_zone]"]')
406
- expect(node).to have_css('select[name="author[time_zone]"] option[value="Perth"]', text: "(GMT+08:00) Perth")
563
+ expect(node)
564
+ .to have_css('select[name="author[time_zone]"] option[value="Perth"]',
565
+ text: "(GMT+08:00) Perth")
407
566
  end
408
567
  end
409
568
 
410
569
  it "should generate date_field input" do
411
570
  form_for(@author) do |builder|
412
571
  node = Capybara.string builder.date_field(:publish_date)
413
- expect(node).to have_css('label[for="author_publish_date"]', text: "date")
414
- expect(node).to have_css('input[type="date"][name="author[publish_date]"]')
415
- expect(node.find_field("author_publish_date").value).to eq @author.publish_date.to_s
572
+ expect(node)
573
+ .to have_css('label[for="author_publish_date"]', text: "date")
574
+ expect(node)
575
+ .to have_css('input[type="date"][name="author[publish_date]"]')
576
+ expect(node.find_field("author_publish_date").value)
577
+ .to eq @author.publish_date.to_s
416
578
  end
417
579
  end
418
580
 
419
581
  it "should generate datetime_field input" do
420
582
  form_for(@author) do |builder|
421
583
  node = Capybara.string builder.datetime_field(:forty_two)
422
- expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
423
- expect(node).to have_css('input[type^="datetime"][name="author[forty_two]"]')
584
+ expect(node)
585
+ .to have_css('label[for="author_forty_two"]', text: "Forty two")
586
+ expect(node)
587
+ .to have_css('input[type^="datetime"][name="author[forty_two]"]')
424
588
  value = DateTime.parse(node.find_field("author_forty_two").value)
425
589
  expect(value).to eq @author.forty_two.to_s
426
590
  end
@@ -429,99 +593,145 @@ describe "FoundationRailsHelper::FormHelper" do
429
593
  it "should generate datetime_local_field" do
430
594
  form_for(@author) do |builder|
431
595
  node = Capybara.string builder.datetime_local_field(:forty_two)
432
- expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
433
- expect(node).to have_css('input[type="datetime-local"][name="author[forty_two]"]')
434
- expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%Y-%m-%dT%H:%M:%S")
596
+ expect(node)
597
+ .to have_css('label[for="author_forty_two"]', text: "Forty two")
598
+ expect(node)
599
+ .to have_css('input[type="datetime-local"][name="author[forty_two]"]')
600
+ expect(node.find_field("author_forty_two").value)
601
+ .to eq @author.forty_two.strftime("%Y-%m-%dT%H:%M:%S")
435
602
  end
436
603
  end
437
604
 
438
605
  it "should generate month_field input" do
439
606
  form_for(@author) do |builder|
440
607
  node = Capybara.string builder.month_field(:forty_two)
441
- expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
442
- expect(node).to have_css('input[type="month"][name="author[forty_two]"]')
443
- expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%Y-%m")
608
+ expect(node)
609
+ .to have_css('label[for="author_forty_two"]', text: "Forty two")
610
+ expect(node)
611
+ .to have_css('input[type="month"][name="author[forty_two]"]')
612
+ expect(node.find_field("author_forty_two").value)
613
+ .to eq @author.forty_two.strftime("%Y-%m")
444
614
  end
445
615
  end
446
616
 
447
617
  it "should generate week_field" do
448
618
  form_for(@author) do |builder|
449
619
  node = Capybara.string builder.week_field(:forty_two)
450
- expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
451
- expect(node).to have_css('input[type="week"][name="author[forty_two]"]')
452
- expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%Y-W%V")
620
+ expect(node)
621
+ .to have_css('label[for="author_forty_two"]', text: "Forty two")
622
+ expect(node)
623
+ .to have_css('input[type="week"][name="author[forty_two]"]')
624
+ expect(node.find_field("author_forty_two").value)
625
+ .to eq @author.forty_two.strftime("%Y-W%V")
453
626
  end
454
627
  end
455
628
 
456
629
  it "should generate time_field" do
457
630
  form_for(@author) do |builder|
458
631
  node = Capybara.string builder.time_field(:forty_two)
459
- expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
460
- expect(node).to have_css('input[type="time"][name="author[forty_two]"]')
461
- expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%H:%M:%S.%L")
632
+ expect(node)
633
+ .to have_css('label[for="author_forty_two"]', text: "Forty two")
634
+ expect(node)
635
+ .to have_css('input[type="time"][name="author[forty_two]"]')
636
+ expect(node.find_field("author_forty_two").value)
637
+ .to eq @author.forty_two.strftime("%H:%M:%S.%L")
462
638
  end
463
639
  end
464
640
 
465
641
  it "should generate range_field" do
466
642
  form_for(@author) do |builder|
467
643
  node = Capybara.string builder.range_field(:some_number)
468
- expect(node).to have_css('label[for="author_some_number"]', text: "Some number")
469
- expect(node).to have_css('input[type="range"][name="author[some_number]"]')
470
- expect(node.find_field("author_some_number").value).to eq @author.some_number
644
+ expect(node)
645
+ .to have_css('label[for="author_some_number"]', text: "Some number")
646
+ expect(node)
647
+ .to have_css('input[type="range"][name="author[some_number]"]')
648
+ expect(node.find_field("author_some_number").value)
649
+ .to eq @author.some_number
471
650
  end
472
651
  end
473
652
 
474
653
  it "should generate search_field" do
475
654
  form_for(@author) do |builder|
476
655
  node = Capybara.string builder.search_field(:description)
477
- expect(node).to have_css('label[for="author_description"]', text: "Description")
478
- expect(node).to have_css('input[type="search"][name="author[description]"]')
479
- expect(node.find_field("author_description").value).to eq @author.description
656
+ expect(node)
657
+ .to have_css('label[for="author_description"]', text: "Description")
658
+ expect(node)
659
+ .to have_css('input[type="search"][name="author[description]"]')
660
+ expect(node.find_field("author_description").value)
661
+ .to eq @author.description
480
662
  end
481
663
  end
482
664
 
483
665
  it "should generate color_field" do
484
666
  form_for(@author) do |builder|
485
667
  node = Capybara.string builder.color_field(:favorite_color)
486
- expect(node).to have_css('label[for="author_favorite_color"]', text: "Favorite color")
487
- expect(node).to have_css('input[type="color"][name="author[favorite_color]"]')
488
- expect(node.find_field("author_favorite_color").value).to eq @author.favorite_color
668
+ expect(node).to have_css(
669
+ 'label[for="author_favorite_color"]', text: "Favorite color"
670
+ )
671
+ expect(node)
672
+ .to have_css('input[type="color"][name="author[favorite_color]"]')
673
+ expect(node.find_field("author_favorite_color").value)
674
+ .to eq @author.favorite_color
489
675
  end
490
676
  end
491
677
 
492
678
  it "should generate collection_select input" do
679
+ selector = 'select[name="author[favorite_book]"] option'
680
+
493
681
  form_for(@author) do |builder|
494
- node = Capybara.string builder.collection_select(:favorite_book, Book.all, :id, :title)
495
- expect(node).to have_css('label[for="author_favorite_book"]', text: "Favorite book")
682
+ node = Capybara.string(
683
+ builder.collection_select(:favorite_book, Book.all, :id, :title)
684
+ )
685
+ expect(node).to have_css(
686
+ 'label[for="author_favorite_book"]',
687
+ text: "Favorite book"
688
+ )
496
689
  expect(node).to have_css('select[name="author[favorite_book]"]')
497
- expect(node).to have_css('select[name="author[favorite_book]"] option[value="78"]', text: "Gulliver's Travels")
498
- expect(node).to have_css('select[name="author[favorite_book]"] option[value="133"]', text: "Treasure Island")
690
+ expect(node)
691
+ .to have_css("#{selector}[value=\"78\"]", text: "Gulliver's Travels")
692
+ expect(node)
693
+ .to have_css("#{selector}[value=\"133\"]", text: "Treasure Island")
499
694
  end
500
695
  end
501
696
 
502
697
  it "should generate grouped_collection_select input" do
698
+ selector = 'select[name="author[favorite_book]"] optgroup'
699
+
503
700
  form_for(@author) do |builder|
504
- node = Capybara.string builder.grouped_collection_select(:favorite_book, Genre.all, :books, :name, :id, :title)
505
- expect(node).to have_css('label[for="author_favorite_book"]', text: "Favorite book")
701
+ node = Capybara.string(
702
+ builder.grouped_collection_select(:favorite_book, Genre.all,
703
+ :books, :name, :id, :title)
704
+ )
705
+ expect(node).to have_css(
706
+ 'label[for="author_favorite_book"]', text: "Favorite book"
707
+ )
506
708
  expect(node).to have_css('select[name="author[favorite_book]"]')
507
- expect(node).to have_css('select[name="author[favorite_book]"] optgroup[label="Exploration"] option[value="78"]', text: "Gulliver's Travels")
508
- expect(node).to have_css('select[name="author[favorite_book]"] optgroup[label="Pirate Exploits"] option[value="133"]', text: "Treasure Island")
709
+ expect(node).to have_css(
710
+ "#{selector}[label=\"Exploration\"] option[value=\"78\"]",
711
+ text: "Gulliver's Travels"
712
+ )
713
+ expect(node).to have_css(
714
+ "#{selector}[label=\"Pirate Exploits\"] option[value=\"133\"]",
715
+ text: "Treasure Island"
716
+ )
509
717
  end
510
718
  end
511
719
 
512
- describe "hint" do
513
- it "should add a span element" do
720
+ describe "help_text" do
721
+ it "should add a p element" do
514
722
  form_for(@author) do |builder|
515
- hint = "Enter login"
516
- node = Capybara.string builder.text_field(:login, hint: hint)
517
- expect(node.find("span").text).to eq hint
723
+ help_text = "Enter login"
724
+ node =
725
+ Capybara.string builder.text_field(:login, help_text: help_text)
726
+ expect(node.find("p").text).to eq help_text
518
727
  end
519
728
  end
520
729
 
521
- it "should not add hint attribute" do
730
+ it "should not add help_text attribute" do
522
731
  form_for(@author) do |builder|
523
- node = Capybara.string builder.text_field(:login, hint: "Enter login")
524
- expect(node.find_field("author_login")["hint"]).to be_nil
732
+ node =
733
+ Capybara.string builder.text_field(:login, help_text: "Enter login")
734
+ expect(node.find_field("author_login")["help_text"]).to be_nil
525
735
  end
526
736
  end
527
737
  end
@@ -540,115 +750,172 @@ describe "FoundationRailsHelper::FormHelper" do
540
750
  it "should not display errors" do
541
751
  form_for(@author) do |builder|
542
752
  node = Capybara.string builder.text_field(:login)
543
- expect(node).to_not have_css("small.error")
753
+ expect(node).to_not have_css("small.form-error")
544
754
  end
545
755
  end
756
+
546
757
  it "should display errors" do
547
758
  form_for(@author) do |builder|
548
759
  allow(@author).to receive(:errors).and_return(login: ["required"])
549
760
  node = Capybara.string builder.text_field(:login)
550
- expect(node).to have_css("small.error", text: "required")
761
+ expect(node).to have_css("small.form-error", text: "required")
551
762
  end
552
763
  end
764
+
553
765
  %w(file_field email_field text_field telephone_field phone_field
554
766
  url_field number_field date_field datetime_field datetime_local_field
555
767
  month_field week_field time_field range_field search_field color_field
556
-
557
768
  password_field).each do |field|
558
769
  it "should display errors on #{field} inputs" do
559
770
  form_for(@author) do |builder|
560
- allow(@author).to receive(:errors).and_return(description: ["required"])
771
+ allow(@author)
772
+ .to receive(:errors).and_return(description: ["required"])
561
773
  node = Capybara.string builder.public_send(field, :description)
562
- expect(node).to have_css('label.error[for="author_description"]')
563
- expect(node).to have_css('input.error[name="author[description]"]')
774
+ expect(node)
775
+ .to have_css('label.is-invalid-label[for="author_description"]')
776
+ expect(node)
777
+ .to have_css('input.is-invalid-input[name="author[description]"]')
564
778
  end
565
779
  end
566
780
  end
781
+
567
782
  it "should display errors on text_area inputs" do
568
783
  form_for(@author) do |builder|
569
784
  allow(@author).to receive(:errors).and_return(description: ["required"])
570
785
  node = Capybara.string builder.text_area(:description)
571
- expect(node).to have_css('label.error[for="author_description"]')
572
- expect(node).to have_css('textarea.error[name="author[description]"]')
786
+ expect(node)
787
+ .to have_css('label.is-invalid-label[for="author_description"]')
788
+ expect(node)
789
+ .to have_css('textarea.is-invalid-input[name="author[description]"]')
573
790
  end
574
791
  end
792
+
575
793
  it "should display errors on select inputs" do
576
794
  form_for(@author) do |builder|
577
- allow(@author).to receive(:errors).and_return(favorite_book: ["required"])
578
- node = Capybara.string builder.select(:favorite_book, [["Choice #1", :a], ["Choice #2", :b]])
579
- expect(node).to have_css('label.error[for="author_favorite_book"]')
580
- expect(node).to have_css('select.error[name="author[favorite_book]"]')
795
+ allow(@author)
796
+ .to receive(:errors).and_return(favorite_book: ["required"])
797
+ node = Capybara.string(
798
+ builder.select(:favorite_book, [["Choice #1", :a], ["Choice #2", :b]])
799
+ )
800
+ expect(node)
801
+ .to have_css('label.is-invalid-label[for="author_favorite_book"]')
802
+ expect(node)
803
+ .to have_css('select.is-invalid-input[name="author[favorite_book]"]')
581
804
  end
582
805
  end
806
+
583
807
  it "should display errors on date_select inputs" do
584
808
  form_for(@author) do |builder|
585
809
  allow(@author).to receive(:errors).and_return(birthdate: ["required"])
586
810
  node = Capybara.string builder.date_select(:birthdate)
587
- expect(node).to have_css('label.error[for="author_birthdate"]')
588
- %w(1 2 3).each { |i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
811
+ expect(node)
812
+ .to have_css('label.is-invalid-label[for="author_birthdate"]')
813
+ %w(1 2 3).each do |i|
814
+ expect(node).to have_css(
815
+ "select.is-invalid-input[name='author[birthdate(#{i}i)]']"
816
+ )
817
+ end
589
818
  end
590
819
  end
820
+
591
821
  it "should display errors on datetime_select inputs" do
592
822
  form_for(@author) do |builder|
593
823
  allow(@author).to receive(:errors).and_return(birthdate: ["required"])
594
824
  node = Capybara.string builder.datetime_select(:birthdate)
595
- expect(node).to have_css('label.error[for="author_birthdate"]')
596
- %w(1 2 3 4 5).each { |i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
825
+ expect(node)
826
+ .to have_css('label.is-invalid-label[for="author_birthdate"]')
827
+ %w(1 2 3 4 5).each do |i|
828
+ expect(node).to have_css(
829
+ "select.is-invalid-input[name='author[birthdate(#{i}i)]']"
830
+ )
831
+ end
597
832
  end
598
833
  end
834
+
599
835
  it "should display errors on time_zone_select inputs" do
600
836
  form_for(@author) do |builder|
601
837
  allow(@author).to receive(:errors).and_return(time_zone: ["required"])
602
838
  node = Capybara.string builder.time_zone_select(:time_zone)
603
- expect(node).to have_css('label.error[for="author_time_zone"]')
604
- expect(node).to have_css('select.error[name="author[time_zone]"]')
839
+ expect(node)
840
+ .to have_css('label.is-invalid-label[for="author_time_zone"]')
841
+ expect(node)
842
+ .to have_css('select.is-invalid-input[name="author[time_zone]"]')
605
843
  end
606
844
  end
607
845
 
608
846
  it "should display errors on collection_select inputs" do
609
847
  form_for(@author) do |builder|
610
- allow(@author).to receive(:errors).and_return(favorite_book: ["required"])
611
- node = Capybara.string builder.collection_select(:favorite_book, Book.all, :id, :title)
612
- expect(node).to have_css('label.error[for="author_favorite_book"]')
613
- expect(node).to have_css('select.error[name="author[favorite_book]"]')
848
+ allow(@author)
849
+ .to receive(:errors).and_return(favorite_book: ["required"])
850
+ node = Capybara.string(
851
+ builder.collection_select(:favorite_book, Book.all, :id, :title)
852
+ )
853
+ expect(node)
854
+ .to have_css('label.is-invalid-label[for="author_favorite_book"]')
855
+ expect(node)
856
+ .to have_css('select.is-invalid-input[name="author[favorite_book]"]')
614
857
  end
615
858
  end
616
859
 
617
860
  it "should display errors on grouped_collection_select inputs" do
618
861
  form_for(@author) do |builder|
619
- allow(@author).to receive(:errors).and_return(favorite_book: ["required"])
620
- node = Capybara.string builder.grouped_collection_select(:favorite_book, Genre.all, :books, :name, :id, :title)
621
- expect(node).to have_css('label.error[for="author_favorite_book"]')
622
- expect(node).to have_css('select.error[name="author[favorite_book]"]')
623
- end
624
- end
625
-
626
- # N.B. check_box and radio_button inputs don't have the error class applied
627
-
862
+ allow(@author)
863
+ .to receive(:errors).and_return(favorite_book: ["required"])
864
+ node = Capybara.string(
865
+ builder.grouped_collection_select(
866
+ :favorite_book,
867
+ Genre.all,
868
+ :books,
869
+ :name,
870
+ :id,
871
+ :title
872
+ )
873
+ )
874
+ expect(node)
875
+ .to have_css('label.is-invalid-label[for="author_favorite_book"]')
876
+ expect(node)
877
+ .to have_css('select.is-invalid-input[name="author[favorite_book]"]')
878
+ end
879
+ end
880
+
881
+ # N.B. check_box and radio_button inputs don't have the is-invalid-input
882
+ # class applied
628
883
  it "should display HTML errors when the option is specified" do
884
+ login = ['required <a href="link_target">link</a>']
885
+
629
886
  form_for(@author) do |builder|
630
- allow(@author).to receive(:errors).and_return(login: ['required <a href="link_target">link</a>'])
631
- node = Capybara.string builder.text_field(:login, html_safe_errors: true)
887
+ allow(@author).to receive(:errors).and_return(login: login)
888
+ node = Capybara.string(
889
+ builder.text_field(:login, html_safe_errors: true)
890
+ )
632
891
  expect(node).to have_link("link", href: "link_target")
633
892
  end
634
893
  end
894
+
635
895
  it "should not display HTML errors when the option is not specified" do
896
+ login = ['required <a href="link_target">link</a>']
897
+
636
898
  form_for(@author) do |builder|
637
- allow(@author).to receive(:errors).and_return(login: ['required <a href="link_target">link</a>'])
899
+ allow(@author).to receive(:errors).and_return(login: login)
638
900
  node = Capybara.string builder.text_field(:login)
639
901
  expect(node).to_not have_link("link", href: "link")
640
902
  end
641
903
  end
642
904
 
643
905
  it "should not display labels unless specified in the builder method" do
906
+ label = "Tell me about you"
907
+
644
908
  form_for(@author, auto_labels: false) do |builder|
645
- node = Capybara.string builder.text_field(:login) +
646
- builder.check_box(:active, label: true) +
647
- builder.text_field(:description, label: "Tell me about you")
909
+ node = Capybara.string(
910
+ builder.text_field(:login) +
911
+ builder.check_box(:active, label: true) +
912
+ builder.text_field(:description, label: label)
913
+ )
648
914
 
649
915
  expect(node).to_not have_css('label[for="author_login"]')
650
916
  expect(node).to have_css('label[for="author_active"]', text: "Active")
651
- expect(node).to have_css('label[for="author_description"]', text: "Tell me about you")
917
+ expect(node)
918
+ .to have_css('label[for="author_description"]', text: label)
652
919
  end
653
920
  end
654
921
 
@@ -657,7 +924,9 @@ describe "FoundationRailsHelper::FormHelper" do
657
924
  form_for(@author) do |builder|
658
925
  allow(@author).to receive(:errors).and_return(email: ["required"])
659
926
  node = Capybara.string builder.text_field(:email, class: "righteous")
660
- expect(node).to have_css('input.righteous.error[name="author[email]"]')
927
+ expect(node).to have_css(
928
+ 'input.righteous.is-invalid-input[name="author[email]"]'
929
+ )
661
930
  end
662
931
  end
663
932
  end
@@ -667,7 +936,9 @@ describe "FoundationRailsHelper::FormHelper" do
667
936
  form_for(@author) do |builder|
668
937
  allow(@author).to receive(:errors).and_return(email: ["required"])
669
938
  node = Capybara.string builder.text_field(:email, class: :illgotten)
670
- expect(node).to have_css('input.illgotten.error[name="author[email]"]')
939
+ expect(node).to have_css(
940
+ 'input.illgotten.is-invalid-input[name="author[email]"]'
941
+ )
671
942
  end
672
943
  end
673
944
  end
@@ -682,7 +953,8 @@ describe "FoundationRailsHelper::FormHelper" do
682
953
  it "should display form button with default class" do
683
954
  form_for(@author) do |builder|
684
955
  node = Capybara.string builder.submit("Save")
685
- expect(node).to have_css('input[type="submit"][class="small radius success button"]')
956
+ expect(node)
957
+ .to have_css('input[type="submit"][class="success button"]')
686
958
  end
687
959
  end
688
960
  end
@@ -702,7 +974,7 @@ describe "FoundationRailsHelper::FormHelper" do
702
974
  end
703
975
  end
704
976
 
705
- context "when option value is 'superduper'" do
977
+ context 'when option value is "superduper"' do
706
978
  it "should display form button with 'superduper' class" do
707
979
  form_for(@author) do |builder|
708
980
  node = Capybara.string builder.submit("Save", class: "superduper")