reform 2.3.2 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +4 -0
  3. data/lib/reform/form/dry/new_api.rb +2 -4
  4. data/lib/reform/version.rb +1 -1
  5. data/test/call_new_api.rb +6 -6
  6. data/test/call_old_api.rb +6 -6
  7. data/test/changed_test.rb +6 -6
  8. data/test/coercion_test.rb +13 -13
  9. data/test/composition_new_api.rb +24 -24
  10. data/test/composition_old_api.rb +24 -24
  11. data/test/contract_new_api.rb +8 -8
  12. data/test/contract_old_api.rb +8 -8
  13. data/test/default_test.rb +2 -2
  14. data/test/deserialize_test.rb +8 -8
  15. data/test/errors_new_api.rb +38 -38
  16. data/test/errors_old_api.rb +38 -38
  17. data/test/feature_test.rb +2 -2
  18. data/test/form_new_api.rb +3 -3
  19. data/test/form_old_api.rb +3 -3
  20. data/test/form_option_new_api.rb +1 -1
  21. data/test/form_option_old_api.rb +1 -1
  22. data/test/from_test.rb +10 -10
  23. data/test/inherit_new_api.rb +17 -17
  24. data/test/inherit_old_api.rb +17 -17
  25. data/test/module_new_api.rb +8 -8
  26. data/test/module_old_api.rb +9 -9
  27. data/test/parse_option_test.rb +7 -7
  28. data/test/parse_pipeline_test.rb +1 -1
  29. data/test/populate_new_api.rb +53 -53
  30. data/test/populate_old_api.rb +53 -53
  31. data/test/populator_skip_test.rb +2 -2
  32. data/test/prepopulator_test.rb +15 -15
  33. data/test/read_only_test.rb +2 -2
  34. data/test/readable_test.rb +3 -3
  35. data/test/reform_new_api.rb +19 -19
  36. data/test/reform_old_api.rb +19 -19
  37. data/test/save_new_api.rb +4 -4
  38. data/test/save_old_api.rb +4 -4
  39. data/test/setup_test.rb +9 -9
  40. data/test/skip_if_new_api.rb +12 -12
  41. data/test/skip_if_old_api.rb +15 -15
  42. data/test/skip_setter_and_getter_test.rb +6 -6
  43. data/test/validate_new_api.rb +62 -62
  44. data/test/validate_old_api.rb +64 -64
  45. data/test/validation/dry_validation_new_api.rb +115 -116
  46. data/test/validation/dry_validation_old_api.rb +105 -105
  47. data/test/validation/result_test.rb +14 -14
  48. data/test/virtual_test.rb +7 -7
  49. data/test/writeable_test.rb +8 -8
  50. metadata +2 -2
@@ -53,60 +53,60 @@ class DryValidationErrorsAPITest < Minitest::Spec
53
53
  it "everything wrong" do
54
54
  result = form.(title: nil, artist: {email: ""}, songs: [{title: "Clams have feelings too"}, {title: ""}])
55
55
 
56
- result.success?.must_equal false
56
+ _(result.success?).must_equal false
57
57
 
58
58
  # errors.messages
59
- form.errors.messages.must_equal(title: ["must be filled", "size cannot be less than 2"], "artist.email": ["must be filled"], "artist.label.location": ["must be filled"], "songs.title": ["must be filled"])
60
- form.artist.errors.messages.must_equal(email: ["must be filled"], "label.location": ["must be filled"])
61
- form.artist.label.errors.messages.must_equal(location: ["must be filled"])
62
- form.songs[0].errors.messages.must_equal({})
63
- form.songs[1].errors.messages.must_equal(title: ["must be filled"])
59
+ _(form.errors.messages).must_equal(title: ["must be filled", "size cannot be less than 2"], "artist.email": ["must be filled"], "artist.label.location": ["must be filled"], "songs.title": ["must be filled"])
60
+ _(form.artist.errors.messages).must_equal(email: ["must be filled"], "label.location": ["must be filled"])
61
+ _(form.artist.label.errors.messages).must_equal(location: ["must be filled"])
62
+ _(form.songs[0].errors.messages).must_equal({})
63
+ _(form.songs[1].errors.messages).must_equal(title: ["must be filled"])
64
64
 
