reform 2.3.2 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +17 -0
  3. data/.gitignore +1 -1
  4. data/CHANGES.md +23 -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/form/populator.rb +13 -3
  12. data/lib/reform/form/prepopulate.rb +1 -1
  13. data/lib/reform/form/validate.rb +3 -3
  14. data/lib/reform/validation/groups.rb +0 -1
  15. data/lib/reform/version.rb +1 -1
  16. data/reform.gemspec +2 -2
  17. data/test/call_test.rb +23 -0
  18. data/test/changed_test.rb +6 -6
  19. data/test/coercion_test.rb +17 -17
  20. data/test/{composition_new_api.rb → composition_test.rb} +27 -28
  21. data/test/{contract_new_api.rb → contract_test.rb} +8 -8
  22. data/test/default_test.rb +2 -2
  23. data/test/deserialize_test.rb +8 -8
  24. data/test/docs/validation_test.rb +134 -0
  25. data/test/{errors_new_api.rb → errors_test.rb} +41 -41
  26. data/test/feature_test.rb +2 -2
  27. data/test/fixtures/dry_error_messages.yml +64 -54
  28. data/test/{form_option_new_api.rb → form_option_test.rb} +1 -1
  29. data/test/{form_new_api.rb → form_test.rb} +3 -3
  30. data/test/from_test.rb +10 -10
  31. data/test/{inherit_new_api.rb → inherit_test.rb} +17 -17
  32. data/test/{module_new_api.rb → module_test.rb} +10 -10
  33. data/test/parse_option_test.rb +7 -7
  34. data/test/parse_pipeline_test.rb +1 -1
  35. data/test/{populate_new_api.rb → populate_test.rb} +136 -53
  36. data/test/populator_skip_test.rb +2 -2
  37. data/test/prepopulator_test.rb +16 -16
  38. data/test/read_only_test.rb +2 -2
  39. data/test/readable_test.rb +3 -3
  40. data/test/{reform_new_api.rb → reform_test.rb} +19 -19
  41. data/test/{save_new_api.rb → save_test.rb} +4 -4
  42. data/test/setup_test.rb +9 -9
  43. data/test/{skip_if_new_api.rb → skip_if_test.rb} +12 -12
  44. data/test/skip_setter_and_getter_test.rb +6 -6
  45. data/test/test_helper.rb +5 -6
  46. data/test/{validate_new_api.rb → validate_test.rb} +65 -78
  47. data/test/validation/{dry_validation_new_api.rb → dry_validation_test.rb} +128 -128
  48. data/test/validation/result_test.rb +14 -14
  49. data/test/virtual_test.rb +7 -7
  50. data/test/writeable_test.rb +8 -8
  51. metadata +42 -75
  52. data/.travis.yml +0 -16
  53. data/Appraisals +0 -8
  54. data/gemfiles/0.13.0.gemfile +0 -8
  55. data/gemfiles/1.5.0.gemfile +0 -9
  56. data/lib/reform/form/dry/new_api.rb +0 -47
  57. data/lib/reform/form/dry/old_api.rb +0 -61
  58. data/test/call_new_api.rb +0 -23
  59. data/test/call_old_api.rb +0 -23
  60. data/test/composition_old_api.rb +0 -184
  61. data/test/contract_old_api.rb +0 -77
  62. data/test/errors_old_api.rb +0 -230
  63. data/test/fixtures/dry_new_api_error_messages.yml +0 -104
  64. data/test/form_old_api.rb +0 -57
  65. data/test/form_option_old_api.rb +0 -24
  66. data/test/inherit_old_api.rb +0 -105
  67. data/test/module_old_api.rb +0 -146
  68. data/test/populate_old_api.rb +0 -304
  69. data/test/reform_old_api.rb +0 -202
  70. data/test/save_old_api.rb +0 -101
  71. data/test/skip_if_old_api.rb +0 -92
  72. data/test/validate_old_api.rb +0 -410
  73. data/test/validation/dry_validation_old_api.rb +0 -772
@@ -25,8 +25,8 @@ class ModuleInclusionTest < MiniTest::Spec
25
25
  params { required(:band).filled }
26
26
  end
27
27
 
