simple_form 3.1.0.rc1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/README.md +64 -16
  4. data/lib/generators/simple_form/install_generator.rb +2 -2
  5. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +9 -4
  6. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +45 -15
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +85 -4
  8. data/lib/simple_form/action_view_extensions/builder.rb +1 -0
  9. data/lib/simple_form/action_view_extensions/form_helper.rb +5 -1
  10. data/lib/simple_form/components/errors.rb +3 -5
  11. data/lib/simple_form/components/labels.rb +1 -1
  12. data/lib/simple_form/form_builder.rb +34 -19
  13. data/lib/simple_form/inputs/boolean_input.rb +8 -5
  14. data/lib/simple_form/inputs/collection_input.rb +2 -4
  15. data/lib/simple_form/tags.rb +3 -4
  16. data/lib/simple_form/version.rb +1 -1
  17. data/lib/simple_form/wrappers/builder.rb +2 -2
  18. data/lib/simple_form/wrappers/many.rb +1 -0
  19. data/lib/simple_form.rb +21 -2
  20. data/test/action_view_extensions/builder_test.rb +34 -34
  21. data/test/action_view_extensions/form_helper_test.rb +33 -14
  22. data/test/components/label_test.rb +36 -36
  23. data/test/form_builder/association_test.rb +41 -41
  24. data/test/form_builder/button_test.rb +10 -10
  25. data/test/form_builder/error_test.rb +88 -29
  26. data/test/form_builder/general_test.rb +89 -64
  27. data/test/form_builder/hint_test.rb +18 -18
  28. data/test/form_builder/input_field_test.rb +59 -19
  29. data/test/form_builder/label_test.rb +23 -14
  30. data/test/form_builder/wrapper_test.rb +70 -21
  31. data/test/generators/simple_form_generator_test.rb +2 -2
  32. data/test/inputs/boolean_input_test.rb +17 -9
  33. data/test/inputs/collection_check_boxes_input_test.rb +46 -7
  34. data/test/inputs/collection_radio_buttons_input_test.rb +65 -26
  35. data/test/inputs/collection_select_input_test.rb +62 -62
  36. data/test/inputs/datetime_input_test.rb +24 -24
  37. data/test/inputs/disabled_test.rb +15 -15
  38. data/test/inputs/discovery_test.rb +44 -5
  39. data/test/inputs/file_input_test.rb +2 -2
  40. data/test/inputs/general_test.rb +20 -20
  41. data/test/inputs/grouped_collection_select_input_test.rb +10 -10
  42. data/test/inputs/hidden_input_test.rb +4 -4
  43. data/test/inputs/numeric_input_test.rb +43 -43
  44. data/test/inputs/priority_input_test.rb +13 -13
  45. data/test/inputs/readonly_test.rb +19 -19
  46. data/test/inputs/required_test.rb +13 -13
  47. data/test/inputs/string_input_test.rb +33 -33
  48. data/test/inputs/text_input_test.rb +7 -7
  49. data/test/support/discovery_inputs.rb +20 -0
  50. data/test/support/misc_helpers.rb +28 -0
  51. data/test/support/models.rb +13 -2
  52. data/test/test_helper.rb +5 -1
  53. metadata +4 -4
@@ -6,14 +6,14 @@ class CollectionSelectInputTest < ActionView::TestCase
6
6
  SimpleForm::Inputs::CollectionSelectInput.reset_i18n_cache :boolean_collection
7
7
  end
8
8
 
9
- test 'input should generate a boolean select with options by default for select types' do
9
+ test 'input generates a boolean select with options by default for select types' do
10
10
  with_input_for @user, :active, :select
11
11
  assert_select 'select.select#user_active'
12
12
  assert_select 'select option[value=true]', 'Yes'
13
13
  assert_select 'select option[value=false]', 'No'
14
14
  end
15
15
 
16
- test 'input as select should use i18n to translate select boolean options' do
16
+ test 'input as select uses i18n to translate select boolean options' do
17
17
  store_translations(:en, simple_form: { yes: 'Sim', no: 'Não' }) do