65
65
  # #errors[]
66
- form.errors[:nonsense].must_equal []
67
- form.errors[:title].must_equal ["must be filled", "size cannot be less than 2"]
68
- form.artist.errors[:email].must_equal ["must be filled"]
69
- form.artist.label.errors[:location].must_equal ["must be filled"]
70
- form.songs[0].errors[:title].must_equal []
71
- form.songs[1].errors[:title].must_equal ["must be filled"]
66
+ _(form.errors[:nonsense]).must_equal []
67
+ _(form.errors[:title]).must_equal ["must be filled", "size cannot be less than 2"]
68
+ _(form.artist.errors[:email]).must_equal ["must be filled"]
69
+ _(form.artist.label.errors[:location]).must_equal ["must be filled"]
70
+ _(form.songs[0].errors[:title]).must_equal []
71
+ _(form.songs[1].errors[:title]).must_equal ["must be filled"]
72
72
 
73
73
  # #to_result
74
- form.to_result.errors.must_equal(title: ["must be filled"])
75
- form.to_result.messages.must_equal(title: ["must be filled", "size cannot be less than 2"])
76
- form.to_result.hints.must_equal(title: ["size cannot be less than 2"])
77
- form.artist.to_result.errors.must_equal(email: ["must be filled"])
78
- form.artist.to_result.messages.must_equal(email: ["must be filled"])
79
- form.artist.to_result.hints.must_equal(email: [])
80
- form.artist.label.to_result.errors.must_equal(location: ["must be filled"])
81
- form.artist.label.to_result.messages.must_equal(location: ["must be filled"])
82
- form.artist.label.to_result.hints.must_equal(location: [])
83
- form.songs[0].to_result.errors.must_equal({})
84
- form.songs[0].to_result.messages.must_equal({})
85
- form.songs[0].to_result.hints.must_equal({})
86
- form.songs[1].to_result.errors.must_equal(title: ["must be filled"])
87
- form.songs[1].to_result.messages.must_equal(title: ["must be filled"])
88
- form.songs[1].to_result.hints.must_equal(title: [])
89
- form.songs[1].to_result.errors(locale: :de).must_equal(title: ["muss abgefüllt sein"])
90
- form.songs[1].to_result.messages(locale: :de).must_equal(title: ["muss abgefüllt sein"])
91
- form.songs[1].to_result.hints(locale: :de).must_equal(title: [])
74
+ _(form.to_result.errors).must_equal(title: ["must be filled"])
75
+ _(form.to_result.messages).must_equal(title: ["must be filled", "size cannot be less than 2"])
76
+ _(form.to_result.hints).must_equal(title: ["size cannot be less than 2"])
77
+ _(form.artist.to_result.errors).must_equal(email: ["must be filled"])
78
+ _(form.artist.to_result.messages).must_equal(email: ["must be filled"])
79
+ _(form.artist.to_result.hints).must_equal(email: [])
80
+ _(form.artist.label.to_result.errors).must_equal(location: ["must be filled"])
81
+ _(form.artist.label.to_result.messages).must_equal(location: ["must be filled"])
82
+ _(form.artist.label.to_result.hints).must_equal(location: [])
83
+ _(form.songs[0].to_result.errors).must_equal({})
84
+ _(form.songs[0].to_result.messages).must_equal({})
85
+ _(form.songs[0].to_result.hints).must_equal({})
86
+ _(form.songs[1].to_result.errors).must_equal(title: ["must be filled"])
87
+ _(form.songs[1].to_result.messages).must_equal(title: ["must be filled"])
88
+ _(form.songs[1].to_result.hints).must_equal(title: [])
89
+ _(form.songs[1].to_result.errors(locale: :de)).must_equal(title: ["muss abgefüllt sein"])
90
+ _(form.songs[1].to_result.messages(locale: :de)).must_equal(title: ["muss abgefüllt sein"])
91
+ _(form.songs[1].to_result.hints(locale: :de)).must_equal(title: [])
92
92
  end
93
93
 
94
94
  it "only nested property is invalid." do
95
95
  result = form.(title: "Black Star", artist: {email: ""})
96
96
 