28
- include Dry::Types.module # allows using Types::* in module.
29
- property :cool, type: DRY_TYPES_CONSTANT::Bool # test coercion.
28
+ include Dry.Types(default: :nominal) # allows using Types::* in module.
29
+ property :cool, type: Types::Params::Bool # test coercion.
30
30
  end
31
31
 
32
32
  # TODO: test if works, move stuff into inherit_schema!
@@ -60,24 +60,24 @@ class ModuleInclusionTest < MiniTest::Spec
60
60
  let(:song) { OpenStruct.new(band: OpenStruct.new(title: "Time Again")) }
61
61
 
62
62
  # nested form from module is present and creates accessor.
63
- it { SongForm.new(song).band.title.must_equal "Time Again" }
63
+ it { assert_equal SongForm.new(song).band.title, "Time Again" }
64
64
 
65
65
  # methods from module get included.
66
- it { SongForm.new(song).id.must_equal 1 }
67
- it { SongForm.new(song).band.id.must_equal 2 }
66
+ it { assert_equal SongForm.new(song).id, 1 }
67
+ it { assert_equal SongForm.new(song).band.id, 2 }
68
68
 
69
69
  # validators get inherited.
70
70
  it do
71
71
  form = SongForm.new(OpenStruct.new)
72
72
  form.validate({})
73
- form.errors.messages.must_equal(band: ["must be filled"])
73
+ assert_equal form.errors.messages, band: ["must be filled"]
74
74
  end
75
75
 
76
76
  # coercion works
77
77
  it do
78
78
  form = SongForm.new(OpenStruct.new)
79
79
  form.validate(cool: "1")
80
- form.cool.must_equal true
80
+ assert form.cool
81
81
  end
82
82
 
83
83
  # include a module into a module into a class :)
@@ -106,7 +106,7 @@ class ModuleInclusionTest < MiniTest::Spec
106
106
  it do
107
107
  form = AlbumForm.new(OpenStruct.new(band: OpenStruct.new))
108
108
  form.validate("band" => {})
109
- form.errors.messages.must_equal("band.title": ["must be filled"], "band.label": ["must be filled"], name: ["must be filled"])
109
+ assert_equal form.errors.messages, "band.title": ["must be filled"], "band.label": ["must be filled"], name: ["must be filled"]
110
110
  end
111
111
 
112
112
  describe "module with custom accessors" do
@@ -130,8 +130,8 @@ class ModuleInclusionTest < MiniTest::Spec
130
130
  let(:song) { OpenStruct.new(id: 1, title: "Instant Mash") }
131
131
 
132
132
  it do
133
- IncludingSongForm.new(song).id.must_equal 1
134
- IncludingSongForm.new(song).title.must_equal "INSTANT MASH"
133
+ assert_equal IncludingSongForm.new(song).id, 1
134
+ assert_equal IncludingSongForm.new(song).title, "INSTANT MASH"
135
135
  end
136
136
  end
137
137
  end
@@ -13,13 +13,13 @@ class ParseOptionTest < MiniTest::Spec
13
13
  let(:form) { CommentForm.new(Comment.new, user: current_user) }
14
14
 
15
15
  it do
16
- form.user.must_equal current_user
16
+ assert_equal form.user, current_user
17
17
 
18
18
  lorem = "Lorem ipsum dolor sit amet..."
19
19
  form.validate("content" => lorem, "user" => "not the current user")
20
20
 
21
- form.content.must_equal lorem
22
- form.user.must_equal current_user
21
+ assert_equal form.content, lorem
22
+ assert_equal form.user, current_user
23
23
  end
24
24
 
25
25
  describe "using ':parse' option doesn't override other ':deserialize' options" do
@@ -30,11 +30,11 @@ class ParseOptionTest < MiniTest::Spec
30
30
  end
31
31
 
32
32
  it do
33
- ArticleCommentForm.definitions.get(:user)[:deserializer][:writeable].must_equal false
34
- ArticleCommentForm.definitions.get(:user)[:deserializer][:instance].must_equal "Instance"
33
+ assert_equal ArticleCommentForm.definitions.get(:user)[:deserializer][:writeable], false
34
+ assert_equal ArticleCommentForm.definitions.get(:user)[:deserializer][:instance], "Instance"
35
35
 
