simple_form 3.1.0.rc1 → 3.1.0.rc2

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.

Potentially problematic release.


This version of simple_form might be problematic. Click here for more details.

Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -1
  3. data/README.md +37 -6
  4. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +6 -2
  5. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +37 -14
  6. data/lib/simple_form.rb +8 -0
  7. data/lib/simple_form/components/labels.rb +1 -1
  8. data/lib/simple_form/form_builder.rb +29 -15
  9. data/lib/simple_form/inputs/boolean_input.rb +7 -4
  10. data/lib/simple_form/tags.rb +1 -0
  11. data/lib/simple_form/version.rb +1 -1
  12. data/lib/simple_form/wrappers/builder.rb +2 -2
  13. data/lib/simple_form/wrappers/many.rb +1 -0
  14. data/test/action_view_extensions/builder_test.rb +3 -3
  15. data/test/action_view_extensions/form_helper_test.rb +13 -13
  16. data/test/components/label_test.rb +35 -35
  17. data/test/form_builder/association_test.rb +4 -4
  18. data/test/form_builder/button_test.rb +5 -5
  19. data/test/form_builder/error_test.rb +18 -18
  20. data/test/form_builder/general_test.rb +65 -60
  21. data/test/form_builder/hint_test.rb +15 -15
  22. data/test/form_builder/input_field_test.rb +16 -16
  23. data/test/form_builder/label_test.rb +22 -13
  24. data/test/form_builder/wrapper_test.rb +54 -20
  25. data/test/inputs/boolean_input_test.rb +8 -8
  26. data/test/inputs/collection_check_boxes_input_test.rb +24 -7
  27. data/test/inputs/collection_radio_buttons_input_test.rb +40 -23
  28. data/test/inputs/collection_select_input_test.rb +45 -45
  29. data/test/inputs/datetime_input_test.rb +23 -23
  30. data/test/inputs/disabled_test.rb +15 -15
  31. data/test/inputs/discovery_test.rb +44 -5
  32. data/test/inputs/file_input_test.rb +2 -2
  33. data/test/inputs/general_test.rb +20 -20
  34. data/test/inputs/grouped_collection_select_input_test.rb +2 -2
  35. data/test/inputs/hidden_input_test.rb +4 -4
  36. data/test/inputs/numeric_input_test.rb +24 -24
  37. data/test/inputs/priority_input_test.rb +7 -7
  38. data/test/inputs/readonly_test.rb +19 -19
  39. data/test/inputs/required_test.rb +13 -13
  40. data/test/inputs/string_input_test.rb +23 -23
  41. data/test/inputs/text_input_test.rb +4 -4
  42. data/test/support/discovery_inputs.rb +20 -0
  43. data/test/support/misc_helpers.rb +22 -0
  44. data/test/support/models.rb +2 -1
  45. metadata +2 -2
@@ -8,7 +8,7 @@ class FormBuilderTest < ActionView::TestCase
8
8
  end
9
9
  end
10
10
 
11
- test 'nested simple fields should yield an instance of FormBuilder' do
11
+ test 'nested simple fields yields an instance of FormBuilder' do
12
12
  simple_form_for :user do |f|
13
13
  f.simple_fields_for :posts do |posts_form|
14
14
  assert posts_form.instance_of?(SimpleForm::FormBuilder)
@@ -22,7 +22,7 @@ class FormBuilderTest < ActionView::TestCase
22
22
  end
23
23
  end
24
24
 
25
- test 'builder should work without controller' do
25
+ test 'builder works without controller' do
26
26
  stub_any_instance ActionView::TestCase, :controller, nil do
27
27
  simple_form_for @user do |f|
28
28
  assert f.input(:name)
@@ -30,7 +30,7 @@ class FormBuilderTest < ActionView::TestCase
30
30
  end
31
31
  end
32
32
 
33
- test 'builder input should allow a block to configure input' do
33
+ test 'builder input allows a block to configure input' do
34
34
  with_form_for @user, :name do
35
35
  text_field_tag :foo, :bar, id: :cool
36
36
  end
@@ -38,7 +38,7 @@ class FormBuilderTest < ActionView::TestCase
38
38
  assert_select 'input#cool'
39
39
  end
40
40
 