97
- result.success?.must_equal false
97
+ _(result.success?).must_equal false
98
98
 
99
99
  # errors.messages
100
- form.errors.messages.must_equal("artist.email": ["must be filled"], "artist.label.location": ["must be filled"], "songs.title": ["must be filled"])
101
- form.artist.errors.messages.must_equal(email: ["must be filled"], "label.location": ["must be filled"])
102
- form.artist.label.errors.messages.must_equal(location: ["must be filled"])
100
+ _(form.errors.messages).must_equal("artist.email": ["must be filled"], "artist.label.location": ["must be filled"], "songs.title": ["must be filled"])
101
+ _(form.artist.errors.messages).must_equal(email: ["must be filled"], "label.location": ["must be filled"])
102
+ _(form.artist.label.errors.messages).must_equal(location: ["must be filled"])
103
103
  end
104
104
 
105
105
  it "nested collection invalid" do
106
106
  result = form.(title: "Black Star", artist: {email: "uhm", label: {location: "Hannover"}}, songs: [{title: ""}])
107
107
 
108
- result.success?.must_equal false
109
- form.errors.messages.must_equal("songs.title": ["must be filled"])
108
+ _(result.success?).must_equal false
109
+ _(form.errors.messages).must_equal("songs.title": ["must be filled"])
110
110
  end
111
111
 
112
112
  #---
@@ -129,9 +129,9 @@ class DryValidationErrorsAPITest < Minitest::Spec
129
129
  form = CollectionExternalValidationsForm.new(Album.new(nil, nil, [Song.new, Song.new]))
130
130
  form.validate(songs: [{title: "Liar"}, {title: ""}])
131
131
 
132
- form.errors.messages.must_equal("songs.title": ["must be filled"])
133
- form.songs[0].errors.messages.must_equal({})
134
- form.songs[1].errors.messages.must_equal(title: ["must be filled"])
132
+ _(form.errors.messages).must_equal("songs.title": ["must be filled"])
133
+ _(form.songs[0].errors.messages).must_equal({})
134
+ _(form.songs[1].errors.messages).must_equal(title: ["must be filled"])
135
135
  end
136
136
  end
137
137
 
@@ -155,13 +155,13 @@ class DryValidationExplicitSchemaTest < Minitest::Spec
155
155
 
156
156
  # valid.
157
157
  it do
158
- form.validate(name: "Helloween", email: "yep").must_equal true
159
- form.errors.messages.inspect.must_equal "{}"
158
+ _(form.validate(name: "Helloween", email: "yep")).must_equal true
159
+ _(form.errors.messages.inspect).must_equal "{}"
160
160
  end
161
161
 
162
162
  it "invalid" do
163
- form.validate(name: "", email: "yep").must_equal false
164
- form.errors.messages.inspect.must_equal "{:name=>[\"must be filled\"]}"
163
+ _(form.validate(name: "", email: "yep")).must_equal false
164
+ _(form.errors.messages.inspect).must_equal "{:name=>[\"must be filled\"]}"
165
165
  end
166
166
  end
167
167
 
@@ -208,21 +208,21 @@ class DryValidationDefaultGroupTest < Minitest::Spec
208
208
 
209
209
  # valid.
210
210
  it do
211
- form.validate(username: "Helloween",
211
+ _(form.validate(username: "Helloween",
212
212
  email: "yep",
213
213
  starts_at: "01/01/2000 - 11:00",
214
214
  active: "true",
215
- confirm_password: "pA55w0rd").must_equal true
216
- form.errors.messages.inspect.must_equal "{}"
215
+ confirm_password: "pA55w0rd")).must_equal true
216
+ _(form.errors.messages.inspect).must_equal "{}"
217
217
  end
218
218
 
219
219
  it "invalid" do
220
- form.validate(username: "Helloween",
220
+ _(form.validate(username: "Helloween",
221
221
  email: "yep",
222
222
  active: "hello",
223
223
  starts_at: "01/01/2000 - 11:00",
224
- color: "purple").must_equal false
225
- form.errors.messages.inspect.must_equal "{:active=>[\"must be boolean\"], :confirm_password=>[\"must be filled\"], :color=>[\"must be one of: red orange green\"]}"
224
+ color: "purple")).must_equal false
225
+ _(form.errors.messages.inspect).must_equal "{:active=>[\"must be boolean\"], :confirm_password=>[\"must be filled\"], :color=>[\"must be one of: red orange green\"]}"
226
226
  end