36
- ArticleCommentForm.definitions.get(:article)[:deserializer][:writeable].must_equal true
37
- ArticleCommentForm.definitions.get(:article)[:deserializer][:instance].must_equal "Instance"
36
+ assert ArticleCommentForm.definitions.get(:article)[:deserializer][:writeable]
37
+ assert_equal ArticleCommentForm.definitions.get(:article)[:deserializer][:instance], "Instance"
38
38
  end
39
39
  end
40
40
  end
@@ -10,6 +10,6 @@ class ParsePipelineTest < MiniTest::Spec
10
10
  it "allows passing :parse_pipeline directly" do
11
11
  form = AlbumForm.new(Album.new)
12
12
  form.validate("name" => "Greatest Hits")
13
- form.name.must_equal "{\"name\"=>\"Greatest Hits\"}"
13
+ assert_equal form.name, "{\"name\"=>\"Greatest Hits\"}"
14
14
  end
15
15
  end
@@ -48,7 +48,7 @@ class PopulatorTest < MiniTest::Spec
48
48
  "name" => "override me!"
49
49
  )
50
50
 
51
- form.name.must_equal "!em edirrevo"
51
+ assert_equal form.name, "!em edirrevo"
52
52
  end
53
53
 
54
54
  # changing existing property :artist.
@@ -60,7 +60,7 @@ class PopulatorTest < MiniTest::Spec
60
60
  "artist" => {"name" => "Marcus Miller"}
61
61
  )
62
62
 
63
- form.artist.model.object_id.must_equal old_id
63
+ assert_equal form.artist.model.object_id, old_id
64
64
  end
65
65
 
66
66
  # use populator for default value on scalars?
@@ -68,36 +68,36 @@ class PopulatorTest < MiniTest::Spec
68
68
  # adding to collection via :populator.
69
69
  # valid.
70
70
  it "yyy" do
71
- form.validate(
71
+ assert form.validate(
72
72
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"},
73
73
  {"title" => "Rime Of The Ancient Mariner"}, # new song.
74
74
  {"title" => "Re-Education", "composer" => {"name" => "Rise Against"}}], # new song with new composer.
75
- ).must_equal true
75
+ )
76
76
 
77
- form.errors.messages.inspect.must_equal "{}"
77
+ assert_equal form.errors.messages.inspect, "{}"
78
78
 
79
79
  # form has updated.
80
- form.name.must_equal "The Dissent Of Man"
81
- form.songs[0].title.must_equal "Fallout"
82
- form.songs[1].title.must_equal "Roxanne"
83
- form.songs[1].composer.name.must_equal "Greg Graffin"
80
+ assert_equal form.name, "The Dissent Of Man"
81
+ assert_equal form.songs[0].title, "Fallout"
82
+ assert_equal form.songs[1].title, "Roxanne"
83
+ assert_equal form.songs[1].composer.name, "Greg Graffin"
84
84
 
85
- form.songs[1].composer.model.must_be_instance_of Artist
85
+ form.songs[1].composer.model.is_a? Artist
86
86
 
87
- form.songs[1].title.must_equal "Roxanne"
88
- form.songs[2].title.must_equal "Rime Of The Ancient Mariner" # new song added.
89
- form.songs[3].title.must_equal "Re-Education"
90
- form.songs[3].composer.name.must_equal "Rise Against"
91
- form.songs.size.must_equal 4
92
- form.artist.name.must_equal "Bad Religion"
87
+ assert_equal form.songs[1].title, "Roxanne"
88
+ assert_equal form.songs[2].title, "Rime Of The Ancient Mariner" # new song added.
89
+ assert_equal form.songs[3].title, "Re-Education"
90
+ assert_equal form.songs[3].composer.name, "Rise Against"
91
+ assert_equal form.songs.size, 4
92
+ assert_equal form.artist.name, "Bad Religion"
93
93
 
94
94
  # model has not changed, yet.
