foundation_rails_helper 1.2.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
1
  module Railtie
2
2
  class Railtie < Rails::Railtie
3
3
  # initializer 'setup foundation form builder' do
4
- #
4
+ #
5
5
  # end
6
6
  end
7
-
8
- end
7
+ end
@@ -0,0 +1,7 @@
1
+ inherit_from:
2
+ - ../.rubocop.yml
3
+
4
+ StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+ Exclude:
7
+ - './spec_helper.rb'
@@ -1,20 +1,19 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe FoundationRailsHelper do
4
-
5
4
  describe FoundationRailsHelper::Configuration do
6
5
  describe "#button_class" do
7
6
  it "default value is 'small radius success button'" do
8
7
  config = FoundationRailsHelper::Configuration.new
9
- expect(config.button_class).to eq('small radius success button')
8
+ expect(config.button_class).to eq("small radius success button")
10
9
  end
11
10
  end
12
11
 
13
12
  describe "#button_class=" do
14
13
  it "can set value" do
15
14
  config = FoundationRailsHelper::Configuration.new
16
- config.button_class = 'new-class'
17
- expect(config.button_class).to eq('new-class')
15
+ config.button_class = "new-class"
16
+ expect(config.button_class).to eq("new-class")
18
17
  end
19
18
  end
20
19
 
@@ -36,13 +35,13 @@ describe FoundationRailsHelper do
36
35
  describe ".reset" do
37
36
  it "resets the configured button class" do
38
37
  FoundationRailsHelper.configure do |config|
39
- config.button_class = 'new-class'
38
+ config.button_class = "new-class"
40
39
  end
41
40
 
42
41
  FoundationRailsHelper.reset
43
42
 
44
43
  config = FoundationRailsHelper.configuration
45
- expect(config.button_class).to eq('small radius success button')
44
+ expect(config.button_class).to eq("small radius success button")
46
45
  end
47
46
 
48
47
  it "resets the configured ignored flash keys" do
@@ -57,5 +56,4 @@ describe FoundationRailsHelper do
57
56
  end
58
57
  end
59
58
  end
60
-
61
59
  end
@@ -11,50 +11,50 @@ describe FoundationRailsHelper::FlashHelper do
11
11
 
12
12
  FoundationRailsHelper::FlashHelper::DEFAULT_KEY_MATCHING.each do |message_type, foundation_type|
13
13
  it "displays flash message with #{foundation_type} class for #{message_type} message" do
14
- allow(self).to receive(:flash).and_return({message_type.to_s => "Flash message"})
14
+ allow(self).to receive(:flash).and_return(message_type.to_s => "Flash message")
15
15
  node = Capybara.string display_flash_messages
16
- expect(node).
17
- to have_css("div.alert-box.#{foundation_type}", :text => "Flash message").
18
- and have_css("div.alert-box a.close", :text => "×")
16
+ expect(node)
17
+ .to have_css("div.alert-box.#{foundation_type}", text: "Flash message")
18
+ .and have_css("div.alert-box a.close", text: "×")
19
19
  end
20
20
  end
21
21
 
22
22
  it "handles symbol keys" do
23
- allow(self).to receive(:flash).and_return({ :success => "Flash message" })
23
+ allow(self).to receive(:flash).and_return(success: "Flash message")
24
24
  node = Capybara.string display_flash_messages
25
- expect(node).to have_css("div.alert-box.success", :text => "Flash message")
25
+ expect(node).to have_css("div.alert-box.success", text: "Flash message")
26
26
  end
27
27
 
28
28
  it "handles string keys" do
29
- allow(self).to receive(:flash).and_return({ "success" => "Flash message" })
29
+ allow(self).to receive(:flash).and_return("success" => "Flash message")
30
30
  node = Capybara.string display_flash_messages
31
- expect(node).to have_css("div.alert-box.success", :text => "Flash message")
31
+ expect(node).to have_css("div.alert-box.success", text: "Flash message")
32
32
  end
33
33
 
34
34
  it "displays multiple flash messages" do
35
- allow(self).to receive(:flash).and_return({ "success" => "Yay it worked", "error" => "But this other thing failed" })
35
+ allow(self).to receive(:flash).and_return("success" => "Yay it worked", "error" => "But this other thing failed")
36
36
  node = Capybara.string display_flash_messages
37
- expect(node).
38
- to have_css("div.alert-box.success", :text => "Yay it worked").
39
- and have_css("div.alert-box.alert", :text => "But this other thing failed")
37
+ expect(node)
38
+ .to have_css("div.alert-box.success", text: "Yay it worked")
39
+ .and have_css("div.alert-box.alert", text: "But this other thing failed")
40
40
  end
41
41
 
42
42
  it "displays flash message with overridden key matching" do
43
- allow(self).to receive(:flash).and_return({ "notice" => "Flash message" })
44
- node = Capybara.string display_flash_messages({:notice => :alert})
45
- expect(node).to have_css("div.alert-box.alert", :text => "Flash message")
43
+ allow(self).to receive(:flash).and_return("notice" => "Flash message")
44
+ node = Capybara.string display_flash_messages(notice: :alert)
45
+ expect(node).to have_css("div.alert-box.alert", text: "Flash message")
46
46
  end
47
47
 
48
48
  it "displays flash message with custom key matching" do
49
- allow(self).to receive(:flash).and_return({ "custom_type" => "Flash message" })
50
- node = Capybara.string display_flash_messages({:custom_type => :custom_class})
51
- expect(node).to have_css("div.alert-box.custom_class", :text => "Flash message")
49
+ allow(self).to receive(:flash).and_return("custom_type" => "Flash message")
50
+ node = Capybara.string display_flash_messages(custom_type: :custom_class)
51
+ expect(node).to have_css("div.alert-box.custom_class", text: "Flash message")
52
52
  end
53
53
 