41
- test 'builder should allow adding custom input mappings for default input types' do
41
+ test 'builder allows adding custom input mappings for default input types' do
42
42
  swap SimpleForm, input_mappings: { /count$/ => :integer } do
43
43
  with_form_for @user, :post_count
44
44
  assert_no_select 'form input#user_post_count.string'
@@ -46,7 +46,7 @@ class FormBuilderTest < ActionView::TestCase
46
46
  end
47
47
  end
48
48
 
49
- test 'builder should allow to skip input_type class' do
49
+ test 'builder allows to skip input_type class' do
50
50
  swap SimpleForm, generate_additional_classes_for: [:label, :wrapper] do
51
51
  with_form_for @user, :post_count
52
52
  assert_no_select "form input#user_post_count.integer"
@@ -54,7 +54,7 @@ class FormBuilderTest < ActionView::TestCase
54
54
  end
55
55
  end
56
56
 
57
- test 'builder should allow to add additional classes only for wrapper' do
57
+ test 'builder allows to add additional classes only for wrapper' do
58
58
  swap SimpleForm, generate_additional_classes_for: [:wrapper] do
59
59
  with_form_for @user, :post_count
60
60
  assert_no_select "form input#user_post_count.string"
@@ -63,7 +63,7 @@ class FormBuilderTest < ActionView::TestCase
63
63
  end
64
64
  end
65
65
 
66
- test 'builder should allow adding custom input mappings for integer input types' do
66
+ test 'builder allows adding custom input mappings for integer input types' do
67
67
  swap SimpleForm, input_mappings: { /lock_version/ => :hidden } do
68
68
  with_form_for @user, :lock_version
69
69
  assert_no_select 'form input#user_lock_version.integer'
@@ -101,82 +101,87 @@ class FormBuilderTest < ActionView::TestCase
101
101
  end
102
102
 
103
103
  # INPUT TYPES
104
- test 'builder should generate text fields for string columns' do
104
+ test 'builder generates text fields for string columns' do
105
105
  with_form_for @user, :name
106
106
  assert_select 'form input#user_name.string'
107
107
  end
108
108
 
109
- test 'builder should generate text areas for text columns' do
109
+ test 'builder generates text areas for text columns' do
110
110
  with_form_for @user, :description
111
111
  assert_select 'form textarea#user_description.text'
112
112
  end
113
113
 
114
- test 'builder should generate a checkbox for boolean columns' do
114
+ test 'builder generates a checkbox for boolean columns' do
115
115
  with_form_for @user, :active
116
116
  assert_select 'form input[type=checkbox]#user_active.boolean'
117
117
  end
118
118
 
119
- test 'builder should use integer text field for integer columns' do
119
+ test 'builder uses integer text field for integer columns' do
120
120
  with_form_for @user, :age
121
121
  assert_select 'form input#user_age.numeric.integer'
122
122
  end
123
123
 
124
- test 'builder should generate decimal text field for decimal columns' do
124
+ test 'builder generates decimal text field for decimal columns' do
125
125
  with_form_for @user, :credit_limit
126
126
  assert_select 'form input#user_credit_limit.numeric.decimal'
127
127
  end
128
128
 
129
- test 'builder should generate password fields for columns that matches password' do
129
+ test 'builder generates uuid fields for uuid columns' do
130
+ with_form_for @user, :uuid
131
+ assert_select 'form input#user_uuid.string.uuid'
132
+ end
133
+
134
+ test 'builder generates password fields for columns that matches password' do
130
135
  with_form_for @user, :password
131
136
  assert_select 'form input#user_password.password'
132
137
  end
133
138
 
134
- test 'builder should generate country fields for columns that matches country' do
139
+ test 'builder generates country fields for columns that matches country' do
135
140
  with_form_for @user, :residence_country
136
141
  assert_select 'form select#user_residence_country.country'
137
142
  end
138
143
 
139
- test 'builder should generate time_zone fields for columns that matches time_zone' do
144
+ test 'builder generates time_zone fields for columns that matches time_zone' do
140
145
  with_form_for @user, :time_zone
141
146
  assert_select 'form select#user_time_zone.time_zone'
142
147
  end
143
148
 
144
- test 'builder should generate email fields for columns that matches email' do
149
+ test 'builder generates email fields for columns that matches email' do
145
150
  with_form_for @user, :email
146
151
  assert_select 'form input#user_email.string.email'