95
- album.name.must_equal "The Dissent Of Man"
96
- album.songs[0].title.must_equal "Broken"
97
- album.songs[1].title.must_equal "Resist Stance"
98
- album.songs[1].composer.name.must_equal "Greg Graffin"
99
- album.songs.size.must_equal 2
100
- album.artist.name.must_equal "Bad Religion"
95
+ assert_equal album.name, "The Dissent Of Man"
96
+ assert_equal album.songs[0].title, "Broken"
97
+ assert_equal album.songs[1].title, "Resist Stance"
98
+ assert_equal album.songs[1].composer.name, "Greg Graffin"
99
+ assert_equal album.songs.size, 2
100
+ assert_equal album.artist.name, "Bad Religion"
101
101
  end
102
102
  end
103
103
 
@@ -117,7 +117,7 @@ class PopulateWithMethodTest < Minitest::Spec
117
117
  it "runs populator method" do
118
118
  form.validate("title" => "override me!")
119
119
 
120
- form.title.must_equal "!em edirrevo"
120
+ assert_equal form.title, "!em edirrevo"
121
121
  end
122
122
  end
123
123
 
@@ -127,6 +127,14 @@ class PopulateWithCallableTest < Minitest::Spec
127
127
  class TitlePopulator
128
128
  include Uber::Callable
129
129
 
130
+ def call(form:, **options)
131
+ form.title = options[:fragment].reverse
132
+ end
133
+ end
134
+
135
+ class TitlePopulatorWithOldSignature
136
+ include Uber::Callable
137
+
130
138
  def call(form, options)
131
139
  form.title = options[:fragment].reverse
132
140
  end
@@ -136,12 +144,28 @@ class PopulateWithCallableTest < Minitest::Spec
136
144
  property :title, populator: TitlePopulator.new
137
145
  end
138
146
 
147
+ class AlbumFormWithOldPopulator < TestForm
148
+ property :title, populator: TitlePopulatorWithOldSignature.new
149
+ end
150
+
139
151
  let(:form) { AlbumForm.new(Album.new) }
140
152
 
141
153
  it "runs populator method" do
142
154
  form.validate("title" => "override me!")
143
155
 
144
- form.title.must_equal "!em edirrevo"
156
+ assert_equal form.title, "!em edirrevo"
157
+ end
158
+
159
+ it "gives warning when `form` is accepted as a positional argument" do
160
+ _, warnings = capture_io do
161
+ form = AlbumFormWithOldPopulator.new(Album.new)
162
+ form.validate("title" => "override me!")
163
+
164
+ assert_equal form.title, "!em edirrevo"
165
+ end
166
+
167
+ assert_equal warnings, %{[Reform] Accepting `form` as a positional argument in `:populator` will be deprecated. Please use `def call(form:, **options)` signature instead.
168
+ }
145
169
  end
146
170
  end
147
171
 
@@ -161,7 +185,7 @@ class PopulateWithProcTest < Minitest::Spec
161
185
  it "runs populator method" do
162
186
  form.validate("title" => "override me!")
163
187
 
164
- form.title.must_equal "!em edirrevo"
188
+ assert_equal form.title, "!em edirrevo"
165
189
  end
166
190
  end
167
191
 
@@ -216,35 +240,35 @@ class PopulateIfEmptyTest < MiniTest::Spec
216
240
  let(:form) { AlbumForm.new(album) }
217
241
 
218
242
  it do
219
- form.songs.size.must_equal 2
243
+ assert_equal form.songs.size, 2
220
244
 
221
- form.validate(
245
+ assert form.validate(
222
246
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"},
223
247
  {"title" => "Rime Of The Ancient Mariner"}, # new song.
224
248
  {"title" => "Re-Education", "composer" => {"name" => "Rise Against"}}], # new song with new composer.
225
- ).must_equal true
249
+ )
226
250
 
227
- form.errors.messages.inspect.must_equal "{}"
251
+ assert_equal form.errors.messages.inspect, "{}"
228
252
 
229
253
  # form has updated.