18
18
  with_input_for @user, :active, :select
19
19
  assert_select 'select option[value=true]', 'Sim'
@@ -21,14 +21,14 @@ class CollectionSelectInputTest < ActionView::TestCase
21
21
  end
22
22
  end
23
23
 
24
- test 'input should allow overriding collection for select types' do
24
+ test 'input allows overriding collection for select types' do
25
25
  with_input_for @user, :name, :select, collection: ['Jose', 'Carlos']
26
26
  assert_select 'select.select#user_name'
27
27
  assert_select 'select option', 'Jose'
28
28
  assert_select 'select option', 'Carlos'
29
29
  end
30
30
 
31
- test 'input should do automatic collection translation for select types using defaults key' do
31
+ test 'input does automatic collection translation for select types using defaults key' do
32
32
  store_translations(:en, simple_form: { options: { defaults: {
33
33
  gender: { male: 'Male', female: 'Female'}
34
34
  } } }) do
@@ -39,7 +39,7 @@ class CollectionSelectInputTest < ActionView::TestCase
39
39
  end
40
40
  end
41
41
 
42
- test 'input should do automatic collection translation for select types using specific object key' do
42
+ test 'input does automatic collection translation for select types using specific object key' do
43
43
  store_translations(:en, simple_form: { options: { user: {
44
44
  gender: { male: 'Male', female: 'Female'}
45
45
  } } }) do
@@ -50,38 +50,38 @@ class CollectionSelectInputTest < ActionView::TestCase
50
50
  end
51
51
  end
52
52
 
53
- test 'input should mark the selected value by default' do
53
+ test 'input marks the selected value by default' do
54
54
  @user.name = "Carlos"
55
55
  with_input_for @user, :name, :select, collection: ['Jose', 'Carlos']
56
56
  assert_select 'select option[selected=selected]', 'Carlos'
57
57
  end
58
58
 
59
- test 'input should accept html options as the last element of collection' do
59
+ test 'input accepts html options as the last element of collection' do
60
60
  with_input_for @user, :name, :select, collection: [['Jose', class: 'foo']]
61
61
  assert_select 'select.select#user_name'
62
62
  assert_select 'select option.foo', 'Jose'
63
63
  end
64
64
 
65
- test 'input should mark the selected value also when using integers' do
65
+ test 'input marks the selected value also when using integers' do
66
66
  @user.age = 18
67
67
  with_input_for @user, :age, :select, collection: 18..60
68
68
  assert_select 'select option[selected=selected]', '18'
69
69
  end
70
70
 
71
- test 'input should mark the selected value when using booleans and select' do
71
+ test 'input marks the selected value when using booleans and select' do
72
72
  @user.active = false
73
73
  with_input_for @user, :active, :select
74
74
  assert_no_select 'select option[selected][value=true]', 'Yes'
75
75
  assert_select 'select option[selected][value=false]', 'No'
76
76
  end
77
77
 
78
- test 'input should set the correct value when using a collection that includes floats' do
78
+ test 'input sets the correct value when using a collection that includes floats' do
79
79
  with_input_for @user, :age, :select, collection: [2.0, 2.5, 3.0, 3.5, 4.0, 4.5]
80
80
  assert_select 'select option[value="2.0"]'
81
81
  assert_select 'select option[value="2.5"]'
82
82
  end
83
83
 
84
- test 'input should set the correct values when using a collection that uses mixed values' do
84
+ test 'input sets the correct values when using a collection that uses mixed values' do
85
85
  with_input_for @user, :age, :select, collection: ["Hello Kitty", 2, 4.5, :johnny, nil, true, false]
86
86
  assert_select 'select option[value="Hello Kitty"]'
87
87
  assert_select 'select option[value="2"]'
@@ -92,138 +92,138 @@ class CollectionSelectInputTest < ActionView::TestCase
92
92
  assert_select 'select option[value="false"]'
93
93
  end
94
94
 