147
152
  end
148
153
 
149
- test 'builder should generate tel fields for columns that matches phone' do
154
+ test 'builder generates tel fields for columns that matches phone' do
150
155
  with_form_for @user, :phone_number
151
156
  assert_select 'form input#user_phone_number.string.tel'
152
157
  end
153
158
 
154
- test 'builder should generate url fields for columns that matches url' do
159
+ test 'builder generates url fields for columns that matches url' do
155
160
  with_form_for @user, :url
156
161
  assert_select 'form input#user_url.string.url'
157
162
  end
158
163
 
159
- test 'builder should generate date select for date columns' do
164
+ test 'builder generates date select for date columns' do
160
165
  with_form_for @user, :born_at
161
166
  assert_select 'form select#user_born_at_1i.date'
162
167
  end
163
168
 
164
- test 'builder should generate time select for time columns' do
169
+ test 'builder generates time select for time columns' do
165
170
  with_form_for @user, :delivery_time
166
171
  assert_select 'form select#user_delivery_time_4i.time'
167
172
  end
168
173
 
169
- test 'builder should generate datetime select for datetime columns' do
174
+ test 'builder generates datetime select for datetime columns' do
170
175
  with_form_for @user, :created_at
171
176
  assert_select 'form select#user_created_at_1i.datetime'
172
177
  end
173
178
 
174
- test 'builder should generate datetime select for timestamp columns' do
179
+ test 'builder generates datetime select for timestamp columns' do
175
180
  with_form_for @user, :updated_at
176
181
  assert_select 'form select#user_updated_at_1i.datetime'
177
182
  end
178
183
 
179
- test 'builder should generate file for file columns' do
184
+ test 'builder generates file for file columns' do
180
185
  @user.avatar = MiniTest::Mock.new
181
186
  @user.avatar.expect(:public_filename, true)
182
187
 
@@ -184,7 +189,7 @@ class FormBuilderTest < ActionView::TestCase
184
189
  assert_select 'form input#user_avatar.file'
185
190
  end
186
191
 
187
- test 'builder should generate file for attributes that are real db columns but have file methods' do
192
+ test 'builder generates file for attributes that are real db columns but have file methods' do
188
193
  @user.home_picture = MiniTest::Mock.new
189
194
  @user.home_picture.expect(:mounted_as, true)
190
195
 
@@ -192,12 +197,12 @@ class FormBuilderTest < ActionView::TestCase
192
197
  assert_select 'form input#user_home_picture.file'
193
198
  end
194
199
 
195
- test 'build should generate select if a collection is given' do
200
+ test 'build generates select if a collection is given' do
196
201
  with_form_for @user, :age, collection: 1..60
197
202
  assert_select 'form select#user_age.select'
198
203
  end
199
204
 
200
- test 'builder should allow overriding default input type for text' do
205
+ test 'builder allows overriding default input type for text' do
201
206
  with_form_for @user, :name, as: :text
202
207
  assert_no_select 'form input#user_name'
203
208
  assert_select 'form textarea#user_name.text'
@@ -212,25 +217,25 @@ class FormBuilderTest < ActionView::TestCase
212
217
  end
213
218
 
214
219
  # COMMON OPTIONS
215
- test 'builder should add chosen form class' do
220
+ test 'builder adds chosen form class' do
216
221
  swap SimpleForm, form_class: :my_custom_class do
217
222
  with_form_for @user, :name
218
223
  assert_select 'form.my_custom_class'
219
224
  end
220
225
  end
221
226
 
222
- test 'builder should allow passing options to input' do
227
+ test 'builder allows passing options to input' do
223
228
  with_form_for @user, :name, input_html: { class: 'my_input', id: 'my_input' }
224
229
  assert_select 'form input#my_input.my_input.string'
225
230
  end
226
231
 
227
- test 'builder should not propagate input options to wrapper' do
232
+ test 'builder does not propagate input options to wrapper' do
228
233
  with_form_for @user, :name, input_html: { class: 'my_input', id: 'my_input' }
229
234
  assert_no_select 'form div.input.my_input.string'
230
235
  assert_select 'form input#my_input.my_input.string'
231
236
  end
232
237
 
233
- test 'builder should not propagate input options to wrapper with custom wrapper' do
238
+ test 'builder does not propagate input options to wrapper with custom wrapper' do
234
239
  swap_wrapper :default, self.custom_wrapper_with_wrapped_input do