230
- form.name.must_equal "The Dissent Of Man"
231
- form.songs[0].title.must_equal "Fallout"
232
- form.songs[1].title.must_equal "Roxanne"
233
- form.songs[1].composer.name.must_equal "Greg Graffin"
234
- form.songs[1].title.must_equal "Roxanne"
235
- form.songs[2].title.must_equal "Rime Of The Ancient Mariner" # new song added.
236
- form.songs[3].title.must_equal "Re-Education"
237
- form.songs[3].composer.name.must_equal "Rise Against"
238
- form.songs.size.must_equal 4
239
- form.artist.name.must_equal "Bad Religion"
254
+ assert_equal form.name, "The Dissent Of Man"
255
+ assert_equal form.songs[0].title, "Fallout"
256
+ assert_equal form.songs[1].title, "Roxanne"
257
+ assert_equal form.songs[1].composer.name, "Greg Graffin"
258
+ assert_equal form.songs[1].title, "Roxanne"
259
+ assert_equal form.songs[2].title, "Rime Of The Ancient Mariner" # new song added.
260
+ assert_equal form.songs[3].title, "Re-Education"
261
+ assert_equal form.songs[3].composer.name, "Rise Against"
262
+ assert_equal form.songs.size, 4
263
+ assert_equal form.artist.name, "Bad Religion"
240
264
 
241
265
  # model has not changed, yet.
242
- album.name.must_equal "The Dissent Of Man"
243
- album.songs[0].title.must_equal "Broken"
244
- album.songs[1].title.must_equal "Resist Stance"
245
- album.songs[1].composer.name.must_equal "Greg Graffin"
246
- album.songs.size.must_equal 2
247
- album.artist.name.must_equal "Bad Religion"
266
+ assert_equal album.name, "The Dissent Of Man"
267
+ assert_equal album.songs[0].title, "Broken"
268
+ assert_equal album.songs[1].title, "Resist Stance"
269
+ assert_equal album.songs[1].composer.name, "Greg Graffin"
270
+ assert_equal album.songs.size, 2
271
+ assert_equal album.artist.name, "Bad Religion"
248
272
  end
249
273
 
250
274
  # trigger artist populator. lambda calling form instance method.
@@ -252,11 +276,11 @@ class PopulateIfEmptyTest < MiniTest::Spec
252
276
  form = AlbumForm.new(album = Album.new)
253
277
  form.validate("artist" => {"name" => "From Autumn To Ashes"})
254
278
 
255
- form.artist.name.must_equal "From Autumn To Ashes"
279
+ assert_equal form.artist.name, "From Autumn To Ashes"
256
280
  # test lambda was executed in form context.
257
- form.artist.model.must_be_instance_of AlbumForm::Sting
281
+ assert form.artist.model.is_a? AlbumForm::Sting
258
282
  # test lambda block arguments.
259
- form.artist.model.args.to_s.must_equal "[{\"name\"=>\"From Autumn To Ashes\"}, nil]"
283
+ assert_equal form.artist.model.args.to_s, "[{\"name\"=>\"From Autumn To Ashes\"}, nil]"
260
284
 
261
285
  assert_nil album.artist
262
286
  end
@@ -292,13 +316,72 @@ class PopulateIfEmptyWithDeletionTest < MiniTest::Spec
292
316
  let(:form) { AlbumForm.new(album) }
293
317
 
294
318
  it do
295
- form.validate(
319
+ assert form.validate(
296
320
  "songs" => [{"title" => "Broken, delete me!"}, {"title" => "Roxanne"}]
297
- ).must_equal true
321
+ )
322
+
323
+ assert_equal form.errors.messages.inspect, "{}"
324
+
325
+ assert_equal form.songs.size, 1
326
+ assert_equal form.songs[0].title, "Roxanne"
327
+ end
328
+ end
298
329
 
299
- form.errors.messages.inspect.must_equal "{}"
330
+ class PopulateWithFormKeyTest < MiniTest::Spec
331
+ Song = Struct.new(:title, :album, :composer)
332
+ Album = Struct.new(:name, :songs, :artist)
333
+
334
+ let(:song) { Song.new('Broken') }
335
+ let(:song2) { Song.new('Resist Stance') }
336
+ let(:album) { Album.new('The Dissent Of Man', [song, song2]) }
337
+
338
+ class SongForm < TestForm
339
+ property :title
340
+
341
+ validation do
342
+ params { required(:title).filled }
343
+ end
344
+ end
345
+
346
+ class AlbumForm < TestForm
347
+ property :name
348
+
349
+ collection :songs, form: SongForm, populator: :populator!, model_identifier: :title
300
350
 