95
- test 'input should include a blank option even if :include_blank is set to false if the collection includes a nil value' do
95
+ test 'input includes a blank option even if :include_blank is set to false if the collection includes a nil value' do
96
96
  with_input_for @user, :age, :select, collection: [nil], include_blank: false
97
97
  assert_select 'select option[value=""]'
98
98
  end
99
99
 
100
- test 'input should automatically set include blank' do
100
+ test 'input automatically sets include blank' do
101
101
  with_input_for @user, :age, :select, collection: 18..30
102
- assert_select 'select option[value=]', ''
102
+ assert_select 'select option[value=""]', ''
103
103
  end
104
104
 
105
- test 'input should translate include blank when set to :translate' do
105
+ test 'input translates include blank when set to :translate' do
106
106
  store_translations(:en, simple_form: { include_blanks: { user: {
107
107
  age: 'Rather not say'
108
108
  } } }) do
109
109
  with_input_for @user, :age, :select, collection: 18..30, include_blank: :translate
110
- assert_select 'select option[value=]', 'Rather not say'
110
+ assert_select 'select option[value=""]', 'Rather not say'
111
111
  end
112
112
  end
113
113
 
114
- test 'input should translate include blank with a default' do
114
+ test 'input translates include blank with a default' do
115
115
  store_translations(:en, simple_form: { include_blanks: { defaults: {
116
116
  age: 'Rather not say',
117
117
  } } }) do
118
118
  with_input_for @user, :age, :select, collection: 18..30, include_blank: :translate
119
- assert_select 'select option[value=]', 'Rather not say'
119
+ assert_select 'select option[value=""]', 'Rather not say'
120
120
  end
121
121
  end
122
122
 
123
- test 'input should not translate include blank when set to a string' do
123
+ test 'input does not translate include blank when set to a string' do
124
124
  store_translations(:en, simple_form: { include_blanks: { user: {
125
125
  age: 'Rather not say'
126
126
  } } }) do
127
127
  with_input_for @user, :age, :select, collection: 18..30, include_blank: 'Young at heart'
128
- assert_select 'select option[value=]', 'Young at heart'
128
+ assert_select 'select option[value=""]', 'Young at heart'
129
129
  end
130
130
  end
131
131
 
132
- test 'input should not translate include blank when automatically set' do
132
+ test 'input does not translate include blank when automatically set' do
133
133
  store_translations(:en, simple_form: { include_blanks: { user: {
134
134
  age: 'Rather not say'
135
135
  } } }) do
136
136
  with_input_for @user, :age, :select, collection: 18..30
137
- assert_select 'select option[value=]', ''
137
+ assert_select 'select option[value=""]', ''
138
138
  end
139
139
  end
140
140
 
141
- test 'input should not translate include blank when set to true' do
141
+ test 'input does not translate include blank when set to true' do
142
142
  store_translations(:en, simple_form: { include_blanks: { user: {
143
143
  age: 'Rather not say'
144
144
  } } }) do
145
145
  with_input_for @user, :age, :select, collection: 18..30, include_blank: true
146
- assert_select 'select option[value=]', ''
146
+ assert_select 'select option[value=""]', ''
147
147
  end
148
148
  end
149
149
 
150
- test 'input should not translate include blank when set to false' do
150
+ test 'input does not translate include blank when set to false' do
151
151
  store_translations(:en, simple_form: { include_blanks: { user: {
152
152
  age: 'Rather not say'
153
153
  } } }) do
154
154
  with_input_for @user, :age, :select, collection: 18..30, include_blank: false
155
- assert_no_select 'select option[value=]'
155
+ assert_no_select 'select option[value=""]'
156
156
  end
157
157
  end
158
158
 
159
- test 'input should not set include blank if otherwise is told' do
159
+ test 'input does not set include blank if otherwise is told' do
160
160
  with_input_for @user, :age, :select, collection: 18..30, include_blank: false
161
- assert_no_select 'select option[value=]'
161
+ assert_no_select 'select option[value=""]'
162
162
  end
163
163
 
164
- test 'input should not set include blank if prompt is given' do
164
+ test 'input does not set include blank if prompt is given' do
165
165
  with_input_for @user, :age, :select, collection: 18..30, prompt: "Please select foo"