54
54
  it "displays flash message with standard class if key doesn't match" do
55
- allow(self).to receive(:flash).and_return({ "custom_type" => "Flash message" })
55
+ allow(self).to receive(:flash).and_return("custom_type" => "Flash message")
56
56
  node = Capybara.string display_flash_messages
57
- expect(node).to have_css("div.alert-box.standard", :text => "Flash message")
57
+ expect(node).to have_css("div.alert-box.standard", text: "Flash message")
58
58
  end
59
59
 
60
60
  context "when the flash hash contains devise internal data" do
@@ -65,12 +65,12 @@ describe FoundationRailsHelper::FlashHelper do
65
65
  end
66
66
 
67
67
  it "doesn't raise an error (e.g. NoMethodError)" do
68
- allow(self).to receive(:flash).and_return({ "timedout" => true })
69
- expect{ Capybara.string display_flash_messages }.not_to raise_error
68
+ allow(self).to receive(:flash).and_return("timedout" => true)
69
+ expect { Capybara.string display_flash_messages }.not_to raise_error
70
70
  end
71
71
 
72
72
  it "doesn't display an alert for that data" do
73
- allow(self).to receive(:flash).and_return({ "timedout" => true })
73
+ allow(self).to receive(:flash).and_return("timedout" => true)
74
74
  expect(display_flash_messages).to be_nil
75
75
 
76
76
  # Ideally we'd create a node using Capybara.string, as in the other examples
@@ -7,7 +7,7 @@ describe "FoundationRailsHelper::FormHelper" do
7
7
  mock_everything
8
8
  end
9
9
 
10
- it 'should have FoundationRailsHelper::FormHelper as default buidler' do
10
+ it "should have FoundationRailsHelper::FormHelper as default buidler" do
11
11
  form_for(@author) do |builder|
12
12
  expect(builder.class).to eq FoundationRailsHelper::FormBuilder
13
13
  end
@@ -16,42 +16,42 @@ describe "FoundationRailsHelper::FormHelper" do
16
16
  it "should display labels by default" do
17
17
  form_for(@author) do |builder|
18
18
  node = Capybara.string builder.text_field(:login)
19
- expect(node).to have_css('label[for="author_login"]', :text => "Login")
19
+ expect(node).to have_css('label[for="author_login"]', text: "Login")
20
20
  end
21
21
  end
22
22
 
23
23
  it "should display labels if auto_labels: true is set" do
24
24
  form_for(@author, auto_labels: true) do |builder|
25
25
  node = Capybara.string builder.text_field(:login)
26
- expect(node).to have_css('label[for="author_login"]', :text => "Login")
26
+ expect(node).to have_css('label[for="author_login"]', text: "Login")
27
27
  end
28
28
  end
29
29
 
30
- it "should display labels if there are options without auto_labels: false" do
31
- form_for(@author, {html: {class: 'myclass'}}) do |builder|
30
+ it "should not display labels by if there are options without auto_labels: false" do
31
+ form_for(@author, html: { class: "myclass" }) do |builder|
32
32
  node = Capybara.string builder.text_field(:login)
33
- expect(node).to have_css('label[for="author_login"]', :text => "Login")
33
+ expect(node).to have_css('label[for="author_login"]', text: "Login")
34
34
  end
35
35
  end
36
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
+ form_for(@author, html: { class: "myclass" }, auto_labels: false) do |builder|
39
39
  node = Capybara.string builder.text_field(:login)
40
- expect(node).to_not have_css('label[for="author_login"]', :text => "Login")
40
+ expect(node).to_not have_css('label[for="author_login"]', text: "Login")
41
41
  end
42
42
  end
43
43
 
44
44
  it "should display labels if :auto_labels is set to nil" do
45
45
  form_for(@author, auto_labels: nil) do |builder|
46
46
  node = Capybara.string builder.text_field(:login)
47
- expect(node).to have_css('label[for="author_login"]', :text => "Login")
47
+ expect(node).to have_css('label[for="author_login"]', text: "Login")
48
48
  end
49
49
  end
50
50
 
51
51
  it "should display labels if :auto_labels is set to a string" do
52
52
  form_for(@author, auto_labels: "false") do |builder|
53
53
  node = Capybara.string builder.text_field(:login)
54
- expect(node).to have_css('label[for="author_login"]', :text => "Login")
54
+ expect(node).to have_css('label[for="author_login"]', text: "Login")
55
55
  end
56
56
  end
57
57
 
@@ -67,9 +67,9 @@ describe "FoundationRailsHelper::FormHelper" do
67
67
 
68
68
  it "should not have error class multiple times" do
69
69
  form_for(@author) do |builder|
70
- allow(@author).to receive(:errors).and_return({:login => ['required']})
70
+ allow(@author).to receive(:errors).and_return(login: ["required"])
71
71
  node = Capybara.string builder.text_field(:login)
72
- error_class = node.find('label')['class'].split(/\s+/).keep_if { |v| v == 'error' }
72
+ error_class = node.find("label")["class"].split(/\s+/).keep_if { |v| v == "error" }
73
73
  expect(error_class.size).to eq 1
74
74
  end
75
75
  end
@@ -79,32 +79,32 @@ describe "FoundationRailsHelper::FormHelper" do
79
79
  context "when input field has a prefix" do
80
80
  before do
81
81
  form_for(@author) do |builder|
82
- @node = Capybara.string builder.text_field(:login, :prefix => {small: 2, medium:4, large: 6, value: "Prefix"})
82
+ @node = Capybara.string builder.text_field(:login, prefix: { small: 2, medium: 4, large: 6, value: "Prefix" })
83
83
  end
84
84
  end
85
85
 
86
86
  it "wraps input in the div with class 'row collapse'" do
87
- expect(@node.find('.row.collapse')).to_not be nil
87
+ expect(@node.find(".row.collapse")).to_not be nil
88
88
  end