227
227
  end
228
228
 
@@ -261,36 +261,36 @@ class ValidationGroupsTest < MiniTest::Spec
261
261
 
262
262
  # valid.
263
263
  it do
264
- form.validate(username: "Helloween",
264
+ _(form.validate(username: "Helloween",
265
265
  special_class: SomeClass.new(id: 15),
266
266
  email: "yep",
267
267
  password: "99",
268
- confirm_password: "99").must_equal true
269
- form.errors.messages.inspect.must_equal "{}"
268
+ confirm_password: "99")).must_equal true
269
+ _(form.errors.messages.inspect).must_equal "{}"
270
270
  end
271
271
 
272
272
  # invalid.
273
273
  it do
274
- form.validate({}).must_equal false
275
- form.errors.messages.must_equal({username: ["must be filled"], email: ["must be filled"], special_class: ["must be filled", "must be ValidationGroupsTest::SomeClass"]})
274
+ _(form.validate({})).must_equal false
275
+ _(form.errors.messages).must_equal({username: ["must be filled"], email: ["must be filled"], special_class: ["must be filled", "must be ValidationGroupsTest::SomeClass"]})
276
276
  end
277
277
 
278
278
  # partially invalid.
279
279
  # 2nd group fails.
280
280
  it do
281
- form.validate(username: "Helloween", email: "yo", confirm_password: "9", special_class: SomeClass.new(id: 15)).must_equal false
282
- form.errors.messages.inspect.must_equal "{:email=>[\"size cannot be less than 3\"], :confirm_password=>[\"size cannot be less than 2\"]}"
281
+ _(form.validate(username: "Helloween", email: "yo", confirm_password: "9", special_class: SomeClass.new(id: 15))).must_equal false
282
+ _(form.errors.messages.inspect).must_equal "{:email=>[\"size cannot be less than 3\"], :confirm_password=>[\"size cannot be less than 2\"]}"
283
283
  end
284
284
  # 3rd group fails.
285
285
  it do
286
- form.validate(username: "Helloween", email: "yo!", confirm_password: "9", special_class: SomeClass.new(id: 15)).must_equal false
287
- form.errors.messages.inspect
286
+ _(form.validate(username: "Helloween", email: "yo!", confirm_password: "9", special_class: SomeClass.new(id: 15))).must_equal false
287
+ _(form.errors.messages.inspect)
288
288
  .must_equal "{:confirm_password=>[\"size cannot be less than 2\"], :password=>[\"must be filled\", \"size cannot be less than 2\"]}"
289
289
  end
290
290
  # 4th group with after: fails.
291
291
  it do
292
- form.validate(username: "Helloween", email: "yo!", password: "1", confirm_password: "9", special_class: SomeClass.new(id: 15)).must_equal false
293
- form.errors.messages.inspect.must_equal "{:confirm_password=>[\"size cannot be less than 2\"], :password=>[\"size cannot be less than 2\"]}"
292
+ _(form.validate(username: "Helloween", email: "yo!", password: "1", confirm_password: "9", special_class: SomeClass.new(id: 15))).must_equal false
293
+ _(form.errors.messages.inspect).must_equal "{:confirm_password=>[\"size cannot be less than 2\"], :password=>[\"size cannot be less than 2\"]}"
294
294
  end
295
295
  end
296
296
 
@@ -314,14 +314,14 @@ class ValidationGroupsTest < MiniTest::Spec
314
314
 
315
315
  # valid.
316
316
  it do
317
- form.validate(username: "Nick").must_equal true
318
- form.errors.messages.inspect.must_equal "{}"
317
+ _(form.validate(username: "Nick")).must_equal true
318
+ _(form.errors.messages.inspect).must_equal "{}"
319
319
  end
320
320
 
321
321
  # invalid.
322
322
  it do