166
- assert_no_select 'select option[value=]', ''
166
+ assert_no_select 'select option[value=""]', ''
167
167
  end
168
168
 
169
- test 'input should not set include blank if multiple is given' do
169
+ test 'input does not set include blank if multiple is given' do
170
170
  with_input_for @user, :age, :select, collection: 18..30, input_html: { multiple: true }
171
- assert_no_select 'select option[value=]', ''
171
+ assert_no_select 'select option[value=""]', ''
172
172
  end
173
173
 
174
- test 'input should translate prompt when set to :translate' do
174
+ test 'input translates prompt when set to :translate' do
175
175
  store_translations(:en, simple_form: { prompts: { user: {
176
176
  age: 'Select age:'
177
177
  } } }) do
178
178
  with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
179
- assert_select 'select option[value=]', 'Select age:'
179
+ assert_select 'select option[value=""]', 'Select age:'
180
180
  end
181
181
  end
182
182
 
183
- test 'input should translate prompt with a default' do
183
+ test 'input translates prompt with a default' do
184
184
  store_translations(:en, simple_form: { prompts: { defaults: {
185
185
  age: 'Select age:',
186
186
  } } }) do
187
187
  with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
188
- assert_select 'select option[value=]', 'Select age:'
188
+ assert_select 'select option[value=""]', 'Select age:'
189
189
  end
190
190
  end
191
191
 
192
- test 'input should not translate prompt when set to a string' do
192
+ test 'input does not translate prompt when set to a string' do
193
193
  store_translations(:en, simple_form: { prompts: { user: {
194
194
  age: 'Select age:'
195
195
  } } }) do
196
196
  with_input_for @user, :age, :select, collection: 18..30, prompt: 'Do it:'
197
- assert_select 'select option[value=]', 'Do it:'
197
+ assert_select 'select option[value=""]', 'Do it:'
198
198
  end
199
199
  end
200
200
 
201
- test 'input should not translate prompt when set to false' do
201
+ test 'input does not translate prompt when set to false' do
202
202
  store_translations(:en, simple_form: { prompts: { user: {
203
203
  age: 'Select age:'
204
204
  } } }) do
205
205
  with_input_for @user, :age, :select, collection: 18..30, prompt: false
206
- assert_no_select 'select option[value=]'
206
+ assert_no_select 'select option[value=""]'
207
207
  end
208
208
  end
209
209
 
210
- test 'input should use Rails prompt translation as a fallback' do
210
+ test 'input uses Rails prompt translation as a fallback' do
211
211
  store_translations(:en, helpers: { select: {
212
212
  prompt: 'Select value:'
213
213
  } }) do
214
214
  with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
215
- assert_select 'select option[value=]', "Select value:"
215
+ assert_select 'select option[value=""]', "Select value:"
216
216
  end
217
217
  end
218
218
 
219
- test 'input should detect label and value on collections' do
219
+ test 'input detects label and value on collections' do
220
220
  users = [User.build(id: 1, name: "Jose"), User.build(id: 2, name: "Carlos")]
221
221
  with_input_for @user, :description, :select, collection: users
222
- assert_select 'select option[value=1]', 'Jose'
223
- assert_select 'select option[value=2]', 'Carlos'
222
+ assert_select 'select option[value="1"]', 'Jose'
223
+ assert_select 'select option[value="2"]', 'Carlos'
224
224
  end
225
225
 
226
- test 'input should disable the anothers components when the option is a object' do
226
+ test 'input disables the anothers components when the option is a object' do
227
227
  with_input_for @user, :description, :select, collection: ["Jose", "Carlos"], disabled: true
228
228
  assert_no_select 'select option[value=Jose][disabled=disabled]', 'Jose'
229
229
  assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
@@ -231,7 +231,7 @@ class CollectionSelectInputTest < ActionView::TestCase
231
231
  assert_select 'div.disabled'
232
232
  end
233
233
 