89
89
 
90
90
  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')
91
+ expect(@node.find(".row.collapse")).to have_css("div.small-2.medium-4.large-6.columns")
92
92
  end
93
93
 
94
94
  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"
95
+ expect(@node.find(".row.collapse").find("div.small-2.medium-4.large-6.columns").find("span").text).to eq "Prefix"
96
96
  end
97
97
 
98
98
  it "creates prefix span with right class" do
99
- expect(@node.find('.row.collapse')).to have_css('span.prefix')
99
+ expect(@node.find(".row.collapse")).to have_css("span.prefix")
100
100
  end
101
101
 
102
102
  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')
103
+ expect(@node.find(".row.collapse")).to have_css("div.small-10.medium-8.large-6.columns")
104
104
  end
105
105
 
106
106
  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]"]')
107
+ expect(@node.find(".row.collapse").find("div.small-10.medium-8.large-6.columns")).to have_css('input[type="text"][name="author[login]"]')
108
108
  end
109
109
  end
110
110
 
@@ -112,7 +112,7 @@ describe "FoundationRailsHelper::FormHelper" do
112
112
  it "will not wrap input into a div" do
113
113
  form_for(@author) do |builder|
114
114
  node = Capybara.string builder.text_field(:login)
115
- expect(node).to_not have_css('div.row.collapse')
115
+ expect(node).to_not have_css("div.row.collapse")
116
116
  end
117
117
  end
118
118
  end
@@ -122,65 +122,65 @@ describe "FoundationRailsHelper::FormHelper" do
122
122
  context "when input field has a postfix" do
123
123
  before do
124
124
  form_for(@author) do |builder|
125
- @node = Capybara.string builder.text_field(:login, :postfix => {small: 2, medium: 4, large: 6, value: "Postfix"})
125
+ @node = Capybara.string builder.text_field(:login, postfix: { small: 2, medium: 4, large: 6, value: "Postfix" })
126
126
  end
127
127
  end
128
128
 
129
129
  it "wraps input in the div with class 'row collapse'" do
130
- expect(@node.find('.row.collapse')).to_not be nil
130
+ expect(@node.find(".row.collapse")).to_not be nil
131
131
  end
132
132
 
133
133
  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')
134
+ expect(@node.find(".row.collapse")).to have_css("div.small-2.medium-4.large-6.columns")
135
135
  end
136
136
 
137
137
  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"
138
+ expect(@node.find(".row.collapse").find("div.small-2.medium-4.large-6.columns").find("span").text).to eq "Postfix"
139
139
  end
140
140
 
141
141
  it "creates postfix span with right class" do
142
- expect(@node.find('.row.collapse')).to have_css('span.postfix')
142
+ expect(@node.find(".row.collapse")).to have_css("span.postfix")
143
143
  end
144
144
 
145
145
  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')
146
+ expect(@node.find(".row.collapse")).to have_css("div.small-10.medium-8.large-6.columns")
147
147
  end
148
148
 
149
149
  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]"]')
150
+ expect(@node.find(".row.collapse").find("div.small-10.medium-8.large-6.columns")).to have_css('input[type="text"][name="author[login]"]')
151
151
  end
152
152
  end
153
153
 
154
154
  context "with only one column size" do
155
155
  before do
156
156
  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"})
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" })
160
160
  end
161
161
  end
162
162
 
163
163
  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')
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")
167
167
  end
168
168
 
169
169
  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')
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")
173
173
  end
174
174
 
175
175
  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')
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")
178
178
  end
179
179
 
180
180
  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')
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")
184
184
  end
185
185
  end
186
186
  end
@@ -190,15 +190,14 @@ describe "FoundationRailsHelper::FormHelper" do
190
190
  before do
191
191
  form_for(@author) do |builder|
192
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"})
193
+ prefix: { small: 2, medium: 3, large: 4, value: "Prefix" },
194
+ postfix: { small: 2, medium: 3, large: 4, value: "Postfix" })
195
195
  end
196
196
  end
197
197
 
198
198
  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')
199
+ expect(@node.find(".row.collapse")).to have_css("div.small-8.medium-6.large-4.columns")
200
200
  end
201
-
202
201
  end
203
202
  end
204
203
 
@@ -206,24 +205,24 @@ describe "FoundationRailsHelper::FormHelper" do
206
205
  it "should generate text_field input" do
207
206
  form_for(@author) do |builder|
208
207
  node = Capybara.string builder.text_field(:login)
209
- expect(node).to have_css('label[for="author_login"]', :text => "Login")
208
+ expect(node).to have_css('label[for="author_login"]', text: "Login")
210
209
  expect(node).to have_css('input[type="text"][name="author[login]"]')
211
- expect(node.find_field('author_login').value).to eq @author.login
210
+ expect(node.find_field("author_login").value).to eq @author.login
212
211
  end
213
212
  end
214
213
 
215
214
  it "should generate text_field input without label" do
216
215
  form_for(@author) do |builder|
217
- node = Capybara.string builder.text_field(:login, :label => false)
218
- expect(node).to_not have_css('label[for="author_login"]', :text => "Login")
216
+ node = Capybara.string builder.text_field(:login, label: false)
217
+ expect(node).to_not have_css('label[for="author_login"]', text: "Login")
219
218
  expect(node).to have_css('input[type="text"][name="author[login]"]')
220
- expect(node.find_field('author_login').value).to eq @author.login
219
+ expect(node.find_field("author_login").value).to eq @author.login
221
220
  end
222
221
  end
223
222
 
224
223
  it "should generate text_field with class from options" do
225
224
  form_for(@author) do |builder|
226
- node = Capybara.string builder.text_field(:login, :class => 'righteous')
225
+ node = Capybara.string builder.text_field(:login, class: "righteous")
227
226
  expect(node).to have_css('input.righteous[type="text"][name="author[login]"]')