301
- form.songs.size.must_equal 1
302
- form.songs[0].title.must_equal "Roxanne"
351
+ def populator!(fragment:, **)
352
+ item = songs.find { |song| song.title == fragment['title'] }
353
+ if item && fragment['delete'] == '1'
354
+ songs.delete(item)
355
+ return skip!
356
+ end
357
+ item || songs.append(Song.new)
358
+ end
359
+ end
360
+
361
+ let(:form) { AlbumForm.new(album) }
362
+
363
+ it do
364
+ assert_equal 2, form.songs.size
365
+
366
+ assert form.validate(
367
+ 'songs' => [
368
+ { 'title' => 'Broken' },
369
+ { 'title' => 'Resist Stance' },
370
+ { 'title' => 'Rime Of The Ancient Mariner' }
371
+ ]
372
+ )
373
+
374
+ assert_equal 3, form.songs.size
375
+
376
+ assert form.validate(
377
+ 'songs' => [
378
+ { 'title' => 'Broken', 'delete' => '1' },
379
+ { 'title' => 'Resist Stance' },
380
+ { 'title' => 'Rime Of The Ancient Mariner' }
381
+ ]
382
+ )
383
+ assert_equal 2, form.songs.size
384
+ assert_equal 'Resist Stance', form.songs.first.title
385
+ assert_equal 'Rime Of The Ancient Mariner', form.songs.last.title
303
386
  end
304
387
  end
@@ -21,8 +21,8 @@ class PopulatorSkipTest < MiniTest::Spec
21
21
 
22
22
  form.validate(hash)
23
23
 
24
- form.songs.size.must_equal 2
24
+ assert_equal form.songs.size, 2
25
25
  assert_nil form.songs[0].title
26
- form.songs[1].title.must_equal "Bad"
26
+ assert_equal form.songs[1].title, "Bad"
27
27
  end
28
28
  end
@@ -37,25 +37,25 @@ class PrepopulatorTest < MiniTest::Spec
37
37
  it do
38
38
  form = AlbumForm.new(OpenStruct.new(length: 1)).prepopulate!(title: "Potemkin City Limits")
39
39
 
40
- form.length.must_equal 1
41
- form.title.must_equal "Another Day At Work"
42
- form.hit.model.must_equal Song.new("Potemkin City Limits")
43
- form.songs.size.must_equal 2
44
- form.songs[0].model.must_equal Song.new
45
- form.songs[1].model.must_equal Song.new
46
- form.songs[1].model.must_equal Song.new
40
+ assert_equal form.length, 1
41
+ assert_equal form.title, "Another Day At Work"
42
+ assert_equal form.hit.model, Song.new("Potemkin City Limits")
43
+ assert_equal form.songs.size, 2
44
+ assert_equal form.songs[0].model, Song.new
45
+ assert_equal form.songs[1].model, Song.new
46
+ assert_equal form.songs[1].model, Song.new
47
47
  # prepopulate works more than 1 level, recursive.
48
48
  # it also passes options properly down there.
49
- form.hit.band.model.must_equal Band.new("Potemkin City Limits")
49
+ assert_equal form.hit.band.model, Band.new("Potemkin City Limits")
50
50
  end
51
51
 
52
52
  # add to existing collection.
53
53
  it do
54
- form = AlbumForm.new(OpenStruct.new(songs: [Song.new])).prepopulate!
54
+ form = AlbumForm.new(OpenStruct.new(songs: [Song.new])).prepopulate!(title: "Potemkin City Limits")
55
55
 
56
- form.songs.size.must_equal 2
57
- form.songs[0].model.must_equal Song.new
58
- form.songs[1].model.must_equal Song.new
56
+ assert_equal form.songs.size, 2
57
+ assert_equal form.songs[0].model, Song.new
58
+ assert_equal form.songs[1].model, Song.new
59
59
  end
60
60
  end
61
61
 
@@ -75,7 +75,7 @@ class PrepopulateWithoutConfiguration < MiniTest::Spec
75
75
 
76
76
  subject { AlbumForm.new(OpenStruct.new(songs: [], hit: nil)).prepopulate! }
77
77
 