234
- test 'input should not disable the anothers components when the option is a object' do
234
+ test 'input does not disable the anothers components when the option is a object' do
235
235
  with_input_for @user, :description, :select, collection: ["Jose", "Carlos"], disabled: 'Jose'
236
236
  assert_select 'select option[value=Jose][disabled=disabled]', 'Jose'
237
237
  assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
@@ -239,7 +239,7 @@ class CollectionSelectInputTest < ActionView::TestCase
239
239
  assert_no_select 'div.disabled'
240
240
  end
241
241
 
242
- test 'input should allow overriding label and value method using a lambda for collection selects' do
242
+ test 'input allows overriding label and value method using a lambda for collection selects' do
243
243
  with_input_for @user, :name, :select,
244
244
  collection: ['Jose', 'Carlos'],
245
245
  label_method: lambda { |i| i.upcase },
@@ -248,7 +248,7 @@ class CollectionSelectInputTest < ActionView::TestCase
248
248
  assert_select 'select option[value=carlos]', "CARLOS"
249
249
  end
250
250
 
251
- test 'input should allow overriding only label but not value method using a lambda for collection select' do
251
+ test 'input allows overriding only label but not value method using a lambda for collection select' do
252
252
  with_input_for @user, :name, :select,
253
253
  collection: ['Jose', 'Carlos'],
254
254
  label_method: lambda { |i| i.upcase }
@@ -256,7 +256,7 @@ class CollectionSelectInputTest < ActionView::TestCase
256
256
  assert_select 'select option[value=Carlos]', "CARLOS"
257
257
  end
258
258
 
259
- test 'input should allow overriding only value but not label method using a lambda for collection select' do
259
+ test 'input allows overriding only value but not label method using a lambda for collection select' do
260
260
  with_input_for @user, :name, :select,
261
261
  collection: ['Jose', 'Carlos'],
262
262
  value_method: lambda { |i| i.downcase }
@@ -264,39 +264,39 @@ class CollectionSelectInputTest < ActionView::TestCase
264
264
  assert_select 'select option[value=carlos]', "Carlos"
265
265
  end
266
266
 
267
- test 'input should allow symbols for collections' do
267
+ test 'input allows symbols for collections' do
268
268
  with_input_for @user, :name, :select, collection: [:jose, :carlos]
269
269
  assert_select 'select.select#user_name'
270
270
  assert_select 'select option[value=jose]', 'jose'
271
271
  assert_select 'select option[value=carlos]', 'carlos'
272
272
  end
273
273
 
274
- test 'collection input with select type should generate required html attribute only with blank option' do
274
+ test 'collection input with select type generates required html attribute only with blank option' do
275
275
  with_input_for @user, :name, :select, include_blank: true, collection: ['Jose', 'Carlos']
276
276
  assert_select 'select.required'
277
277
  assert_select 'select[required]'
278
278
  end
279
279
 
280
- test 'collection input with select type should generate required html attribute only with blank option or prompt' do
280
+ test 'collection input with select type generates required html attribute only with blank option or prompt' do
281
281
  with_input_for @user, :name, :select, prompt: 'Name...', collection: ['Jose', 'Carlos']
282
282
  assert_select 'select.required'
283
283
  assert_select 'select[required]'
284
284
  end
285
285
 
286
- test 'collection input with select type should not generate required html attribute without blank option' do
286
+ test 'collection input with select type does not generate required html attribute without blank option' do
287
287
  with_input_for @user, :name, :select, include_blank: false, collection: ['Jose', 'Carlos']
288
288
  assert_select 'select.required'
289
289
  assert_no_select 'select[required]'
290
290
  assert_no_select 'select[aria-required=true]'
291
291
  end
292
292
 
293
- test 'collection input with select type with multiple attribute should generate required html attribute without blank option' do
293
+ test 'collection input with select type with multiple attribute generates required html attribute without blank option' do
294
294
  with_input_for @user, :name, :select, include_blank: false, input_html: { multiple: true }, collection: ['Jose', 'Carlos']
295
295
  assert_select 'select.required'
296
296
  assert_select 'select[required]'
