reform 2.3.3 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +0 -3
  4. data/CHANGES.md +9 -0
  5. data/Gemfile +1 -1
  6. data/LICENSE.txt +1 -1
  7. data/README.md +5 -5
  8. data/Rakefile +1 -12
  9. data/lib/reform/contract/validate.rb +1 -1
  10. data/lib/reform/form/dry.rb +47 -9
  11. data/lib/reform/validation/groups.rb +0 -1
  12. data/lib/reform/version.rb +1 -1
  13. data/test/call_test.rb +23 -0
  14. data/test/changed_test.rb +6 -6
  15. data/test/coercion_test.rb +17 -17
  16. data/test/{composition_new_api.rb → composition_test.rb} +27 -28
  17. data/test/{contract_new_api.rb → contract_test.rb} +8 -8
  18. data/test/default_test.rb +2 -2
  19. data/test/deserialize_test.rb +8 -8
  20. data/test/docs/validation_test.rb +134 -0
  21. data/test/{errors_new_api.rb → errors_test.rb} +41 -41
  22. data/test/feature_test.rb +2 -2
  23. data/test/fixtures/dry_error_messages.yml +64 -54
  24. data/test/{form_option_new_api.rb → form_option_test.rb} +1 -1
  25. data/test/{form_new_api.rb → form_test.rb} +3 -3
  26. data/test/from_test.rb +10 -10
  27. data/test/{inherit_new_api.rb → inherit_test.rb} +17 -17
  28. data/test/{module_new_api.rb → module_test.rb} +10 -10
  29. data/test/parse_option_test.rb +7 -7
  30. data/test/parse_pipeline_test.rb +1 -1
  31. data/test/{populate_new_api.rb → populate_test.rb} +112 -53
  32. data/test/populator_skip_test.rb +2 -2
  33. data/test/prepopulator_test.rb +15 -15
  34. data/test/read_only_test.rb +2 -2
  35. data/test/readable_test.rb +3 -3
  36. data/test/{reform_new_api.rb → reform_test.rb} +19 -19
  37. data/test/{save_new_api.rb → save_test.rb} +4 -4
  38. data/test/setup_test.rb +9 -9
  39. data/test/{skip_if_new_api.rb → skip_if_test.rb} +12 -12
  40. data/test/skip_setter_and_getter_test.rb +6 -6
  41. data/test/test_helper.rb +5 -6
  42. data/test/{validate_new_api.rb → validate_test.rb} +65 -78
  43. data/test/validation/{dry_validation_new_api.rb → dry_validation_test.rb} +124 -123
  44. data/test/validation/result_test.rb +14 -14
  45. data/test/virtual_test.rb +7 -7
  46. data/test/writeable_test.rb +8 -8
  47. metadata +35 -68
  48. data/Appraisals +0 -8
  49. data/gemfiles/0.13.0.gemfile +0 -8
  50. data/gemfiles/1.5.0.gemfile +0 -9
  51. data/lib/reform/form/dry/new_api.rb +0 -45
  52. data/lib/reform/form/dry/old_api.rb +0 -61
  53. data/test/call_new_api.rb +0 -23
  54. data/test/call_old_api.rb +0 -23
  55. data/test/composition_old_api.rb +0 -184
  56. data/test/contract_old_api.rb +0 -77
  57. data/test/errors_old_api.rb +0 -230
  58. data/test/fixtures/dry_new_api_error_messages.yml +0 -104
  59. data/test/form_old_api.rb +0 -57
  60. data/test/form_option_old_api.rb +0 -24
  61. data/test/inherit_old_api.rb +0 -105
  62. data/test/module_old_api.rb +0 -146
  63. data/test/populate_old_api.rb +0 -304
  64. data/test/reform_old_api.rb +0 -202
  65. data/test/save_old_api.rb +0 -101
  66. data/test/skip_if_old_api.rb +0 -92
  67. data/test/validate_old_api.rb +0 -410
  68. data/test/validation/dry_validation_old_api.rb +0 -772