235
240
  with_form_for @user, :name, input_html: { class: 'my_input' }
236
241
  assert_no_select 'form div.input.my_input'
@@ -238,7 +243,7 @@ class FormBuilderTest < ActionView::TestCase
238
243
  end
239
244
  end
240
245
 
241
- test 'builder should not propagate label options to wrapper with custom wrapper' do
246
+ test 'builder does not propagate label options to wrapper with custom wrapper' do
242
247
  swap_wrapper :default, self.custom_wrapper_with_wrapped_label do
243
248
  with_form_for @user, :name, label_html: { class: 'my_label' }
244
249
  assert_no_select 'form div.label.my_label'
@@ -246,42 +251,42 @@ class FormBuilderTest < ActionView::TestCase
246
251
  end
247
252
  end
248
253
 
249
- test 'builder should generate a input with label' do
254
+ test 'builder generates an input with label' do
250
255
  with_form_for @user, :name
251
256
  assert_select 'form label.string[for=user_name]', /Name/
252
257
  end
253
258
 
254
- test 'builder should be able to disable the label for a input' do
259
+ test 'builder is able to disable the label for an input' do
255
260
  with_form_for @user, :name, label: false
256
261
  assert_no_select 'form label'
257
262
  end
258
263
 
259
- test 'builder should be able to disable the label for an input and return a html safe string' do
264
+ test 'builder is able to disable the label for an input and return a html safe string' do
260
265
  with_form_for @user, :name, label: false, wrapper: custom_wrapper_with_wrapped_label_input
261
266
  assert_select 'form input#user_name'
262
267
  end
263
268
 
264
- test 'builder should use custom label' do
269
+ test 'builder uses custom label' do
265
270
  with_form_for @user, :name, label: 'Yay!'
266
271
  assert_select 'form label', /Yay!/
267
272
  end
268
273
 
269
- test 'builder should pass options to label' do
274
+ test 'builder passes options to label' do
270
275
  with_form_for @user, :name, label_html: { id: "cool" }
271
276
  assert_select 'form label#cool', /Name/
272
277
  end
273
278
 
274
- test 'builder should not generate hints for a input' do
279
+ test 'builder does not generate hints for an input' do
275
280
  with_form_for @user, :name
276
281
  assert_no_select 'span.hint'
277
282
  end
278
283
 
279
- test 'builder should be able to add a hint for a input' do
284
+ test 'builder is able to add a hint for an input' do
280
285
  with_form_for @user, :name, hint: 'test'
281
286
  assert_select 'span.hint', 'test'
282
287
  end
283
288
 
284
- test 'builder should be able to disable a hint even if it exists in i18n' do
289
+ test 'builder is able to disable a hint even if it exists in i18n' do
285
290
  store_translations(:en, simple_form: { hints: { name: 'Hint test' } }) do
286
291
  stub_any_instance(SimpleForm::Inputs::Base, :hint, -> { raise 'Never' }) do
287
292
  with_form_for @user, :name, hint: false
@@ -290,32 +295,32 @@ class FormBuilderTest < ActionView::TestCase
290
295
  end
291
296
  end
292
297
 
293
- test 'builder should pass options to hint' do
298
+ test 'builder passes options to hint' do
294
299
  with_form_for @user, :name, hint: 'test', hint_html: { id: "cool" }
295
300
  assert_select 'span.hint#cool', 'test'
296
301
  end
297
302
 
298
- test 'builder should generate errors for attribute without errors' do
303
+ test 'builder generates errors for attribute without errors' do
299
304
  with_form_for @user, :credit_limit
300
305
  assert_no_select 'span.errors'
301
306
  end
302
307
 
303
- test 'builder should generate errors for attribute with errors' do
308
+ test 'builder generates errors for attribute with errors' do
304
309
  with_form_for @user, :name
305
310
  assert_select 'span.error', "can't be blank"
306
311
  end
307
312
 
308
- test 'builder should be able to disable showing errors for a input' do
313
+ test 'builder is able to disable showing errors for an input' do
309
314
  with_form_for @user, :name, error: false
310
315
  assert_no_select 'span.error'
311
316
  end
312
317
 