297
297
  end
298
298
 
299
- test 'collection input with select type with multiple attribute should generate required html attribute with blank option' do
299
+ test 'collection input with select type with multiple attribute generates required html attribute with blank option' do
300
300
  with_input_for @user, :name, :select, include_blank: true, input_html: { multiple: true }, collection: ['Jose', 'Carlos']
301
301
  assert_select 'select.required'
302
302
  assert_select 'select[required]'
@@ -326,7 +326,7 @@ class CollectionSelectInputTest < ActionView::TestCase
326
326
  assert_select 'select[aria-required]'
327
327
  end
328
328
 
329
- test 'input should allow disabled options with a lambda for collection select' do
329
+ test 'input allows disabled options with a lambda for collection select' do
330
330
  with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
331
331
  disabled: lambda { |x| x == "Carlos" }
332
332
  assert_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
@@ -334,7 +334,7 @@ class CollectionSelectInputTest < ActionView::TestCase
334
334
  assert_no_select 'select option[value=Antonio][disabled]'
335
335
  end
336
336
 
337
- test 'input should allow disabled and label method with lambdas for collection select' do
337
+ test 'input allows disabled and label method with lambdas for collection select' do
338
338
  with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
339
339
  disabled: lambda { |x| x == "Carlos" }, label_method: lambda { |x| x.upcase }
340
340
  assert_select 'select option[value=Carlos][disabled=disabled]', 'CARLOS'
@@ -342,7 +342,7 @@ class CollectionSelectInputTest < ActionView::TestCase
342
342
  assert_no_select 'select option[value=Antonio][disabled]'
343
343
  end
344
344
 
345
- test 'input should allow a non lambda disabled option with lambda label method for collections' do
345
+ test 'input allows a non lambda disabled option with lambda label method for collections' do
346
346
  with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
347
347
  disabled: "Carlos", label_method: lambda { |x| x.upcase }
348
348
  assert_select 'select option[value=Carlos][disabled=disabled]', 'CARLOS'
@@ -350,7 +350,7 @@ class CollectionSelectInputTest < ActionView::TestCase
350
350
  assert_no_select 'select option[value=Antonio][disabled]'
351
351
  end
352
352
 
353
- test 'input should allow selected and label method with lambdas for collection select' do
353
+ test 'input allows selected and label method with lambdas for collection select' do
354
354
  with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
355
355
  selected: lambda { |x| x == "Carlos" }, label_method: lambda { |x| x.upcase }
356
356
  assert_select 'select option[value=Carlos][selected=selected]', 'CARLOS'
@@ -358,7 +358,7 @@ class CollectionSelectInputTest < ActionView::TestCase
358
358
  assert_no_select 'select option[value=Antonio][selected]'
359
359
  end
360
360
 
361
- test 'input should allow a non lambda selected option with lambda label method for collection select' do
361
+ test 'input allows a non lambda selected option with lambda label method for collection select' do
362
362
  with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
363
363
  selected: "Carlos", label_method: lambda { |x| x.upcase }
364
364
  assert_select 'select option[value=Carlos][selected=selected]', 'CARLOS'
@@ -366,7 +366,7 @@ class CollectionSelectInputTest < ActionView::TestCase
366
366
  assert_no_select 'select option[value=Antonio][selected]'
367
367
  end
368
368
 
369
- test 'input should not override default selection through attribute value with label method as lambda for collection select' do
369
+ test 'input does not override default selection through attribute value with label method as lambda for collection select' do
370
370
  @user.name = "Carlos"
371
371
  with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
372
372
  label_method: lambda { |x| x.upcase }
@@ -3,49 +3,49 @@ require 'test_helper'
3
3
 
4
4
  # Tests for datetime, date and time inputs when HTML5 compatibility is enabled in the wrapper.
5
5
  class DateTimeInputWithHtml5Test < ActionView::TestCase
6
- test 'input should generate a datetime input for datetime attributes if HTML5 compatibility is explicitly enbled' do
6
+ test 'input generates a datetime input for datetime attributes if HTML5 compatibility is explicitly enbled' do
7
7
  with_input_for @user, :created_at, :datetime, html5: true