323
- form.validate(username: "Fred").must_equal false
324
- form.errors.messages.inspect.must_equal "{:username=>[\"must be equal to Nick\"]}"
323
+ _(form.validate(username: "Fred")).must_equal false
324
+ _(form.errors.messages.inspect).must_equal "{:username=>[\"must be equal to Nick\"]}"
325
325
  end
326
326
  end
327
327
  end
@@ -358,19 +358,19 @@ class ValidationGroupsTest < MiniTest::Spec
358
358
 
359
359
  # valid.
360
360
  it do
361
- form.validate(username: "Helloween", email: "yep", password: "extrasafe").must_equal true
362
- form.errors.messages.inspect.must_equal "{}"
361
+ _(form.validate(username: "Helloween", email: "yep", password: "extrasafe")).must_equal true
362
+ _(form.errors.messages.inspect).must_equal "{}"
363
363
  end
364
364
 
365
365
  # invalid.
366
366
  it do
367
- form.validate({}).must_equal false
368
- form.errors.messages.must_equal(password: ["must be filled", "size cannot be less than 6"], username: ["must be filled"], email: ["must be filled", "you're a bad person"])
367
+ _(form.validate({})).must_equal false
368
+ _(form.errors.messages).must_equal(password: ["must be filled", "size cannot be less than 6"], username: ["must be filled"], email: ["must be filled", "you're a bad person"])
369
369
  end
370
370
 
371
371
  it do
372
- form.validate(email: 1).must_equal false
373
- form.errors.messages.inspect.must_equal "{:password=>[\"must be filled\", \"size cannot be less than 6\"], :username=>[\"must be filled\"], :email=>[\"you're a bad person\"]}"
372
+ _(form.validate(email: 1)).must_equal false
373
+ _(form.errors.messages.inspect).must_equal "{:password=>[\"must be filled\", \"size cannot be less than 6\"], :username=>[\"must be filled\"], :email=>[\"you're a bad person\"]}"
374
374
  end
375
375
  end
376
376
 
@@ -452,23 +452,23 @@ class ValidationGroupsTest < MiniTest::Spec
452
452
  "producers" => [{"name" => ""}, {"name" => "something lovely"}]
453
453
  )
454
454
 
455
- result.must_equal false
455
+ _(result).must_equal false
456
456
  # from nested validation
457
- form.errors.messages.must_equal(title: ["you're a bad person"], "hit.title": ["must be filled"], "songs.title": ["must be filled"], "producers.name": ["must be filled"], "band.name": ["must be filled"], "band.label.location": ["must be filled"])
457
+ _(form.errors.messages).must_equal(title: ["you're a bad person"], "hit.title": ["must be filled"], "songs.title": ["must be filled"], "producers.name": ["must be filled"], "band.name": ["must be filled"], "band.label.location": ["must be filled"])
458
458
 
459
459
  # songs have their own validation.
460
- form.songs[0].errors.messages.must_equal(title: ["must be filled"])
460
+ _(form.songs[0].errors.messages).must_equal(title: ["must be filled"])
461
461
  # hit got its own validation group.
462
- form.hit.errors.messages.must_equal(title: ["must be filled"])
462
+ _(form.hit.errors.messages).must_equal(title: ["must be filled"])
463
463
 
464
- form.band.label.errors.messages.must_equal(location: ["must be filled"])
465
- form.band.errors.messages.must_equal(name: ["must be filled"], "label.location": ["must be filled"])
466
- form.producers[0].errors.messages.must_equal(name: ["must be filled"])
464
+ _(form.band.label.errors.messages).must_equal(location: ["must be filled"])
465
+ _(form.band.errors.messages).must_equal(name: ["must be filled"], "label.location": ["must be filled"])
466
+ _(form.producers[0].errors.messages).must_equal(name: ["must be filled"])
467
467
 
468
468
  # TODO: use the same form structure as the top one and do the same test against messages, errors and hints.
469
- form.producers[0].to_result.errors.must_equal(name: ["must be filled"])
470
- form.producers[0].to_result.messages.must_equal(name: ["must be filled"])
471
- form.producers[0].to_result.hints.must_equal(name: [])
469
+ _(form.producers[0].to_result.errors).must_equal(name: ["must be filled"])
470
+ _(form.producers[0].to_result.messages).must_equal(name: ["must be filled"])
471
+ _(form.producers[0].to_result.hints).must_equal(name: [])
472
472
  end