313
- test 'builder should pass options to errors' do
318
+ test 'builder passes options to errors' do
314
319
  with_form_for @user, :name, error_html: { id: "cool" }
315
320
  assert_select 'span.error#cool', "can't be blank"
316
321
  end
317
322
 
318
- test 'placeholder should not be generated when set to false' do
323
+ test 'placeholder does not be generated when set to false' do
319
324
  store_translations(:en, simple_form: { placeholders: { user: {
320
325
  name: 'Name goes here'
321
326
  } } }) do
@@ -326,14 +331,14 @@ class FormBuilderTest < ActionView::TestCase
326
331
 
327
332
  # DEFAULT OPTIONS
328
333
  [:input, :input_field].each do |method|
329
- test "builder should receive a default argument and pass it to the inputs when calling '#{method}'" do
334
+ test "builder receives a default argument and pass it to the inputs when calling '#{method}'" do
330
335
  with_concat_form_for @user, defaults: { input_html: { class: 'default_class' } } do |f|
331
336
  f.send(method, :name)
332
337
  end
333
338
  assert_select 'input.default_class'
334
339
  end
335
340
 
336
- test "builder should receive a default argument and pass it to the inputs without changing the defaults when calling '#{method}'" do
341
+ test "builder receives a default argument and pass it to the inputs without changing the defaults when calling '#{method}'" do
337
342
  with_concat_form_for @user, defaults: { input_html: { class: 'default_class', id: 'default_id' } } do |f|
338
343
  concat(f.send(method, :name))
339
344
  concat(f.send(method, :credit_limit))
@@ -343,7 +348,7 @@ class FormBuilderTest < ActionView::TestCase
343
348
  assert_no_select "input.string[name='user[credit_limit]']"
344
349
  end
345
350
 
346
- test "builder should receive a default argument and pass it to the inputs and nested form when calling '#{method}'" do
351
+ test "builder receives a default argument and pass it to the inputs and nested form when calling '#{method}'" do
347
352
  @user.company = Company.new(1, 'Empresa')
348
353
 
349
354
  with_concat_form_for @user, defaults: { input_html: { class: 'default_class' } } do |f|
@@ -358,28 +363,28 @@ class FormBuilderTest < ActionView::TestCase
358
363
  end
359
364
  end
360
365
 
361
- test "builder should receive a default argument and pass it to the inputs when calling 'input', respecting the specific options" do
366
+ test "builder receives a default argument and pass it to the inputs when calling 'input', respecting the specific options" do
362
367
  with_concat_form_for @user, defaults: { input_html: { class: 'default_class' } } do |f|
363
368
  f.input :name, input_html: { id: 'specific_id' }
364
369
  end
365
370
  assert_select 'input.default_class#specific_id'
366
371
  end
367
372
 
368
- test "builder should receive a default argument and pass it to the inputs when calling 'input_field', respecting the specific options" do
373
+ test "builder receives a default argument and pass it to the inputs when calling 'input_field', respecting the specific options" do
369
374
  with_concat_form_for @user, defaults: { input_html: { class: 'default_class' } } do |f|
370
375
  f.input_field :name, id: 'specific_id'
371
376
  end
372
377
  assert_select 'input.default_class#specific_id'
373
378
  end
374
379
 
375
- test "builder should receive a default argument and pass it to the inputs when calling 'input', overwriting the defaults with specific options" do
380
+ test "builder receives a default argument and pass it to the inputs when calling 'input', overwriting the defaults with specific options" do
376
381
  with_concat_form_for @user, defaults: { input_html: { class: 'default_class', id: 'default_id' } } do |f|
377
382
  f.input :name, input_html: { id: 'specific_id' }
378
383
  end
379
384
  assert_select 'input.default_class#specific_id'
380
385
  end
381
386
 
382
- test "builder should receive a default argument and pass it to the inputs when calling 'input_field', overwriting the defaults with specific options" do
387
+ test "builder receives a default argument and pass it to the inputs when calling 'input_field', overwriting the defaults with specific options" do
383
388
  with_concat_form_for @user, defaults: { input_html: { class: 'default_class', id: 'default_id' } } do |f|
384
389
  f.input_field :name, id: 'specific_id'
385
390
  end
@@ -387,24 +392,24 @@ class FormBuilderTest < ActionView::TestCase
387
392
  end
388
393
 