8
8
 
9
9
  assert_select 'input[type="datetime"]'
10
10
  end
11
11
 
12
- test 'input should generate a datetime select for datetime attributes' do
12
+ test 'input generates a datetime select for datetime attributes' do
13
13
  with_input_for @user, :created_at, :datetime
14
14
 
15
15
  assert_select 'select.datetime'
16
16
  end
17
17
 
18
- test 'input should generate a date input for date attributes if HTML5 compatibility is explicitly enbled' do
18
+ test 'input generates a date input for date attributes if HTML5 compatibility is explicitly enbled' do
19
19
  with_input_for @user, :born_at, :date, html5: true
20
20
 
21
21
  assert_select 'input[type="date"]'
22
22
  end
23
23
 
24
- test 'input should generate a date select for date attributes' do
24
+ test 'input generates a date select for date attributes' do
25
25
  with_input_for @user, :born_at, :date
26
26
 
27
27
  assert_select 'select.date'
28
28
  end
29
29
 
30
- test 'input should generate a time input for time attributes if HTML5 compatibility is explicitly enbled' do
30
+ test 'input generates a time input for time attributes if HTML5 compatibility is explicitly enbled' do
31
31
  with_input_for @user, :delivery_time, :time, html5: true
32
32
 
33
33
  assert_select 'input[type="time"]'
34
34
  end
35
35
 
36
- test 'input should generate a time select for time attributes' do
36
+ test 'input generates a time select for time attributes' do
37
37
  with_input_for @user, :delivery_time, :time
38
38
 
39
39
  assert_select 'select.time'
40
40
  end
41
41
 
42
- test 'input should generate required html attribute' do
42
+ test 'input generates required html attribute' do
43
43
  with_input_for @user, :delivery_time, :time, required: true, html5: true
44
44
  assert_select 'input.required'
45
45
  assert_select 'input[required]'
46
46
  end
47
47
 
48
- test 'input should have an aria-required html attribute' do
48
+ test 'input has an aria-required html attribute' do
49
49
  with_input_for @user, :delivery_time, :time, required: true, html5: true
50
50
  assert_select 'input[aria-required=true]'
51
51
  end
@@ -53,7 +53,7 @@ end
53
53
 
54
54
  # Tests for datetime, date and time inputs when HTML5 compatibility is enabled in the wrapper.
55
55
  class DateTimeInputWithoutHtml5Test < ActionView::TestCase
56
- test 'input should generate a datetime select by default for datetime attributes' do
56
+ test 'input generates a datetime select by default for datetime attributes' do
57
57
  swap_wrapper do
58
58
  with_input_for @user, :created_at, :datetime
59
59
  1.upto(5) do |i|
@@ -62,7 +62,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
62
62
  end
63
63
  end
64
64
 
65
- test 'input should be able to pass options to datetime select' do
65
+ test 'input is able to pass options to datetime select' do
66
66
  with_input_for @user, :created_at, :datetime, html5: false,
67
67
  disabled: true, prompt: { year: 'ano', month: 'mês', day: 'dia' }
68
68
 
@@ -72,7 +72,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
72
72
  assert_select 'select.datetime option', 'dia'
73
73
  end
74
74
 
75
- test 'input should generate a datetime input for datetime attributes if HTML5 compatibility is explicitly enabled' do
75
+ test 'input generates a datetime input for datetime attributes if HTML5 compatibility is explicitly enabled' do
76
76
  swap_wrapper do
77
77
  with_input_for @user, :created_at, :datetime, html5: true
78
78
 
@@ -80,7 +80,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
80
80
  end
81
81
  end
82
82
 
83
- test 'input should generate a date select for date attributes' do
83
+ test 'input generates a date select for date attributes' do
84
84
  swap_wrapper do
85
85
  with_input_for @user, :born_at, :date
86
86
  assert_select 'select.date#user_born_at_1i'
@@ -90,7 +90,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
90
90
  end
91
91
  end
92
92
 