228
227
  end
229
228
  end
@@ -231,88 +230,88 @@ describe "FoundationRailsHelper::FormHelper" do
231
230
  it "should generate password_field input" do
232
231
  form_for(@author) do |builder|
233
232
  node = Capybara.string builder.password_field(:password)
234
- expect(node).to have_css('label[for="author_password"]', :text => "Password")
233
+ expect(node).to have_css('label[for="author_password"]', text: "Password")
235
234
  expect(node).to have_css('input[type="password"][name="author[password]"]')
236
- expect(node.find_field('author_password').value).to be_nil
235
+ expect(node.find_field("author_password").value).to be_nil
237
236
  end
238
237
  end
239
238
 
240
239
  it "should generate email_field input" do
241
240
  form_for(@author) do |builder|
242
241
  node = Capybara.string builder.email_field(:email)
243
- expect(node).to have_css('label[for="author_email"]', :text => "Email")
242
+ expect(node).to have_css('label[for="author_email"]', text: "Email")
244
243
  expect(node).to have_css('input[type="email"][name="author[email]"]')
245
- expect(node.find_field('author_email').value).to eq @author.email
244
+ expect(node.find_field("author_email").value).to eq @author.email
246
245
  end
247
246
  end
248
247
 
249
248
  it "should generate url_field input" do
250
249
  form_for(@author) do |builder|
251
250
  node = Capybara.string builder.url_field(:url)
252
- expect(node).to have_css('label[for="author_url"]', :text => "Url")
251
+ expect(node).to have_css('label[for="author_url"]', text: "Url")
253
252
  expect(node).to have_css('input[type="url"][name="author[url]"]')
254
- expect(node.find_field('author_url').value).to eq @author.url
253
+ expect(node.find_field("author_url").value).to eq @author.url
255
254
  end
256
255
  end
257
256
 
258
257
  it "should generate phone_field input" do
259
258
  form_for(@author) do |builder|
260
259
  node = Capybara.string builder.phone_field(:phone)
261
- expect(node).to have_css('label[for="author_phone"]', :text => "Phone")
260
+ expect(node).to have_css('label[for="author_phone"]', text: "Phone")
262
261
  expect(node).to have_css('input[type="tel"][name="author[phone]"]')
263
- expect(node.find_field('author_phone').value).to eq @author.phone
262
+ expect(node.find_field("author_phone").value).to eq @author.phone
264
263
  end
265
264
  end
266
265
 
267
266
  it "should generate number_field input" do
268
267
  form_for(@author) do |builder|
269
268
  node = Capybara.string builder.number_field(:some_number)
270
- expect(node).to have_css('label[for="author_some_number"]', :text => "Some number")
269
+ expect(node).to have_css('label[for="author_some_number"]', text: "Some number")
271
270
  expect(node).to have_css('input[type="number"][name="author[some_number]"]')
272
- expect(node.find_field('author_some_number').value).to eq @author.some_number
271
+ expect(node.find_field("author_some_number").value).to eq @author.some_number
273
272
  end
274
273
  end
275
274
 
276
275
  it "should generate text_area input" do
277
276
  form_for(@author) do |builder|
278
277
  node = Capybara.string builder.text_area(:description)
279
- expect(node).to have_css('label[for="author_description"]', :text => "Description")
278
+ expect(node).to have_css('label[for="author_description"]', text: "Description")
280
279
  expect(node).to have_css('textarea[name="author[description]"]')
281
- expect(node.find_field('author_description').value.strip).to eq @author.description
280
+ expect(node.find_field("author_description").value.strip).to eq @author.description
282
281
  end
283
282
  end
284
283
 
285
284
  it "should generate file_field input" do
286
285
  form_for(@author) do |builder|
287
286
  node = Capybara.string builder.file_field(:avatar)
288
- expect(node).to have_css('label[for="author_avatar"]', :text => "Avatar")
287
+ expect(node).to have_css('label[for="author_avatar"]', text: "Avatar")
289
288
  expect(node).to have_css('input[type="file"][name="author[avatar]"]')
290
- expect(node.find_field('author_avatar').value).to be_nil
289
+ expect(node.find_field("author_avatar").value).to be_nil
291
290
  end
292
291
  end
293
292
 
294
293
  it "should generate select input" do
295
294
  form_for(@author) do |builder|
296
295
  node = Capybara.string builder.select(:description, [["Choice #1", :a], ["Choice #2", :b]])
297
- expect(node).to have_css('label[for="author_description"]', :text => "Description")
296
+ expect(node).to have_css('label[for="author_description"]', text: "Description")
298
297
  expect(node).to have_css('select[name="author[description]"]')
299
- expect(node).to have_css('select[name="author[description]"] option[value="a"]', :text => "Choice #1")
300
- expect(node).to have_css('select[name="author[description]"] option[value="b"]', :text => "Choice #2")
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")
301
300
  end
302
301
  end
303
302
 
304
303
  it "should generate check_box input" do
305
304
  form_for(@author) do |builder|
306
305
  node = Capybara.string builder.check_box(:active)
307
- expect(node).to have_css('label[for="author_active"] input[type="hidden"][name="author[active]"][value="0"]', :visible => false)
306
+ expect(node).to have_css('label[for="author_active"] input[type="hidden"][name="author[active]"][value="0"]', visible: false)
308
307
  expect(node).to have_css('label[for="author_active"] input[type="checkbox"][name="author[active]"]')
309
- expect(node).to have_css('label[for="author_active"]', :text => "Active")
308
+ expect(node).to have_css('label[for="author_active"]', text: "Active")
310
309
  end
311
310
  end
312
311
  it "should generate check_box input without a label" do
313
312
  form_for(@author) do |builder|