389
394
  # WITHOUT OBJECT
390
- test 'builder should generate properly when object is not present' do
395
+ test 'builder generates properly when object is not present' do
391
396
  with_form_for :project, :name
392
397
  assert_select 'form input.string#project_name'
393
398
  end
394
399
 
395
- test 'builder should generate password fields based on attribute name when object is not present' do
400
+ test 'builder generates password fields based on attribute name when object is not present' do
396
401
  with_form_for :project, :password_confirmation
397
402
  assert_select 'form input[type=password].password#project_password_confirmation'
398
403
  end
399
404
 
400
- test 'builder should generate text fields by default for all attributes when object is not present' do
405
+ test 'builder generates text fields by default for all attributes when object is not present' do
401
406
  with_form_for :project, :created_at
402
407
  assert_select 'form input.string#project_created_at'
403
408
  with_form_for :project, :budget
404
409
  assert_select 'form input.string#project_budget'
405
410
  end
406
411
 
407
- test 'builder should allow overriding input type when object is not present' do
412
+ test 'builder allows overriding input type when object is not present' do
408
413
  with_form_for :project, :created_at, as: :datetime
409
414
  assert_select 'form select.datetime#project_created_at_1i'
410
415
  with_form_for :project, :budget, as: :decimal
@@ -412,24 +417,24 @@ class FormBuilderTest < ActionView::TestCase
412
417
  end
413
418
 
414
419
  # CUSTOM FORM BUILDER
415
- test 'custom builder should inherit mappings' do
420
+ test 'custom builder inherits mappings' do
416
421
  with_custom_form_for @user, :email
417
422
  assert_select 'form input[type=email]#user_email.custom'
418
423
  end
419
424
 
420
- test 'form with CustomMapTypeFormBuilder should use custom map type builder' do
425
+ test 'form with CustomMapTypeFormBuilder uses custom map type builder' do
421
426
  with_concat_custom_mapping_form_for(:user) do |user|
422
427
  assert user.instance_of?(CustomMapTypeFormBuilder)
423
428
  end
424
429
  end
425
430
 
426
- test 'form with CustomMapTypeFormBuilder should use custom mapping' do
431
+ test 'form with CustomMapTypeFormBuilder uses custom mapping' do
427
432
  with_concat_custom_mapping_form_for(:user) do |user|
428
433
  assert_equal SimpleForm::Inputs::StringInput, user.class.mappings[:custom_type]
429
434
  end
430
435
  end
431
436
 
432
- test 'form without CustomMapTypeFormBuilder should not use custom mapping' do
437
+ test 'form without CustomMapTypeFormBuilder does not use custom mapping' do
433
438
  with_concat_form_for(:user) do |user|
434
439
  assert_nil user.class.mappings[:custom_type]
435
440
  end
@@ -8,24 +8,24 @@ class HintTest < ActionView::TestCase
8
8
  end
9
9
  end
10
10
 
11
- test 'hint should not be generated by default' do
11
+ test 'hint does not be generated by default' do
12
12
  with_hint_for @user, :name
13
13
  assert_no_select 'span.hint'
14
14
  end
15
15
 
16
- test 'hint should be generated with optional text' do
16
+ test 'hint is generated with optional text' do
17
17
  with_hint_for @user, :name, hint: 'Use with care...'
18
18
  assert_select 'span.hint', 'Use with care...'
19
19
  end
20
20
 
21
- test 'hint should not modify the options hash' do
21
+ test 'hint does not modify the options hash' do
22
22
  options = { hint: 'Use with care...' }
23
23
  with_hint_for @user, :name, options
24
24
  assert_select 'span.hint', 'Use with care...'
25
25
  assert_equal({ hint: 'Use with care...' }, options)
26
26
  end
27
27
 
28
- test 'hint should be generated cleanly with optional text' do
28
+ test 'hint is generated cleanly with optional text' do
29
29
  with_hint_for @user, :name, hint: 'Use with care...', hint_tag: :span
30
30
  assert_no_select 'span.hint[hint]'
31
31
  assert_no_select 'span.hint[hint_tag]'
@@ -37,18 +37,18 @@ class HintTest < ActionView::TestCase
37
37
  assert_select 'p.hint', 'Use with care...'
38
38
  end
39
39
 