78
- it { subject.songs.size.must_equal 0 }
78
+ it { assert_equal subject.songs.size, 0 }
79
79
  end
80
80
 
81
81
  class ManualPrepopulatorOverridingTest < MiniTest::Spec
@@ -104,8 +104,8 @@ class ManualPrepopulatorOverridingTest < MiniTest::Spec
104
104
  it do
105
105
  form = AlbumForm.new(OpenStruct.new(length: 1)).prepopulate!(title: "Potemkin City Limits")
106
106
 
107
- form.length.must_equal 1
108
- form.hit.model.must_equal Song.new("Potemkin City Limits")
109
- form.hit.title.must_equal "Potemkin City Limits"
107
+ assert_equal form.length, 1
108
+ assert_equal form.hit.model, Song.new("Potemkin City Limits")
109
+ assert_equal form.hit.title, "Potemkin City Limits"
110
110
  end
111
111
  end
@@ -9,6 +9,6 @@ class ReadonlyTest < MiniTest::Spec
9
9
 
10
10
  let(:form) { SongForm.new(OpenStruct.new) }
11
11
 
12
- it { form.readonly?(:artist).must_equal false }
13
- it { form.readonly?(:title).must_equal true }
12
+ it { refute form.readonly?(:artist) }
13
+ it { assert form.readonly?(:title) }
14
14
  end
@@ -15,16 +15,16 @@ class ReadableTest < MiniTest::Spec
15
15
 
16
16
  form.validate("password" => "123")
17
17
 
18
- form.password.must_equal "123"
18
+ assert_equal form.password, "123"
19
19
 
20
20
  form.sync
21
- cred.password.must_equal "123" # password written.
21
+ assert_equal cred.password, "123" # password written.
22
22
 
23
23
  hash = {}
24
24
  form.save do |nested|
25
25
  hash = nested
26
26
  end
27
27
 
28
- hash.must_equal("password" => "123")
28
+ assert_equal hash, "password" => "123"
29
29
  }
30
30
  end
@@ -19,7 +19,7 @@ class ReformTest < Minitest::Spec
19
19
 
20
20
  it "returns empty fields" do
21
21
  assert_nil form.title
22
- form.name.must_be_nil
22
+ assert_nil form.name
23
23
  end
24
24
 
25
25
  describe "and submitted values" do
@@ -27,15 +27,15 @@ class ReformTest < Minitest::Spec
27
27
  form.validate("name" => "Duran Duran")
28
28
 
29
29
  assert_nil form.title
30
- form.name.must_equal "Duran Duran"
30
+ assert_equal form.name, "Duran Duran"
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
35
  describe "(edit) form with existing models" do
36
36
  it "returns filled-out fields" do
37
- form.name.must_equal "Duran Duran"
38
- form.title.must_equal "Rio"
37
+ assert_equal form.name, "Duran Duran"
38
+ assert_equal form.title, "Rio"
39
39
  end
40
40
  end
41
41
 
@@ -50,13 +50,13 @@ class ReformTest < Minitest::Spec
50
50
  end
51
51
 
52
52
  it "returns true when valid" do
53
- form.validate("name" => "Duran Duran").must_equal true
53
+ assert_equal form.validate("name" => "Duran Duran"), true
54
54
  end
55
55
 
56
56
  it "exposes input via property accessors" do
57
57
  form.validate("name" => "Duran Duran")
58
58
 
59
- form.name.must_equal "Duran Duran"
59
+ assert_equal form.name, "Duran Duran"
60
60
  end
61
61
 
62
62
  it "doesn't change model properties" do
@@ -81,12 +81,12 @@ class ReformTest < Minitest::Spec
81
81
  let(:form) { ValidatingForm.new(comp) }
82
82
 
83
83
  it "returns false when invalid" do
84
- form.validate({}).must_equal false
84
+ assert_equal form.validate({}), false
85
85
  end
86
86
 
87
87
  it "populates errors" do
88
88
  form.validate({})
89
- form.errors.messages.must_equal(name: ["must be filled"], title: ["must be filled"])
89
+ assert_equal form.errors.messages, name: ["must be filled"], title: ["must be filled"]
90
90
  end
91
91
  end