314
- node = Capybara.string builder.check_box(:active, :label => false)
315
- expect(node).to have_css('input[type="hidden"][name="author[active]"][value="0"]', :visible => false)
313
+ 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)
316
315
  expect(node).to have_css('input[type="checkbox"][name="author[active]"]')
317
316
  expect(node).to_not have_css('label[for="author_active"]')
318
317
  end
@@ -342,7 +341,7 @@ describe "FoundationRailsHelper::FormHelper" do
342
341
  end
343
342
  it "should generate radio_button with label options" do
344
343
  form_for(@author) do |builder|
345
- node = Capybara.string builder.radio_button(:active, "ok", class: 'very', label_options: { class: 'special' })
344
+ node = Capybara.string builder.radio_button(:active, "ok", class: "very", label_options: { class: "special" })
346
345
  expect(node).to have_css('label.special[for="author_active_ok"]')
347
346
  expect(node).to have_css('input.very[type="radio"][name="author[active]"]')
348
347
  end
@@ -351,32 +350,32 @@ describe "FoundationRailsHelper::FormHelper" do
351
350
  it "should generate date_select input" do
352
351
  form_for(@author) do |builder|
353
352
  node = Capybara.string builder.label(:birthdate) + builder.date_select(:birthdate)
354
- expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
355
- %w(1 2 3).each {|i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
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)]']") }
356
355
  expect(node).to have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
357
356
  expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
358
357
  expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
359
- %w(4 5).each {|i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
358
+ %w(4 5).each { |i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
360
359
  end
361
360
  end
362
361
 
363
362
  it "should generate date_select input with :discard_year => true" do
364
363
  form_for(@author) do |builder|
365
- node = Capybara.string builder.label(:birthdate) + builder.date_select(:birthdate, :discard_year => true)
366
- expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
367
- %w(2 3).each {|i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
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)]']") }
368
367
  expect(node).to_not have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
369
368
  expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
370
369
  expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
371
- %w(1 4 5).each {|i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
370
+ %w(1 4 5).each { |i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
372
371
  end
373
372
  end
374
373
 
375
374
  it "should generate datetime_select input" do
376
375
  form_for(@author) do |builder|
377
376
  node = Capybara.string builder.label(:birthdate) + builder.datetime_select(:birthdate)
378
- expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
379
- %w(1 2 3 4 5).each {|i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
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)]']") }
380
379
  expect(node).to have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
381
380
  expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
382
381
  expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
@@ -387,42 +386,42 @@ describe "FoundationRailsHelper::FormHelper" do
387
386
 
388
387
  it "should generate datetime_select input with :discard_year => true" do
389
388
  form_for(@author) do |builder|
390
- node = Capybara.string builder.label(:birthdate) + builder.datetime_select(:birthdate, :discard_year => true)
391
- expect(node).to have_css('label[for="author_birthdate"]', :text => "Birthdate")
392
- %w(2 3 4 5).each {|i| expect(node).to have_css("select[name='author[birthdate(#{i}i)]']") }
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)]']") }
393
392
  expect(node).to_not have_css('select#author_birthdate_1i option[selected="selected"][value="1969"]')
394
393
  expect(node).to have_css('select#author_birthdate_2i option[selected="selected"][value="6"]')
395
394
  expect(node).to have_css('select#author_birthdate_3i option[selected="selected"][value="18"]')
396
395
  expect(node).to have_css('select#author_birthdate_4i option[selected="selected"][value="20"]')
397
396
  expect(node).to have_css('select#author_birthdate_5i option[selected="selected"][value="30"]')