40
- test 'hint should be able to pass html options' do
40
+ test 'hint is able to pass html options' do
41
41
  with_hint_for @user, :name, hint: 'Yay!', id: 'hint', class: 'yay'
42
42
  assert_select 'span#hint.hint.yay'
43
43
  end
44
44
 
45
- test 'hint should be output as html_safe' do
45
+ test 'hint is output as html_safe' do
46
46
  with_hint_for @user, :name, hint: '<b>Bold</b> and not...'.html_safe
47
47
  assert_select 'span.hint', 'Bold and not...'
48
48
  assert_select 'span.hint b', 'Bold'
49
49
  end
50
50
 
51
- test 'builder should escape hint text' do
51
+ test 'builder escapes hint text' do
52
52
  with_hint_for @user, :name, hint: '<script>alert(1337)</script>'
53
53
  assert_select 'span.hint', "&lt;script&gt;alert(1337)&lt;/script&gt;"
54
54
  end
@@ -60,7 +60,7 @@ class HintTest < ActionView::TestCase
60
60
  assert_select 'span.hint', 'Hello World!'
61
61
  end
62
62
 
63
- test 'hint without attribute name should generate component tag with a clean HTML' do
63
+ test 'hint without attribute name generates component tag with a clean HTML' do
64
64
  with_hint_for @validating_user, 'Hello World!'
65
65
  assert_no_select 'span.hint[hint]'
66
66
  assert_no_select 'span.hint[hint_html]'
@@ -73,14 +73,14 @@ class HintTest < ActionView::TestCase
73
73
  assert_no_select 'p.hint[hint_tag]'
74
74
  end
75
75
 
76
- test 'hint without attribute name should be able to pass html options' do
76
+ test 'hint without attribute name is able to pass html options' do
77
77
  with_hint_for @user, 'Yay', id: 'hint', class: 'yay'
78
78
  assert_select 'span#hint.hint.yay', 'Yay'
79
79
  end
80
80
 
81
81
  # I18n
82
82
 
83
- test 'hint should use i18n based on model, action, and attribute to lookup translation' do
83
+ test 'hint uses i18n based on model, action, and attribute to lookup translation' do
84
84
  store_translations(:en, simple_form: { hints: { user: {
85
85
  edit: { name: 'Content of this input will be truncated...' }
86
86
  } } }) do
@@ -89,7 +89,7 @@ class HintTest < ActionView::TestCase
89
89
  end
90
90
  end
91
91
 
92
- test 'hint should use i18n with model and attribute to lookup translation' do
92
+ test 'hint uses i18n with model and attribute to lookup translation' do
93
93
  store_translations(:en, simple_form: { hints: { user: {
94
94
  name: 'Content of this input will be capitalized...'
95
95
  } } }) do
@@ -98,7 +98,7 @@ class HintTest < ActionView::TestCase
98
98
  end
99
99
  end
100
100
 
101
- test 'hint should use i18n under defaults namespace to lookup translation' do
101
+ test 'hint uses i18n under defaults namespace to lookup translation' do
102
102
  store_translations(:en, simple_form: {
103
103
  hints: { defaults: { name: 'Content of this input will be downcased...' } }
104
104
  }) do
@@ -107,7 +107,7 @@ class HintTest < ActionView::TestCase
107
107
  end
108
108
  end
109
109
 
110
- test 'hint should use i18n with lookup for association name' do
110
+ test 'hint uses i18n with lookup for association name' do
111
111
  store_translations(:en, simple_form: { hints: {
112
112
  user: { company: 'My company!' }
113
113
  } } ) do
@@ -116,7 +116,7 @@ class HintTest < ActionView::TestCase
116
116
  end
117
117
  end
118
118
 
119
- test 'hint should output translations as html_safe' do
119
+ test 'hint outputs translations as html_safe' do
120
120
  store_translations(:en, simple_form: { hints: { user: {
121
121
  edit: { name: '<b>This is bold</b> and this is not...' }
122
122
  } } }) do
@@ -128,7 +128,7 @@ class HintTest < ActionView::TestCase
128
128
 
129
129
  # No object
130
130
 
131
- test 'hint should generate properly when object is not present' do
131
+ test 'hint generates properly when object is not present' do
132
132
  with_hint_for :project, :name, hint: 'Test without object'
133
133
  assert_select 'span.hint', 'Test without object'
134
134
  end