@@ -39,7 +39,7 @@ class DryValidationErrorsAPITest < Minitest::Spec
39
39
  property :title
40
40
 
41
41
  validation do
42
- config.messages.load_paths << "test/fixtures/dry_new_api_error_messages.yml"
42
+ config.messages.load_paths << "test/fixtures/dry_error_messages.yml"
43
43
 
44
44
  params { required(:title).filled }
45
45
  end
@@ -51,61 +51,61 @@ class DryValidationErrorsAPITest < Minitest::Spec
51
51
  it "everything wrong" do
52
52
  result = form.(title: nil, artist: {email: ""}, songs: [{title: "Clams have feelings too"}, {title: ""}])
53
53
 
54
- _(result.success?).must_equal false
54
+ assert_equal result.success?, false
55
55
 
56
- _(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"])
57
- _(form.artist.errors.messages).must_equal(email: ["must be filled"], "label.location": ["must be filled"])
58
- _(form.artist.label.errors.messages).must_equal(location: ["must be filled"])
59
- _(form.songs[0].errors.messages).must_equal({})
60
- _(form.songs[1].errors.messages).must_equal(title: ["must be filled"])
56
+ assert_equal form.errors.messages, 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"]
57
+ assert_equal form.artist.errors.messages, email: ["must be filled"], "label.location": ["must be filled"]
58
+ assert_equal form.artist.label.errors.messages, location: ["must be filled"]
59
+ assert_equal form.songs[0].errors.messages, {}
60
+ assert_equal form.songs[1].errors.messages, title: ["must be filled"]
61
61
 
62
62
  # #errors[]
63
- _(form.errors[:nonsense]).must_equal []
64
- _(form.errors[:title]).must_equal ["must be filled", "size cannot be less than 2"]
65
- _(form.artist.errors[:email]).must_equal ["must be filled"]
66
- _(form.artist.label.errors[:location]).must_equal ["must be filled"]
67
- _(form.songs[0].errors[:title]).must_equal []
68
- _(form.songs[1].errors[:title]).must_equal ["must be filled"]
63
+ assert_equal form.errors[:nonsense], []
64
+ assert_equal form.errors[:title], ["must be filled", "size cannot be less than 2"]
65
+ assert_equal form.artist.errors[:email], ["must be filled"]
66
+ assert_equal form.artist.label.errors[:location], ["must be filled"]
67
+ assert_equal form.songs[0].errors[:title], []
68
+ assert_equal form.songs[1].errors[:title], ["must be filled"]
69
69
 
70
70
  # #to_result
71
- _(form.to_result.errors).must_equal(title: ["must be filled"])
72
- _(form.to_result.messages).must_equal(title: ["must be filled", "size cannot be less than 2"])
73
- _(form.to_result.hints).must_equal(title: ["size cannot be less than 2"])
74
- _(form.artist.to_result.errors).must_equal(email: ["must be filled"])
75
- _(form.artist.to_result.messages).must_equal(email: ["must be filled"])
76
- _(form.artist.to_result.hints).must_equal({})
77
- _(form.artist.label.to_result.errors).must_equal(location: ["must be filled"])
78
- _(form.artist.label.to_result.messages).must_equal(location: ["must be filled"])
79
- _(form.artist.label.to_result.hints).must_equal({})
80
- _(form.songs[0].to_result.errors).must_equal({})
81
- _(form.songs[0].to_result.messages).must_equal({})
82
- _(form.songs[0].to_result.hints).must_equal({})
83
- _(form.songs[1].to_result.errors).must_equal(title: ["must be filled"])
84
- _(form.songs[1].to_result.messages).must_equal(title: ["must be filled"])
85
- _(form.songs[1].to_result.hints).must_equal({})
86
- _(form.songs[1].to_result.errors(locale: :de)).must_equal(title: ["muss abgefüllt sein"])
71
+ assert_equal form.to_result.errors, title: ["must be filled"]
72
+ assert_equal form.to_result.messages, title: ["must be filled", "size cannot be less than 2"]
73
+ assert_equal form.to_result.hints, title: ["size cannot be less than 2"]
74
+ assert_equal form.artist.to_result.errors, email: ["must be filled"]
75
+ assert_equal form.artist.to_result.messages, email: ["must be filled"]
76
+ assert_equal form.artist.to_result.hints, {}
77
+ assert_equal form.artist.label.to_result.errors, location: ["must be filled"]
78
+ assert_equal form.artist.label.to_result.messages, location: ["must be filled"]
79
+ assert_equal form.artist.label.to_result.hints, {}
80
+ assert_equal form.songs[0].to_result.errors, {}
81
+ assert_equal form.songs[0].to_result.messages, {}
82
+ assert_equal form.songs[0].to_result.hints, {}
83
+ assert_equal form.songs[1].to_result.errors, title: ["must be filled"]
84
+ assert_equal form.songs[1].to_result.messages, title: ["must be filled"]
85
+ assert_equal form.songs[1].to_result.hints, {}
86
+ assert_equal form.songs[1].to_result.errors(locale: :de), title: ["muss abgefüllt sein"]
87
87
  # seems like dry-v when calling Dry::Schema::Result#messages locale option is ignored
88
88
  # started a topic in their forum https://discourse.dry-rb.org/t/dry-result-messages-ignore-locale-option/910
89
- # form.songs[1].to_result.messages(locale: :de).must_equal(title: ["muss abgefüllt sein"])
90
- _(form.songs[1].to_result.hints(locale: :de)).must_equal({})
89
+ # assert_equal form.songs[1].to_result.messages(locale: :de), (title: ["muss abgefüllt sein"])
90
+ assert_equal form.songs[1].to_result.hints(locale: :de), ({})
91
91
  end
92
92
 
93
93
  it "only nested property is invalid." do
94
94
  result = form.(title: "Black Star", artist: {email: ""})
95
95
 
96
- _(result.success?).must_equal false
96
+ assert_equal result.success?, false
97
97
 
98
98
  # errors.messages
99
- _(form.errors.messages).must_equal("artist.email": ["must be filled"], "artist.label.location": ["must be filled"], "songs.title": ["must be filled"])
100
- _(form.artist.errors.messages).must_equal(email: ["must be filled"], "label.location": ["must be filled"])
101
- _(form.artist.label.errors.messages).must_equal(location: ["must be filled"])
99
+ assert_equal form.errors.messages, "artist.email": ["must be filled"], "artist.label.location": ["must be filled"], "songs.title": ["must be filled"]
100
+ assert_equal form.artist.errors.messages, email: ["must be filled"], "label.location": ["must be filled"]
101
+ assert_equal form.artist.label.errors.messages, location: ["must be filled"]
102
102
  end
103
103
 
104
104
  it "nested collection invalid" do
105
105
  result = form.(title: "Black Star", artist: {email: "uhm", label: {location: "Hannover"}}, songs: [{title: ""}])
106
106
 
107
- _(result.success?).must_equal false
108
- _(form.errors.messages).must_equal("songs.title": ["must be filled"])
107
+ assert_equal result.success?, false
108
+ assert_equal form.errors.messages, "songs.title": ["must be filled"]
109
109
  end
110
110
 
111
111
  #---
@@ -130,9 +130,9 @@ class DryValidationErrorsAPITest < Minitest::Spec
130
130
  form = CollectionExternalValidationsForm.new(Album.new(nil, nil, [Song.new, Song.new]))
131
131
  form.validate(songs: [{title: "Liar"}, {title: ""}])
132
132
 
133
- _(form.errors.messages).must_equal("songs.title": ["must be filled"])
134
- _(form.songs[0].errors.messages).must_equal({})
135
- _(form.songs[1].errors.messages).must_equal(title: ["must be filled"])
133
+ assert_equal form.errors.messages, "songs.title": ["must be filled"]
134
+ assert_equal form.songs[0].errors.messages, {}
135
+ assert_equal form.songs[1].errors.messages, title: ["must be filled"]
136
136
  end
137
137
  end
138
138
 
@@ -158,13 +158,13 @@ class DryValidationExplicitSchemaTest < Minitest::Spec
158
158
 
159
159
  # valid.
160
160
  it do
161
- _(form.validate(name: "Helloween", email: "yep")).must_equal true
162
- _(form.errors.messages.inspect).must_equal "{}"
161
+ assert form.validate(name: "Helloween", email: "yep")
162
+ assert_equal form.errors.messages.inspect, "{}"
163
163
  end
164
164
 
165
165
  it "invalid" do
166
- _(form.validate(name: "", email: "yep")).must_equal false
167
- _(form.errors.messages.inspect).must_equal "{:name=>[\"must be filled\"]}"
166
+ assert_equal form.validate(name: "", email: "yep"), false
167
+ assert_equal form.errors.messages.inspect, "{:name=>[\"must be filled\"]}"
168
168
  end
169
169
  end
170
170
 
@@ -178,8 +178,8 @@ class DryValidationDefaultGroupTest < Minitest::Spec
178
178
  property :email
179
179
  property :password
180
180
  property :confirm_password
181
- property :starts_at, type: DRY_TYPES_CONSTANT::DateTime
182
- property :active, type: DRY_TYPES_CONSTANT::Bool
181
+ property :starts_at, type: Types::Params::DateTime
182
+ property :active, type: Types::Params::Bool
183
183
  property :color
184
184
 
185
185
  validation do
@@ -226,15 +226,15 @@ class DryValidationDefaultGroupTest < Minitest::Spec
226
226
  end
227
227
 
228
228
  it "invalid" do
229
- _(form.validate(
229
+ assert_equal form.validate(
230
230
  username: "Helloween",
231
231
  email: "yep",
232
232
  active: "1",
233
233
  starts_at: "01/01/2000 - 11:00",
234
234
  color: "purple"
235
- )).must_equal false
236
- _(form.active).must_equal true
237
- _(form.errors.messages.inspect).must_equal "{:confirm_password=>[\"must be filled\"], :color=>[\"must be one of: red orange green\"]}"
235
+ ), false
236
+ assert form.active
237
+ assert_equal form.errors.messages.inspect, "{:confirm_password=>[\"must be filled\"], :color=>[\"must be one of: red orange green\"]}"
238
238
  end
239
239
  end
240
240
 
@@ -275,36 +275,37 @@ class ValidationGroupsTest < MiniTest::Spec
275
275
 
276
276
  # valid.
277
277
  it do
278
- _(form.validate(username: "Helloween",
279
- special_class: SomeClass.new(id: 15),
280
- email: "yep",
281
- password: "99",
282
- confirm_password: "99")).must_equal true
283
- _(form.errors.messages.inspect).must_equal "{}"
278
+ assert form.validate(
279
+ username: "Helloween",
280
+ special_class: SomeClass.new(id: 15),
281
+ email: "yep",
282
+ password: "99",
283
+ confirm_password: "99"
284
+ )
285
+ assert_equal form.errors.messages.inspect, "{}"
284
286
  end
285
287
 
286
288
  # invalid.
287
289
  it do
288
- _(form.validate({})).must_equal false
289
- _(form.errors.messages).must_equal({username: ["must be filled"], email: ["must be filled"], special_class: ["must be filled", "must be ValidationGroupsTest::SomeClass"]})
290
+ assert_equal form.validate({}), false
291
+ assert_equal form.errors.messages, username: ["must be filled"], email: ["must be filled"], special_class: ["must be filled", "must be ValidationGroupsTest::SomeClass"]
290
292
  end
291
293
 
292
294
  # partially invalid.
293
295
  # 2nd group fails.
294
296
  it do
295
- _(form.validate(username: "Helloween", email: "yo", confirm_password: "9", special_class: SomeClass.new(id: 15))).must_equal false
296
- _(form.errors.messages.inspect).must_equal "{:email=>[\"size cannot be less than 3\"], :confirm_password=>[\"size cannot be less than 2\"]}"
297
+ assert_equal form.validate(username: "Helloween", email: "yo", confirm_password: "9", special_class: SomeClass.new(id: 15)), false
298
+ assert_equal form.errors.messages.inspect, "{:email=>[\"size cannot be less than 3\"], :confirm_password=>[\"size cannot be less than 2\"]}"
297
299
  end
298
300
  # 3rd group fails.
299
301
  it do
300
- _(form.validate(username: "Helloween", email: "yo!", confirm_password: "9", special_class: SomeClass.new(id: 15))).must_equal false
301
- _(form.errors.messages.inspect)
302
- .must_equal "{:confirm_password=>[\"size cannot be less than 2\"], :password=>[\"must be filled\", \"size cannot be less than 2\"]}"
302
+ assert_equal form.validate(username: "Helloween", email: "yo!", confirm_password: "9", special_class: SomeClass.new(id: 15)), false
303
+ assert_equal form.errors.messages.inspect, "{:confirm_password=>[\"size cannot be less than 2\"], :password=>[\"must be filled\", \"size cannot be less than 2\"]}"
303
304
  end
304
305
  # 4th group with after: fails.
305
306
  it do
306
- _(form.validate(username: "Helloween", email: "yo!", password: "1", confirm_password: "9", special_class: SomeClass.new(id: 15))).must_equal false
307
- _(form.errors.messages.inspect).must_equal "{:confirm_password=>[\"size cannot be less than 2\"], :password=>[\"size cannot be less than 2\"]}"
307
+ assert_equal form.validate(username: "Helloween", email: "yo!", password: "1", confirm_password: "9", special_class: SomeClass.new(id: 15)), false
308
+ assert_equal form.errors.messages.inspect, "{:confirm_password=>[\"size cannot be less than 2\"], :password=>[\"size cannot be less than 2\"]}"
308
309
  end
309
310
  end
310
311
 
@@ -329,14 +330,14 @@ class ValidationGroupsTest < MiniTest::Spec
329
330
 
330
331
  # valid.
331
332
  it do
332
- _(form.validate(username: "Nick")).must_equal true
333
- _(form.errors.messages.inspect).must_equal "{}"
333
+ assert form.validate(username: "Nick")
334
+ assert_equal form.errors.messages.inspect, "{}"
334
335
  end
335
336
 
336
337
  # invalid.
337
338
  it do
338
- _(form.validate(username: "Fred")).must_equal false
339
- _(form.errors.messages.inspect).must_equal "{:username=>[\"must be equal to Nick\"]}"
339
+ assert_equal form.validate(username: "Fred"), false
340
+ assert_equal form.errors.messages.inspect, "{:username=>[\"must be equal to Nick\"]}"
340
341
  end
341
342
  end
342
343
  end
@@ -373,21 +374,21 @@ class ValidationGroupsTest < MiniTest::Spec
373
374
  # valid.
374
375
  it do
375
376
  skip "waiting dry-v to add this as feature https://github.com/dry-rb/dry-schema/issues/33"
376
- _(form.validate(username: "Helloween", email: "yep", password: "extrasafe")).must_equal true
377
- _(form.errors.messages.inspect).must_equal "{}"
377
+ assert form.validate(username: "Helloween", email: "yep", password: "extrasafe")
378
+ assert_equal form.errors.messages.inspect, "{}"
378
379
  end
379
380
 
380
381
  # invalid.
381
382
  it do
382
383
  skip "waiting dry-v to add this as feature https://github.com/dry-rb/dry-schema/issues/33"
383
- _(form.validate({})).must_equal false
384
- _(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"])
384
+ assert_equal form.validate({}), false
385
+ assert_equal form.errors.messages, password: ["must be filled", "size cannot be less than 6"], username: ["must be filled"], email: ["must be filled", "you're a bad person"]
385
386
  end
386
387
 
387
388
  it do
388
389
  skip "waiting dry-v to add this as feature https://github.com/dry-rb/dry-schema/issues/33"
389
- _(form.validate(email: 1)).must_equal false
390
- _(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\"]}"
390
+ assert_equal form.validate(email: 1), false
391
+ assert_equal form.errors.messages.inspect, "{:password=>[\"must be filled\", \"size cannot be less than 6\"], :username=>[\"must be filled\"], :email=>[\"you're a bad person\"]}"
391
392
  end
392
393
  end
393
394
 
@@ -424,7 +425,7 @@ class ValidationGroupsTest < MiniTest::Spec
424
425
  end
425
426
 
426
427
  validation do
427
- config.messages.load_paths << "test/fixtures/dry_new_api_error_messages.yml"
428
+ config.messages.load_paths << "test/fixtures/dry_error_messages.yml"
428
429
  params do
429
430
  required(:title).filled
430
431
  required(:band).hash do
@@ -464,23 +465,23 @@ class ValidationGroupsTest < MiniTest::Spec
464
465
  "producers" => [{"name" => ""}, {"name" => "something lovely"}]
465
466
  )
466
467
 
467
- _(result).must_equal false
468
+ assert_equal result, false
468
469
  # from nested validation
469
- _(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"])
470
+ assert_equal form.errors.messages, 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"]
470
471
 
471
472
  # songs have their own validation.
472
- _(form.songs[0].errors.messages).must_equal(title: ["must be filled"])
473
+ assert_equal form.songs[0].errors.messages, title: ["must be filled"]
473
474
  # hit got its own validation group.
474
- _(form.hit.errors.messages).must_equal(title: ["must be filled"])
475
+ assert_equal form.hit.errors.messages, title: ["must be filled"]
475
476
 
476
- _(form.band.label.errors.messages).must_equal(location: ["must be filled"])
477
- _(form.band.errors.messages).must_equal(name: ["must be filled"], "label.location": ["must be filled"])
478
- _(form.producers[0].errors.messages).must_equal(name: ["must be filled"])
477
+ assert_equal form.band.label.errors.messages, location: ["must be filled"]
478
+ assert_equal form.band.errors.messages, name: ["must be filled"], "label.location": ["must be filled"]
479
+ assert_equal form.producers[0].errors.messages, name: ["must be filled"]
479
480
 
480
481
  # TODO: use the same form structure as the top one and do the same test against messages, errors and hints.
481
- _(form.producers[0].to_result.errors).must_equal(name: ["must be filled"])
482
- _(form.producers[0].to_result.messages).must_equal(name: ["must be filled"])
483
- _(form.producers[0].to_result.hints).must_equal({})
482
+ assert_equal form.producers[0].to_result.errors, name: ["must be filled"]
483
+ assert_equal form.producers[0].to_result.messages, name: ["must be filled"]
484
+ assert_equal form.producers[0].to_result.hints, {}
484
485
  end
485
486
 
486
487
  # FIXME: fix the "must be filled error"
@@ -493,11 +494,11 @@ class ValidationGroupsTest < MiniTest::Spec
493
494
  "producers" => [{"name" => ""}, {"name" => ""}, {"name" => "something lovely"}]
494
495
  )
495
496
 
496
- _(result).must_equal false
497
- _(form.band.errors.full_messages).must_equal ["Name must be filled", "Label Location must be filled"]
498
- _(form.band.label.errors.full_messages).must_equal ["Location must be filled"]
499
- _(form.producers.first.errors.full_messages).must_equal ["Name must be filled"]
500
- _(form.errors.full_messages).must_equal ["Title must be filled", "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"]
497
+ assert_equal result, false
498
+ assert_equal form.band.errors.full_messages, ["Name must be filled", "Label Location must be filled"]
499
+ assert_equal form.band.label.errors.full_messages, ["Location must be filled"]
500
+ assert_equal form.producers.first.errors.full_messages, ["Name must be filled"]
501
+ assert_equal form.errors.full_messages, ["Title must be filled", "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"]
501
502
  end
502
503
 
503
504
  describe "only 1 nested validation" do
@@ -511,7 +512,7 @@ class ValidationGroupsTest < MiniTest::Spec
511
512
  end
512
513
 
513
514
  validation do
514
- config.messages.load_paths << "test/fixtures/dry_new_api_error_messages.yml"
515
+ config.messages.load_paths << "test/fixtures/dry_error_messages.yml"
515
516
 
516
517
  params do
517
518
  required(:title).filled
@@ -536,14 +537,14 @@ class ValidationGroupsTest < MiniTest::Spec
536
537
  "producers" => [{"name" => ""}, {"name" => ""}, {"name" => "something lovely"}]
537
538
  )
538
539
 
539
- _(form.to_result.errors).must_equal(title: ["must be filled"])
540
- _(form.band.to_result.errors).must_equal(name: ["must be filled"])
541
- _(form.band.label.to_result.errors).must_equal(location: ["must be filled"])
540
+ assert_equal form.to_result.errors, title: ["must be filled"]
541
+ assert_equal form.band.to_result.errors, name: ["must be filled"]
542
+ assert_equal form.band.label.to_result.errors, location: ["must be filled"]
542
543
 
543
544
  # with locale: "de"
544
- _(form.to_result.errors(locale: :de)).must_equal(title: ["muss abgefüllt sein"])
545
- _(form.band.to_result.errors(locale: :de)).must_equal(name: ["muss abgefüllt sein"])
546
- _(form.band.label.to_result.errors(locale: :de)).must_equal(location: ["muss abgefüllt sein"])
545
+ assert_equal form.to_result.errors(locale: :de), title: ["muss abgefüllt sein"]
546
+ assert_equal form.band.to_result.errors(locale: :de), name: ["muss abgefüllt sein"]
547
+ assert_equal form.band.label.to_result.errors(locale: :de), location: ["muss abgefüllt sein"]
547
548
  end
548
549
  end
549
550
  end
@@ -604,14 +605,14 @@ class ValidationGroupsTest < MiniTest::Spec
604
605
  # valid.
605
606
  it do
606
607
  skip "waiting dry-v to add this as feature https://github.com/dry-rb/dry-schema/issues/33"
607
- _(form.validate(email: 9)).must_equal true
608
+ assert form.validate(email: 9)
608
609
  end
609
610
 
610
611
  # invalid.
611
612
  it do
612
613
  skip "waiting dry-v to add this as feature https://github.com/dry-rb/dry-schema/issues/33"
613
- _(form.validate({})).must_equal false
614
- _(form.errors.messages).must_equal email: ["must be filled"], full_name: ["must be filled"]
614
+ assert_equal form.validate({}), false
615
+ assert_equal form.errors.messages, email: ["must be filled"], full_name: ["must be filled"]
615
616
  end
616
617
  end
617
618
 
@@ -640,13 +641,13 @@ class ValidationGroupsTest < MiniTest::Spec
640
641
 
641
642
  # valid.
642
643
  it do
643
- _(form.validate(username: "Strung Out", email: 9)).must_equal true
644
+ assert form.validate(username: "Strung Out", email: 9)
644
645
  end
645
646
 
646
647
  # invalid.
647
648
  it do
648
- _(form.validate(email: 9)).must_equal false
649
- _(form.errors.messages.inspect).must_equal "{:username=>[\"must be filled\"]}"
649
+ assert_equal form.validate(email: 9), false
650
+ assert_equal form.errors.messages.inspect, "{:username=>[\"must be filled\"]}"
650
651
  end
651
652
  end
652
653
 
@@ -670,8 +671,8 @@ class ValidationGroupsTest < MiniTest::Spec
670
671
  let(:form) { OrderForm.new(order.new(company.new)) }
671
672
 
672
673
  it "has company error" do
673
- _(form.validate(delivery_address: {company: "not int"})).must_equal false
674
- _(form.errors.messages).must_equal(:"delivery_address.company" => ["must be an integer"])
674
+ assert_equal form.validate(delivery_address: {company: "not int"}), false
675
+ assert_equal form.errors.messages, :"delivery_address.company" => ["must be an integer"]
675
676
  end
676
677
  end
677
678
 
@@ -693,8 +694,8 @@ class ValidationGroupsTest < MiniTest::Spec
693
694
  let(:form) { OrderFormWithForm.new(order.new(company.new)) }
694
695
 
695
696
  it "has company error" do
696
- _(form.validate(delivery_address: {company: "not int"})).must_equal false
697
- _(form.errors.messages).must_equal(:"delivery_address.company" => ["must be an integer"])
697
+ assert_equal form.validate(delivery_address: {company: "not int"}), false
698
+ assert_equal form.errors.messages, :"delivery_address.company" => ["must be an integer"]
698
699
  end
699
700
  end
700
701
 
@@ -721,7 +722,7 @@ class ValidationGroupsTest < MiniTest::Spec
721
722
  end
722
723
 
723
724
  validation do
724
- config.messages.load_paths << "test/fixtures/dry_new_api_error_messages.yml"
725
+ config.messages.load_paths << "test/fixtures/dry_error_messages.yml"
725
726
 
726
727
  params do
727
728
  required(:songs).filled
@@ -740,21 +741,21 @@ class ValidationGroupsTest < MiniTest::Spec
740
741
 
741
742
  it "validates fails and shows the correct errors" do
742
743
  form = AlbumForm.new(Album.new(nil, [], nil))
743
- _(form.validate(
744
+ assert_equal form.validate(
744
745
  "songs" => [
745
746
  {"title" => "One", "enabled" => false},
746
747
  {"title" => nil, "enabled" => false},
747
748
  {"title" => "Three", "enabled" => false}
748
749
  ],
749
750
  "artist" => {"last_name" => nil}
750
- )).must_equal false
751
- _(form.songs.size).must_equal 3
751
+ ), false
752
+ assert_equal form.songs.size, 3
752
753
 
753
- _(form.errors.messages).must_equal(
754
+ assert_equal form.errors.messages, {
754
755
  :songs => ["must have at least one enabled song"],
755
756
  :artist => ["must have last name"],
756
757
  :"songs.title" => ["must be filled"]
757
- )
758
+ }
758
759
  end
759
760
  end
760
761
 
@@ -784,26 +785,26 @@ class ValidationGroupsTest < MiniTest::Spec
784
785
  it "using params" do
785
786
  model = Foo.new
786
787
  form = ParamsForm.new(model)
787
- _(form.validate(age: "99")).must_equal true
788
+ assert form.validate(age: "99")
788
789
  form.sync
789
- _(model.age).must_equal "99"
790
+ assert_equal model.age, "99"
790
791
 
791
792
  form = ParamsForm.new(Foo.new)
792
- _(form.validate(age: "1000")).must_equal false
793
- _(form.errors.messages).must_equal age: ["value exceeded"]
793
+ assert_equal form.validate(age: "1000"), false
794
+ assert_equal form.errors.messages, age: ["value exceeded"]
794
795
  end
795
796
 
796
797
  it "using schema" do
797
798
  model = Foo.new
798
799
  form = SchemaForm.new(model)
799
- _(form.validate(age: "99")).must_equal false
800
- _(form.validate(age: 99)).must_equal true
800
+ assert_equal form.validate(age: "99"), false
801
+ assert form.validate(age: 99)
801
802
  form.sync
802
- _(model.age).must_equal 99
803
+ assert_equal model.age, 99
803
804
 
804
805
  form = SchemaForm.new(Foo.new)
805
- _(form.validate(age: 1000)).must_equal false
806
- _(form.errors.messages).must_equal age: ["value exceeded"]
806
+ assert_equal form.validate(age: 1000), false
807
+ assert_equal form.errors.messages, age: ["value exceeded"]
807
808
  end
808
809
  end
809
810