473
473
 
474
474
  # FIXME: fix the "must be filled error"
@@ -481,11 +481,11 @@ class ValidationGroupsTest < MiniTest::Spec
481
481
  "producers" => [{"name" => ""}, {"name" => ""}, {"name" => "something lovely"}]
482
482
  )
483
483
 
484
- result.must_equal false
485
- form.band.errors.full_messages.must_equal ["Name must be filled", "Label Location must be filled"]
486
- form.band.label.errors.full_messages.must_equal ["Location must be filled"]
487
- form.producers.first.errors.full_messages.must_equal ["Name must be filled"]
488
- form.errors.full_messages.must_equal ["Title must be filled", "Title you're a bad person", "Hit Title must be filled", "Songs Title must be filled", "Producers Name must be filled", "Band Name must be filled", "Band Label Location must be filled"]
484
+ _(result).must_equal false
485
+ _(form.band.errors.full_messages).must_equal ["Name must be filled", "Label Location must be filled"]
486
+ _(form.band.label.errors.full_messages).must_equal ["Location must be filled"]
487
+ _(form.producers.first.errors.full_messages).must_equal ["Name must be filled"]
488
+ _(form.errors.full_messages).must_equal ["Title must be filled", "Title you're a bad person", "Hit Title must be filled", "Songs Title must be filled", "Producers Name must be filled", "Band Name must be filled", "Band Label Location must be filled"]
489
489
  end
490
490
 
491
491
  describe "only 1 nested validation" do
@@ -524,14 +524,14 @@ class ValidationGroupsTest < MiniTest::Spec
524
524
  "producers" => [{"name" => ""}, {"name" => ""}, {"name" => "something lovely"}]
525
525
  )
526
526
 
527
- form.to_result.errors.must_equal(title: ["must be filled"])
528
- form.band.to_result.errors.must_equal(name: ["must be filled"])
529
- form.band.label.to_result.errors.must_equal(location: ["must be filled"])
527
+ _(form.to_result.errors).must_equal(title: ["must be filled"])
528
+ _(form.band.to_result.errors).must_equal(name: ["must be filled"])
529
+ _(form.band.label.to_result.errors).must_equal(location: ["must be filled"])
530
530
 
531
531
  # with locale: "de"
532
- form.to_result.errors(locale: :de).must_equal(title: ["muss abgefüllt sein"])
533
- form.band.to_result.errors(locale: :de).must_equal(name: ["muss abgefüllt sein"])
534
- form.band.label.to_result.errors(locale: :de).must_equal(location: ["muss abgefüllt sein"])
532
+ _(form.to_result.errors(locale: :de)).must_equal(title: ["muss abgefüllt sein"])
533
+ _(form.band.to_result.errors(locale: :de)).must_equal(name: ["muss abgefüllt sein"])
534
+ _(form.band.label.to_result.errors(locale: :de)).must_equal(location: ["muss abgefüllt sein"])
535
535
  end
536
536
  end
537
537
  end
@@ -591,13 +591,13 @@ class ValidationGroupsTest < MiniTest::Spec
591
591
 
592
592
  # valid.
593
593
  it do
594
- form.validate(full_name: "My name", email: 9).must_equal true
594
+ _(form.validate(full_name: "My name", email: 9)).must_equal true
595
595
  end
596
596
 
597
597
  # invalid.
598
598
  it do
599
- form.validate({}).must_equal false
600
- form.errors.messages.must_equal email: ["must be filled"], full_name: ["must be filled"]
599
+ _(form.validate({})).must_equal false
600
+ _(form.errors.messages).must_equal email: ["must be filled"], full_name: ["must be filled"]
601
601
  end
602
602
  end
603
603
 
@@ -626,13 +626,13 @@ class ValidationGroupsTest < MiniTest::Spec
626
626
 
627
627
  # valid.
628
628
  it do
629
- form.validate(username: "Strung Out", email: 9).must_equal true
629
+ _(form.validate(username: "Strung Out", email: 9)).must_equal true
630
630
  end
631
631
 
632
632
  # invalid.