93
- test 'input should be able to pass options to date select' do
93
+ test 'input is able to pass options to date select' do
94
94
  with_input_for @user, :born_at, :date, as: :date, html5: false,
95
95
  disabled: true, prompt: { year: 'ano', month: 'mês', day: 'dia' }
96
96
 
@@ -100,12 +100,12 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
100
100
  assert_select 'select.date option', 'dia'
101
101
  end
102
102
 
103
- test 'input should be able to pass :default to date select' do
103
+ test 'input is able to pass :default to date select' do
104
104
  with_input_for @user, :born_at, :date, default: Date.today, html5: false
105
- assert_select "select.date option[value=#{Date.today.year}][selected=selected]"
105
+ assert_select "select.date option[value='#{Date.today.year}'][selected=selected]"
106
106
  end
107
107
 
108
- test 'input should generate a date input for date attributes if HTML5 compatibility is explicitly enabled' do
108
+ test 'input generates a date input for date attributes if HTML5 compatibility is explicitly enabled' do
109
109
  swap_wrapper do
110
110
  with_input_for @user, :born_at, :date, html5: true
111
111
 
@@ -113,7 +113,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
113
113
  end
114
114
  end
115
115
 
116
- test 'input should generate a time select for time attributes' do
116
+ test 'input generates a time select for time attributes' do
117
117
  swap_wrapper do
118
118
  with_input_for @user, :delivery_time, :time
119
119
  assert_select 'input[type=hidden]#user_delivery_time_1i'
@@ -124,7 +124,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
124
124
  end
125
125
  end
126
126
 
127
- test 'input should be able to pass options to time select' do
127
+ test 'input is able to pass options to time select' do
128
128
  with_input_for @user, :delivery_time, :time, required: true, html5: false,
129
129
  disabled: true, prompt: { hour: 'hora', minute: 'minuto' }
130
130
 
@@ -133,7 +133,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
133
133
  assert_select 'select.time option', 'minuto'
134
134
  end
135
135
 
136
- test 'input should generate a time input for time attributes if HTML5 compatibility is explicitly enabled' do
136
+ test 'input generates a time input for time attributes if HTML5 compatibility is explicitly enabled' do
137
137
  swap_wrapper do
138
138
  with_input_for @user, :delivery_time, :time, html5: true
139
139
 
@@ -141,31 +141,31 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
141
141
  end
142
142
  end
143
143
 
144
- test 'label should use i18n to get target for date input type' do
144
+ test 'label uses i18n to get target for date input type' do
145
145
  store_translations(:en, date: { order: ['month', 'day', 'year'] }) do
146
146
  with_input_for :project, :created_at, :date, html5: false
147
147
  assert_select 'label[for=project_created_at_2i]'
148
148
  end
149
149
  end
150
150
 
151
- test 'label should use i18n to get target for datetime input type' do
151
+ test 'label uses i18n to get target for datetime input type' do
152
152
  store_translations(:en, date: { order: ['month', 'day', 'year'] }) do
153
153
  with_input_for :project, :created_at, :datetime, html5: false
154
154
  assert_select 'label[for=project_created_at_2i]'
155
155
  end
156
156
  end
157
157
 
158
- test 'label should use order to get target when date input type' do
158
+ test 'label uses order to get target when date input type' do
159
159
  with_input_for :project, :created_at, :date, order: ['month', 'year', 'day'], html5: false
160
160
  assert_select 'label[for=project_created_at_2i]'
161
161
  end
162
162
 
163
- test 'label should use order to get target when datetime input type' do
163
+ test 'label uses order to get target when datetime input type' do
164
164
  with_input_for :project, :created_at, :datetime, order: ['month', 'year', 'day'], html5: false
165
165
  assert_select 'label[for=project_created_at_2i]'
166
166
  end
167
167
 
168
- test 'label should point to first option when time input type' do
168
+ test 'label points to first option when time input type' do
169
169
  with_input_for :project, :created_at, :time, html5: false
170
170
  assert_select 'label[for=project_created_at_4i]'
171
171
  end