92
92
  end
@@ -100,7 +100,7 @@ class ReformTest < Minitest::Spec
100
100
  it "xxpushes data to models" do
101
101
  form.save
102
102
 
103
- comp.name.must_equal "Diesel Boy"
103
+ assert_equal comp.name, "Diesel Boy"
104
104
  assert_nil comp.title
105
105
  end
106
106
 
@@ -112,13 +112,13 @@ class ReformTest < Minitest::Spec
112
112
  hash = map
113
113
  end
114
114
 
115
- hash.must_equal("name" => "Diesel Boy", "title" => nil)
115
+ assert_equal hash, "name" => "Diesel Boy", "title" => nil
116
116
  end
117
117
  end
118
118
  end
119
119
 
120
120
  describe "#model" do
121
- it { form.model.must_equal comp }
121
+ it { assert_equal form.model, comp }
122
122
  end
123
123
 
124
124
  describe "inheritance" do
@@ -132,9 +132,9 @@ class ReformTest < Minitest::Spec
132
132
  let(:form) { HitForm.new(OpenStruct.new()) }
133
133
  it do
134
134
  form.validate("title" => "The Body")
135
- form.title.must_equal "The Body"
135
+ assert_equal form.title, "The Body"
136
136
  assert_nil form.position
137
- form.errors.messages.must_equal(name: ["must be filled"], position: ["must be filled"])
137
+ assert_equal form.errors.messages, name: ["must be filled"], position: ["must be filled"]
138
138
  end
139
139
  end
140
140
  end
@@ -156,18 +156,18 @@ class OverridingAccessorsTest < BaseTest
156
156
  subject { SongForm.new(song) }
157
157
 
158
158
  # override reader for presentation.
159
- it { subject.title.must_equal "pray" }
159
+ it { assert_equal subject.title, "pray" }
160
160
 
161
161
  describe "#save" do
162
162
  before { subject.validate("title" => "Hey Little World") }
163
163
 
164
164
  # reader always used
165
- it { subject.title.must_equal "hey little worldhey little world" }
165
+ it { assert_equal subject.title, "hey little worldhey little world" }
166
166
 
167
167
  # the reader is not used when saving/syncing.
168
168
  it do
169
169
  subject.save do |hash|
170
- hash["title"].must_equal "Hey Little WorldHey Little World"
170
+ assert_equal hash["title"], "Hey Little WorldHey Little World"
171
171
  end
172
172
  end
173
173
 
@@ -175,7 +175,7 @@ class OverridingAccessorsTest < BaseTest
175
175
  it do
176
176
  song.extend(Saveable)
177
177
  subject.save
178
- song.title.must_equal "Hey Little WorldHey Little World"
178
+ assert_equal song.title, "Hey Little WorldHey Little World"
179
179
  end
180
180
  end
181
181
  end
@@ -199,6 +199,6 @@ class MethodInFormTest < MiniTest::Spec
199
199
 
200
200
  # methods can be used instead of created accessors.
201
201
  subject { AlbumForm.new(OpenStruct.new(hit: OpenStruct.new)) }
202
- it { subject.title.must_equal "The Suffer And The Witness" }
203
- it { subject.hit.title.must_equal "Drones" }
202
+ it { assert_equal subject.title, "The Suffer And The Witness" }
203
+ it { assert_equal subject.hit.title, "Drones" }
204
204
  end
@@ -53,9 +53,9 @@ class SaveTest < BaseTest
53
53
 
54
54
  form.save
55
55
 
56
- album.saved?.must_equal true
57
- album.songs[0].title.must_equal "Fixed"
58
- album.songs[0].saved?.must_equal true
56
+ assert album.saved?
57
+ assert_equal album.songs[0].title, "Fixed"
58
+ assert album.songs[0].saved?
59
59
  assert_nil album.artist.saved?
60
60
  end
61
61
 
@@ -70,7 +70,7 @@ class SaveTest < BaseTest
70
70
  nested_hash = hash
71
71
  end
72
72
 
73
- nested_hash.must_equal({"name" => nil, "artist" => nil})
73
+ assert_equal nested_hash, "name" => nil, "artist" => nil
74
74
  end
75
75
  end
76
76
  end