633
633
  it do
634
- form.validate(email: 9).must_equal false
635
- form.errors.messages.inspect.must_equal "{:username=>[\"must be filled\"]}"
634
+ _(form.validate(email: 9)).must_equal false
635
+ _(form.errors.messages.inspect).must_equal "{:username=>[\"must be filled\"]}"
636
636
  end
637
637
  end
638
638
 
@@ -656,8 +656,8 @@ class ValidationGroupsTest < MiniTest::Spec
656
656
  let(:form) { OrderForm.new(order.new(company.new)) }
657
657
 
658
658
  it "has company error" do
659
- form.validate(delivery_address: {company: "not int"}).must_equal false
660
- form.errors.messages.must_equal(:"delivery_address.company" => ["must be an integer"])
659
+ _(form.validate(delivery_address: {company: "not int"})).must_equal false
660
+ _(form.errors.messages).must_equal(:"delivery_address.company" => ["must be an integer"])
661
661
  end
662
662
  end
663
663
 
@@ -679,8 +679,8 @@ class ValidationGroupsTest < MiniTest::Spec
679
679
  let(:form) { OrderFormWithForm.new(order.new(company.new)) }
680
680
 
681
681
  it "has company error" do
682
- form.validate(delivery_address: {company: "not int"}).must_equal false
683
- form.errors.messages.must_equal(:"delivery_address.company" => ["must be an integer"])
682
+ _(form.validate(delivery_address: {company: "not int"})).must_equal false
683
+ _(form.errors.messages).must_equal(:"delivery_address.company" => ["must be an integer"])
684
684
  end
685
685
  end
686
686
 
@@ -726,17 +726,17 @@ class ValidationGroupsTest < MiniTest::Spec
726
726
 
727
727
  it "validates fails and shows the correct errors" do
728
728
  form = AlbumForm.new(Album.new(nil, [], nil))
729
- form.validate(
729
+ _(form.validate(
730
730
  "songs" => [
731
731
  {"title" => "One", "enabled" => false},
732
732
  {"title" => nil, "enabled" => false},
733
733
  {"title" => "Three", "enabled" => false}
734
734
  ],
735
735
  "artist" => {"last_name" => nil}
736
- ).must_equal false
737
- form.songs.size.must_equal 3
736
+ )).must_equal false
737
+ _(form.songs.size).must_equal 3
738
738
 