398
- %w(1).each {|i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
397
+ %w(1).each { |i| expect(node).to_not have_css("select[name='author[birthdate(#{i}i)]']") }
399
398
  end
400
399
  end
401
400
 
402
401
  it "should generate time_zone_select input" do
403
402
  form_for(@author) do |builder|
404
403
  node = Capybara.string builder.label(:time_zone) + builder.time_zone_select(:time_zone)
405
- expect(node).to have_css('label[for="author_time_zone"]', :text => "Time zone")
404
+ expect(node).to have_css('label[for="author_time_zone"]', text: "Time zone")
406
405
  expect(node).to have_css('select[name="author[time_zone]"]')
407
- expect(node).to have_css('select[name="author[time_zone]"] option[value="Perth"]', :text => "(GMT+08:00) Perth")
406
+ expect(node).to have_css('select[name="author[time_zone]"] option[value="Perth"]', text: "(GMT+08:00) Perth")
408
407
  end
409
408
  end
410
409
 
411
410
  it "should generate date_field input" do
412
411
  form_for(@author) do |builder|
413
412
  node = Capybara.string builder.date_field(:publish_date)
414
- expect(node).to have_css('label[for="author_publish_date"]', :text => "date")
413
+ expect(node).to have_css('label[for="author_publish_date"]', text: "date")
415
414
  expect(node).to have_css('input[type="date"][name="author[publish_date]"]')
416
- expect(node.find_field('author_publish_date').value).to eq @author.publish_date.to_s
415
+ expect(node.find_field("author_publish_date").value).to eq @author.publish_date.to_s
417
416
  end
418
417
  end
419
418
 
420
419
  it "should generate datetime_field input" do
421
420
  form_for(@author) do |builder|
422
- node = Capybara.string builder.datetime_field(:forty_two)
423
- expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
421
+ node = Capybara.string builder.datetime_field(:forty_two)
422
+ expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
424
423
  expect(node).to have_css('input[type^="datetime"][name="author[forty_two]"]')
425
- value = DateTime.parse( node.find_field('author_forty_two').value)
424
+ value = DateTime.parse(node.find_field("author_forty_two").value)
426
425
  expect(value).to eq @author.forty_two.to_s
427
426
  end
428
427
  end
@@ -430,99 +429,99 @@ describe "FoundationRailsHelper::FormHelper" do
430
429
  it "should generate datetime_local_field" do
431
430
  form_for(@author) do |builder|
432
431
  node = Capybara.string builder.datetime_local_field(:forty_two)
433
- expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
432
+ expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
434
433
  expect(node).to have_css('input[type="datetime-local"][name="author[forty_two]"]')
435
- expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%Y-%m-%dT%H:%M:%S")
434
+ expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%Y-%m-%dT%H:%M:%S")
436
435
  end
437
436
  end
438
437
 
439
438
  it "should generate month_field input" do
440
439
  form_for(@author) do |builder|
441
- node = Capybara.string builder.month_field(:forty_two)
442
- expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
440
+ node = Capybara.string builder.month_field(:forty_two)
441
+ expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
443
442
  expect(node).to have_css('input[type="month"][name="author[forty_two]"]')
444
- expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%Y-%m")
443
+ expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%Y-%m")
445
444
  end
446
445
  end
447
446
 
448
447
  it "should generate week_field" do
449
448
  form_for(@author) do |builder|
450
- node = Capybara.string builder.week_field(:forty_two)
451
- expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
449
+ node = Capybara.string builder.week_field(:forty_two)
450
+ expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
452
451
  expect(node).to have_css('input[type="week"][name="author[forty_two]"]')
453
- expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%Y-W%V")
452
+ expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%Y-W%V")
454
453
  end
455
454
  end
456
455
 
457
456
  it "should generate time_field" do
458
457
  form_for(@author) do |builder|
459
- node = Capybara.string builder.time_field(:forty_two)
460
- expect(node).to have_css('label[for="author_forty_two"]', :text => "Forty two")
458
+ node = Capybara.string builder.time_field(:forty_two)
459
+ expect(node).to have_css('label[for="author_forty_two"]', text: "Forty two")
461
460
  expect(node).to have_css('input[type="time"][name="author[forty_two]"]')
462
- expect(node.find_field('author_forty_two').value).to eq @author.forty_two.strftime("%H:%M:%S.%L")
461
+ expect(node.find_field("author_forty_two").value).to eq @author.forty_two.strftime("%H:%M:%S.%L")
463
462
  end
464
463
  end
465
464
 
466
465
  it "should generate range_field" do
467
466
  form_for(@author) do |builder|
468
467
  node = Capybara.string builder.range_field(:some_number)
469
- expect(node).to have_css('label[for="author_some_number"]', :text => "Some number")
468
+ expect(node).to have_css('label[for="author_some_number"]', text: "Some number")
470
469
  expect(node).to have_css('input[type="range"][name="author[some_number]"]')
471
- expect(node.find_field('author_some_number').value).to eq @author.some_number
470
+ expect(node.find_field("author_some_number").value).to eq @author.some_number
472
471
  end
473
472
  end
474
473
 
475
474
  it "should generate search_field" do
476
475
  form_for(@author) do |builder|
477
476
  node = Capybara.string builder.search_field(:description)
478
- expect(node).to have_css('label[for="author_description"]', :text => "Description")
477
+ expect(node).to have_css('label[for="author_description"]', text: "Description")
479
478
  expect(node).to have_css('input[type="search"][name="author[description]"]')
480
- expect(node.find_field('author_description').value).to eq @author.description
479
+ expect(node.find_field("author_description").value).to eq @author.description
481
480
  end
482
481
  end
483
482
 
484
483
  it "should generate color_field" do
485
484
  form_for(@author) do |builder|
486
485
  node = Capybara.string builder.color_field(:favorite_color)
487
- expect(node).to have_css('label[for="author_favorite_color"]', :text => "Favorite color")
486
+ expect(node).to have_css('label[for="author_favorite_color"]', text: "Favorite color")
488
487
  expect(node).to have_css('input[type="color"][name="author[favorite_color]"]')
489
- expect(node.find_field('author_favorite_color').value).to eq @author.favorite_color
488
+ expect(node.find_field("author_favorite_color").value).to eq @author.favorite_color
490
489
  end
491
490
  end
492
491
 
493
492
  it "should generate collection_select input" do
494
493
  form_for(@author) do |builder|
495
494
  node = Capybara.string builder.collection_select(:favorite_book, Book.all, :id, :title)
496
- expect(node).to have_css('label[for="author_favorite_book"]', :text => "Favorite book")
495
+ expect(node).to have_css('label[for="author_favorite_book"]', text: "Favorite book")
497
496
  expect(node).to have_css('select[name="author[favorite_book]"]')
498
- expect(node).to have_css('select[name="author[favorite_book]"] option[value="78"]', :text => "Gulliver's Travels")
499
- expect(node).to have_css('select[name="author[favorite_book]"] option[value="133"]', :text => "Treasure Island")
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")
500
499
  end
501
500
  end
502
501
 
503
502
  it "should generate grouped_collection_select input" do
504
503
  form_for(@author) do |builder|
505
504
  node = Capybara.string builder.grouped_collection_select(:favorite_book, Genre.all, :books, :name, :id, :title)
506
- expect(node).to have_css('label[for="author_favorite_book"]', :text => "Favorite book")
505
+ expect(node).to have_css('label[for="author_favorite_book"]', text: "Favorite book")
507
506
  expect(node).to have_css('select[name="author[favorite_book]"]')
508
- expect(node).to have_css('select[name="author[favorite_book]"] optgroup[label="Exploration"] option[value="78"]', :text => "Gulliver's Travels")
509
- expect(node).to have_css('select[name="author[favorite_book]"] optgroup[label="Pirate Exploits"] option[value="133"]', :text => "Treasure Island")
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")
510
509
  end
511
510
  end
512
511
 
513
512
  describe "hint" do
514
513
  it "should add a span element" do
515
514
  form_for(@author) do |builder|
516
- hint = 'Enter login'
517
- node = Capybara.string builder.text_field(:login, :hint => hint)
515
+ hint = "Enter login"
516
+ node = Capybara.string builder.text_field(:login, hint: hint)
518
517
  expect(node.find("span").text).to eq hint
519
518
  end
520
519
  end
521
520
 
522
521
  it "should not add hint attribute" do
523
522
  form_for(@author) do |builder|
524
- node = Capybara.string builder.text_field(:login, :hint => 'Enter login')
525
- expect(node.find_field("author_login")['hint']).to be_nil
523
+ node = Capybara.string builder.text_field(:login, hint: "Enter login")
524
+ expect(node.find_field("author_login")["hint"]).to be_nil
526
525
  end
527
526
  end
528
527
  end
@@ -541,25 +540,24 @@ describe "FoundationRailsHelper::FormHelper" do
541
540
  it "should not display errors" do
542
541
  form_for(@author) do |builder|
543
542
  node = Capybara.string builder.text_field(:login)
544
- expect(node).to_not have_css('small.error')
543
+ expect(node).to_not have_css("small.error")
545
544
  end
546
545
  end
547
546
  it "should display errors" do
548
547
  form_for(@author) do |builder|
549
- allow(@author).to receive(:errors).and_return({:login => ['required']})
548
+ allow(@author).to receive(:errors).and_return(login: ["required"])
550
549
  node = Capybara.string builder.text_field(:login)
551
- expect(node).to have_css('small.error', :text => "required")
550
+ expect(node).to have_css("small.error", text: "required")
552
551
  end
553
552
  end
554
553
  %w(file_field email_field text_field telephone_field phone_field
555
554
  url_field number_field date_field datetime_field datetime_local_field
556
555
  month_field week_field time_field range_field search_field color_field
557
556
 
558
- password_field
559
- ).each do |field|
557
+ password_field).each do |field|
560
558
  it "should display errors on #{field} inputs" do