739
- form.errors.messages.must_equal(
739
+ _(form.errors.messages).must_equal(
740
740
  :songs => ["must have at least one enabled song"],
741
741
  :artist => ["must have last name"],
742
742
  :"songs.title" => ["must be filled"]
@@ -11,10 +11,10 @@ class ErrorsResultTest < Minitest::Spec
11
11
  let(:failed) { MyResult.new(false) }
12
12
  let(:succeeded) { MyResult.new(true) }
13
13
 
14
- it { Reform::Contract::Result.new([failed, failed]).success?.must_equal false }
15
- it { Reform::Contract::Result.new([succeeded, failed]).success?.must_equal false }
16
- it { Reform::Contract::Result.new([failed, succeeded]).success?.must_equal false }
17
- it { Reform::Contract::Result.new([succeeded, succeeded]).success?.must_equal true }
14
+ it { _(Reform::Contract::Result.new([failed, failed]).success?).must_equal false }
15
+ it { _(Reform::Contract::Result.new([succeeded, failed]).success?).must_equal false }
16
+ it { _(Reform::Contract::Result.new([failed, succeeded]).success?).must_equal false }
17
+ it { _(Reform::Contract::Result.new([succeeded, succeeded]).success?).must_equal true }
18
18
  end
19
19
 
20
20
  describe "Contract::Result#errors" do
@@ -27,7 +27,7 @@ class ErrorsResultTest < Minitest::Spec
27
27
  ]
28
28
  end
29
29
 
30
- it { Reform::Contract::Result.new(results).errors.must_equal({title: ["must be filled", "something more"], length: ["no Int"]}) }
30
+ it { _(Reform::Contract::Result.new(results).errors).must_equal({title: ["must be filled", "something more"], length: ["no Int"]}) }
31
31
  end
32
32
 
33
33
  describe "Result::Pointer" do
@@ -44,24 +44,24 @@ class ErrorsResultTest < Minitest::Spec
44
44
  end
45
45
 
46
46
  let(:top) { Reform::Contract::Result::Pointer.new(MyResult.new(false, errors), []) }
47
- it { top.success?.must_equal false }
48
- it { top.errors.must_equal errors }
47
+ it { _(top.success?).must_equal false }
48
+ it { _(top.errors).must_equal errors }
49
49
 
50
50
  let(:artist) { Reform::Contract::Result::Pointer.new(MyResult.new(false, errors), [:artist]) }
51
- it { artist.success?.must_equal false }
52
- it { artist.errors.must_equal({age: ["too old"], bands: {0 => {name: "too new school"}, 1 => {name: "too boring"}}}) }
51
+ it { _(artist.success?).must_equal false }
52
+ it { _(artist.errors).must_equal({age: ["too old"], bands: {0 => {name: "too new school"}, 1 => {name: "too boring"}}}) }
53
53
 
54
54
  let(:band) { Reform::Contract::Result::Pointer.new(MyResult.new(false, errors), [:artist, :bands, 1]) }
55
- it { band.success?.must_equal false }
56
- it { band.errors.must_equal({name: "too boring"}) }
55
+ it { _(band.success?).must_equal false }
56
+ it { _(band.errors).must_equal({name: "too boring"}) }
57
57
 
58
58
  describe "advance" do
59
59
  let(:advanced) { artist.advance(:bands, 1) }
60
60
 
61
- it { advanced.success?.must_equal false }
62
- it { advanced.errors.must_equal({name: "too boring"}) }
61
+ it { _(advanced.success?).must_equal false }
62
+ it { _(advanced.errors).must_equal({name: "too boring"}) }
63
63
 
64
- it { artist.advance(%i[absolute nonsense]).must_be_nil }
64
+ it { _(artist.advance(%i[absolute nonsense])).must_be_nil }
65
65
  end
66
66
  end
67
67
  end
@@ -13,8 +13,8 @@ class VirtualTest < MiniTest::Spec
13
13
  it {
14
14
  form.validate(credit_card_number: "123", transactions: [id: 1])
15
15
 
16
- form.credit_card_number.must_equal "123" # this is still readable in the UI.
17
- form.transactions.first.id.must_equal 1 # this is still readable in the UI.
16
+ _(form.credit_card_number).must_equal "123" # this is still readable in the UI.
17
+ _(form.transactions.first.id).must_equal 1 # this is still readable in the UI.
18
18
 
19
19
  form.sync
20
20
 
@@ -23,7 +23,7 @@ class VirtualTest < MiniTest::Spec
23
23
  hash = nested
24
24
  end
25
25
 
26
- hash.must_equal("credit_card_number" => "123", "transactions" => ["id" => 1])
26
+ _(hash).must_equal("credit_card_number" => "123", "transactions" => ["id" => 1])
27
27
  }
28
28
  end
29
29
 
@@ -49,16 +49,16 @@ class VirtualAndDefaultTest < MiniTest::Spec
49
49
  form = CreditCardForm.new(Object.new)
50
50
  form.validate({})
51
51
 
52
- hash(form).must_equal("credit_card_number" => "123", "transactions" => ["id" => 2])
52
+ _(hash(form)).must_equal("credit_card_number" => "123", "transactions" => ["id" => 2])
53
53
 
54
54
  form = CreditCardForm.new(Object.new)
55
55
  form.validate(credit_card_number: "123", transactions: [id: 1])
56
56
 
57
- form.credit_card_number.must_equal "123" # this is still readable in the UI.
58
- form.transactions.first.id.must_equal 1 # this is still readable in the UI.
57
+ _(form.credit_card_number).must_equal "123" # this is still readable in the UI.
58
+ _(form.transactions.first.id).must_equal 1 # this is still readable in the UI.
59
59
 
60
60
  form.sync
61
61
 
62
- hash(form).must_equal("credit_card_number" => "123", "transactions" => ["id" => 1])
62
+ _(hash(form)).must_equal("credit_card_number" => "123", "transactions" => ["id" => 1])
63
63
  }
64
64
  end