561
559
  form_for(@author) do |builder|
562
- allow(@author).to receive(:errors).and_return({:description => ['required']})
560
+ allow(@author).to receive(:errors).and_return(description: ["required"])
563
561
  node = Capybara.string builder.public_send(field, :description)
564
562
  expect(node).to have_css('label.error[for="author_description"]')
565
563
  expect(node).to have_css('input.error[name="author[description]"]')
@@ -568,7 +566,7 @@ describe "FoundationRailsHelper::FormHelper" do
568
566
  end
569
567
  it "should display errors on text_area inputs" do
570
568
  form_for(@author) do |builder|
571
- allow(@author).to receive(:errors).and_return({:description => ['required']})
569
+ allow(@author).to receive(:errors).and_return(description: ["required"])
572
570
  node = Capybara.string builder.text_area(:description)
573
571
  expect(node).to have_css('label.error[for="author_description"]')
574
572
  expect(node).to have_css('textarea.error[name="author[description]"]')
@@ -576,7 +574,7 @@ describe "FoundationRailsHelper::FormHelper" do
576
574
  end
577
575
  it "should display errors on select inputs" do
578
576
  form_for(@author) do |builder|
579
- allow(@author).to receive(:errors).and_return({:favorite_book => ['required']})
577
+ allow(@author).to receive(:errors).and_return(favorite_book: ["required"])
580
578
  node = Capybara.string builder.select(:favorite_book, [["Choice #1", :a], ["Choice #2", :b]])
581
579
  expect(node).to have_css('label.error[for="author_favorite_book"]')
582
580
  expect(node).to have_css('select.error[name="author[favorite_book]"]')
@@ -584,23 +582,23 @@ describe "FoundationRailsHelper::FormHelper" do
584
582
  end
585
583
  it "should display errors on date_select inputs" do
586
584
  form_for(@author) do |builder|
587
- allow(@author).to receive(:errors).and_return({:birthdate => ['required']})
585
+ allow(@author).to receive(:errors).and_return(birthdate: ["required"])
588
586
  node = Capybara.string builder.date_select(:birthdate)
589
587
  expect(node).to have_css('label.error[for="author_birthdate"]')
590
- %w(1 2 3).each {|i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
588
+ %w(1 2 3).each { |i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
591
589
  end
592
590
  end
593
591
  it "should display errors on datetime_select inputs" do
594
592
  form_for(@author) do |builder|
595
- allow(@author).to receive(:errors).and_return({:birthdate => ['required']})
593
+ allow(@author).to receive(:errors).and_return(birthdate: ["required"])
596
594
  node = Capybara.string builder.datetime_select(:birthdate)
597
595
  expect(node).to have_css('label.error[for="author_birthdate"]')
598
- %w(1 2 3 4 5).each {|i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
596
+ %w(1 2 3 4 5).each { |i| expect(node).to have_css("select.error[name='author[birthdate(#{i}i)]']") }
599
597
  end
600
598
  end
601
- it "should display errors on time_zone_select inputs" do
599
+ it "should display errors on time_zone_select inputs" do
602
600
  form_for(@author) do |builder|
603
- allow(@author).to receive(:errors).and_return({:time_zone => ['required']})
601
+ allow(@author).to receive(:errors).and_return(time_zone: ["required"])
604
602
  node = Capybara.string builder.time_zone_select(:time_zone)
605
603
  expect(node).to have_css('label.error[for="author_time_zone"]')
606
604
  expect(node).to have_css('select.error[name="author[time_zone]"]')
@@ -609,7 +607,7 @@ describe "FoundationRailsHelper::FormHelper" do
609
607
 
610
608
  it "should display errors on collection_select inputs" do
611
609
  form_for(@author) do |builder|
612
- allow(@author).to receive(:errors).and_return({:favorite_book => ['required']})
610
+ allow(@author).to receive(:errors).and_return(favorite_book: ["required"])
613
611
  node = Capybara.string builder.collection_select(:favorite_book, Book.all, :id, :title)
614
612
  expect(node).to have_css('label.error[for="author_favorite_book"]')
615
613
  expect(node).to have_css('select.error[name="author[favorite_book]"]')
@@ -618,7 +616,7 @@ describe "FoundationRailsHelper::FormHelper" do
618
616
 
619
617
  it "should display errors on grouped_collection_select inputs" do
620
618
  form_for(@author) do |builder|
621
- allow(@author).to receive(:errors).and_return({:favorite_book => ['required']})
619
+ allow(@author).to receive(:errors).and_return(favorite_book: ["required"])
622
620
  node = Capybara.string builder.grouped_collection_select(:favorite_book, Genre.all, :books, :name, :id, :title)
623
621
  expect(node).to have_css('label.error[for="author_favorite_book"]')
624
622
  expect(node).to have_css('select.error[name="author[favorite_book]"]')
@@ -629,45 +627,45 @@ describe "FoundationRailsHelper::FormHelper" do
629
627
 
630
628
  it "should display HTML errors when the option is specified" do
631
629
  form_for(@author) do |builder|
632
- allow(@author).to receive(:errors).and_return({:login => ['required <a href="link_target">link</a>']})
630
+ allow(@author).to receive(:errors).and_return(login: ['required <a href="link_target">link</a>'])
633
631
  node = Capybara.string builder.text_field(:login, html_safe_errors: true)
634
- expect(node).to have_link('link', href: 'link_target')
632
+ expect(node).to have_link("link", href: "link_target")
635
633
  end
636
634
  end
637
635
  it "should not display HTML errors when the option is not specified" do
638
636
  form_for(@author) do |builder|
639
- allow(@author).to receive(:errors).and_return({:login => ['required <a href="link_target">link</a>']})
637
+ allow(@author).to receive(:errors).and_return(login: ['required <a href="link_target">link</a>'])
640
638
  node = Capybara.string builder.text_field(:login)
641
- expect(node).to_not have_link('link', href: 'link')
639
+ expect(node).to_not have_link("link", href: "link")
642
640
  end
643
641
  end
644
642
 
645
643
  it "should not display labels unless specified in the builder method" do
646
644
  form_for(@author, auto_labels: false) do |builder|
647
645
  node = Capybara.string builder.text_field(:login) +
648
- builder.check_box(:active, label: true) +
649
- builder.text_field(:description, label: 'Tell me about you')
646
+ builder.check_box(:active, label: true) +
647
+ builder.text_field(:description, label: "Tell me about you")
650
648
 
651
649
  expect(node).to_not have_css('label[for="author_login"]')
652
- expect(node).to have_css('label[for="author_active"]', text: 'Active')
653
- expect(node).to have_css('label[for="author_description"]', text: 'Tell me about you')
650
+ 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")
654
652
  end
655
653
  end
656
654
 
657
- context 'when class option given' do
655
+ context "when class option given" do
658
656
  it "should add it to the error class" do
659
657
  form_for(@author) do |builder|
660
- allow(@author).to receive(:errors).and_return({:email => ['required']})
661
- node = Capybara.string builder.text_field(:email, class: 'righteous')
658
+ allow(@author).to receive(:errors).and_return(email: ["required"])
659
+ node = Capybara.string builder.text_field(:email, class: "righteous")
662
660
  expect(node).to have_css('input.righteous.error[name="author[email]"]')
663
661
  end
664
662
  end
665
663
  end
666
664
 
667
- context 'when invalid class option given' do
665
+ context "when invalid class option given" do
668
666
  it "should add it to the error class" do
669
667
  form_for(@author) do |builder|
670
- allow(@author).to receive(:errors).and_return({:email => ['required']})
668
+ allow(@author).to receive(:errors).and_return(email: ["required"])
671
669
  node = Capybara.string builder.text_field(:email, class: :illgotten)
672
670
  expect(node).to have_css('input.illgotten.error[name="author[email]"]')
673
671
  end
@@ -675,15 +673,15 @@ describe "FoundationRailsHelper::FormHelper" do
675
673
  end
676
674
  end
677
675
 
678
- describe 'submit button generator' do
676
+ describe "submit button generator" do
679
677
  after :each do
680
678
  FoundationRailsHelper.reset
681
679
  end
682
680
 
683
- context 'when button_class config is not set' do
681
+ context "when button_class config is not set" do
684
682
  it "should display form button with default class" do
685
683
  form_for(@author) do |builder|
686
- node = Capybara.string builder.submit('Save')
684
+ node = Capybara.string builder.submit("Save")
687
685
  expect(node).to have_css('input[type="submit"][class="small radius success button"]')
688
686
  end
689
687
  end
@@ -692,22 +690,22 @@ describe "FoundationRailsHelper::FormHelper" do
692
690
  context 'when button_class config is "superduper"' do
693
691
  before do
694
692
  FoundationRailsHelper.configure do |config|
695
- config.button_class = 'superduper'
693
+ config.button_class = "superduper"
696
694
  end
697
695
  end
698
696
 
699
697
  it "should display form button with 'superduper' class" do
700
698
  form_for(@author) do |builder|
701
- node = Capybara.string builder.submit('Save')
699
+ node = Capybara.string builder.submit("Save")
702
700
  expect(node).to have_css('input[type="submit"][class="superduper"]')
703
701
  end
704
702
  end
705
703
  end
706
704
 
707
- context 'when option value is "superduper"' do
705
+ context "when option value is 'superduper'" do
708
706
  it "should display form button with 'superduper' class" do
709
707
  form_for(@author) do |builder|
710
- node = Capybara.string builder.submit('Save', class: 'superduper')
708
+ node = Capybara.string builder.submit("Save", class: "superduper")
711
709
  expect(node).to have_css('input[type="submit"][class="superduper"]')
712
710
  end
713
711
  end