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,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
+ _(album.saved?).must_equal true
57
+ _(album.songs[0].title).must_equal "Fixed"
58
+ _(album.songs[0].saved?).must_equal true
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
+ _(nested_hash).must_equal({"name" => nil, "artist" => nil})
74
74
  end
75
75
  end
76
76
  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
+ _(album.saved?).must_equal true
57
+ _(album.songs[0].title).must_equal "Fixed"
58
+ _(album.songs[0].saved?).must_equal true
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
+ _(nested_hash).must_equal({"name" => nil, "artist" => nil})
74
74
  end
75
75
  end
76
76
  end
@@ -31,18 +31,18 @@ class SetupTest < MiniTest::Spec
31
31
  it do
32
32
  form = AlbumForm.new(album)
33
33
 
34
- form.name.must_equal "The Dissent Of Man"
35
- form.songs[0].title.must_equal "Broken"
34
+ _(form.name).must_equal "The Dissent Of Man"
35
+ _(form.songs[0].title).must_equal "Broken"
36
36
  assert_nil form.songs[0].composer
37
- form.songs[1].title.must_equal "Resist Stance"
38
- form.songs[1].composer.name.must_equal "Greg Graffin"
39
- form.artist.name.must_equal "Bad Religion"
37
+ _(form.songs[1].title).must_equal "Resist Stance"
38
+ _(form.songs[1].composer.name).must_equal "Greg Graffin"
39
+ _(form.artist.name).must_equal "Bad Religion"
40
40
 
41
41
  # make sure all is wrapped in forms.
42
- form.songs[0].must_be_kind_of Reform::Form
43
- form.songs[1].must_be_kind_of Reform::Form
44
- form.songs[1].composer.must_be_kind_of Reform::Form
45
- form.artist.must_be_kind_of Reform::Form
42
+ _(form.songs[0]).must_be_kind_of Reform::Form
43
+ _(form.songs[1]).must_be_kind_of Reform::Form
44
+ _(form.songs[1].composer).must_be_kind_of Reform::Form
45
+ _(form.artist).must_be_kind_of Reform::Form
46
46
  end
47
47
  end
48
48
  end
@@ -26,23 +26,23 @@ class SkipIfTest < BaseTest
26
26
  # deserializes when present.
27
27
  it do
28
28
  form = AlbumForm.new(album)
29
- form.validate("hit" => {"title" => "Altar Of Sacrifice"}).must_equal true
30
- form.hit.title.must_equal "Altar Of Sacrifice"
29
+ _(form.validate("hit" => {"title" => "Altar Of Sacrifice"})).must_equal true
30
+ _(form.hit.title).must_equal "Altar Of Sacrifice"
31
31
  end
32
32
 
33
33
  # skips deserialization when not present.
34
34
  it do
35
35
  form = AlbumForm.new(Album.new)
36
- form.validate("hit" => {"title" => ""}).must_equal true
36
+ _(form.validate("hit" => {"title" => ""})).must_equal true
37
37
  assert_nil form.hit # hit hasn't been deserialised.
38
38
  end
39
39
 
40
40
  # skips deserialization when not present.
41
41
  it do
42
42
  form = AlbumForm.new(Album.new(nil, nil, []))
43
- form.validate("songs" => [{"title" => "Waste Of Breath"}, {"title" => nil}]).must_equal true
44
- form.songs.size.must_equal 1
45
- form.songs[0].title.must_equal "Waste Of Breath"
43
+ _(form.validate("songs" => [{"title" => "Waste Of Breath"}, {"title" => nil}])).must_equal true
44
+ _(form.songs.size).must_equal 1
45
+ _(form.songs[0].title).must_equal "Waste Of Breath"
46
46
  end
47
47
  end
48
48
 
@@ -58,16 +58,16 @@ class SkipIfAllBlankTest < BaseTest
58
58
  # create only one object.
59
59
  it do
60
60
  form = AlbumForm.new(OpenStruct.new(songs: []))
61
- form.validate("songs" => [{"title" => "Apathy"}, {"title" => "", "length" => ""}]).must_equal true
62
- form.songs.size.must_equal 1
63
- form.songs[0].title.must_equal "Apathy"
61
+ _(form.validate("songs" => [{"title" => "Apathy"}, {"title" => "", "length" => ""}])).must_equal true
62
+ _(form.songs.size).must_equal 1
63
+ _(form.songs[0].title).must_equal "Apathy"
64
64
  end
65
65
 
66
66
  it do
67
67
  form = AlbumForm.new(OpenStruct.new(songs: []))
68
- form.validate("songs" => [{"title" => "", "length" => ""}, {"title" => "Apathy"}]).must_equal true
69
- form.songs.size.must_equal 1
70
- form.songs[0].title.must_equal "Apathy"
68
+ _(form.validate("songs" => [{"title" => "", "length" => ""}, {"title" => "Apathy"}])).must_equal true
69
+ _(form.songs.size).must_equal 1
70
+ _(form.songs[0].title).must_equal "Apathy"
71
71
  end
72
72
  end
73
73
 
@@ -26,23 +26,23 @@ class SkipIfTest < BaseTest
26
26
  # deserializes when present.
27
27
  it do
28
28
  form = AlbumForm.new(album)
29
- form.validate("hit" => {"title" => "Altar Of Sacrifice"}).must_equal true
30
- form.hit.title.must_equal "Altar Of Sacrifice"
29
+ _(form.validate("hit" => {"title" => "Altar Of Sacrifice"})).must_equal true
30
+ _(form.hit.title).must_equal "Altar Of Sacrifice"
31
31
  end
32
32
 
33
33
  # skips deserialization when not present.
34
34
  it do
35
35
  form = AlbumForm.new(Album.new)
36
- form.validate("hit" => {"title" => ""}).must_equal true
36
+ _(form.validate("hit" => {"title" => ""})).must_equal true
37
37
  assert_nil form.hit # hit hasn't been deserialised.
38
38
  end
39
39
 
40
40
  # skips deserialization when not present.
41
41
  it do
42
42
  form = AlbumForm.new(Album.new(nil, nil, []))
43
- form.validate("songs" => [{"title" => "Waste Of Breath"}, {"title" => nil}]).must_equal true
44
- form.songs.size.must_equal 1
45
- form.songs[0].title.must_equal "Waste Of Breath"
43
+ _(form.validate("songs" => [{"title" => "Waste Of Breath"}, {"title" => nil}])).must_equal true
44
+ _(form.songs.size).must_equal 1
45
+ _(form.songs[0].title).must_equal "Waste Of Breath"
46
46
  end
47
47
  end
48
48
 
@@ -58,23 +58,23 @@ class SkipIfAllBlankTest < BaseTest
58
58
  # create only one object.
59
59
  it do
60
60
  form = AlbumForm.new(OpenStruct.new(songs: []))
61
- form.validate("songs" => [{"title" => "Apathy"}, {"title" => "", "length" => ""}]).must_equal true
62
- form.songs.size.must_equal 1
63
- form.songs[0].title.must_equal "Apathy"
61
+ _(form.validate("songs" => [{"title" => "Apathy"}, {"title" => "", "length" => ""}])).must_equal true
62
+ _(form.songs.size).must_equal 1
63
+ _(form.songs[0].title).must_equal "Apathy"
64
64
  end
65
65
 
66
66
  it do
67
67
  form = AlbumForm.new(OpenStruct.new(songs: []))
68
- form.validate("songs" => [{"title" => "", "length" => ""}, {"title" => "Apathy"}]).must_equal true
69
- form.songs.size.must_equal 1
70
- form.songs[0].title.must_equal "Apathy"
68
+ _(form.validate("songs" => [{"title" => "", "length" => ""}, {"title" => "Apathy"}])).must_equal true
69
+ _(form.songs.size).must_equal 1
70
+ _(form.songs[0].title).must_equal "Apathy"
71
71
  end
72
72
 
73
73
  it do
74
74
  form = AlbumForm.new(OpenStruct.new(songs: []))
75
- form.validate(:songs => [{:title=>"", :length => ""}, {:title=>"Apathy"}]).must_equal true
76
- form.songs.size.must_equal 1
77
- form.songs[0].title.must_equal "Apathy"
75
+ _(form.validate(:songs => [{:title=>"", :length => ""}, {:title=>"Apathy"}])).must_equal true
76
+ _(form.songs.size).must_equal 1
77
+ _(form.songs[0].title).must_equal "Apathy"
78
78
  end
79
79
  end
80
80
 
@@ -37,17 +37,17 @@ class SetupSkipSetterAndGetterTest < MiniTest::Spec
37
37
  album = Album.new("Greatest Hits", artist)
38
38
  form = AlbumForm.new(album)
39
39
 
40
- form.title.must_equal "GREATEST HITS"
41
- form.artist.name.must_equal "bad religion"
40
+ _(form.title).must_equal "GREATEST HITS"
41
+ _(form.artist.name).must_equal "bad religion"
42
42
 
43
43
  form.validate("title" => "Resiststance", "artist" => {"name" => "Greg Graffin"})
44
44
 
45
- form.title.must_equal "ECNATSTSISER" # first, setter called, then getter.
46
- form.artist.name.must_equal "greg graffi"
45
+ _(form.title).must_equal "ECNATSTSISER" # first, setter called, then getter.
46
+ _(form.artist.name).must_equal "greg graffi"
47
47
 
48
48
  form.sync
49
49
 
50
- album.title.must_equal "ecnatstsiseR" # setter called, but not getter.
51
- album.artist.name.must_equal "Greg Graffi"
50
+ _(album.title).must_equal "ecnatstsiseR" # setter called, but not getter.
51
+ _(album.artist.name).must_equal "Greg Graffi"
52
52
  end
53
53
  end
@@ -40,8 +40,8 @@ class ContractValidateTest < MiniTest::Spec
40
40
 
41
41
  # valid
42
42
  it do
43
- form.validate.must_equal true
44
- form.errors.messages.inspect.must_equal "{}"
43
+ _(form.validate).must_equal true
44
+ _(form.errors.messages.inspect).must_equal "{}"
45
45
  end
46
46
 
47
47
  # invalid
@@ -49,8 +49,8 @@ class ContractValidateTest < MiniTest::Spec
49
49
  album.songs[1].composer.name = nil
50
50
  album.name = nil
51
51
 
52
- form.validate.must_equal false
53
- form.errors.messages.inspect.must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"]}"
52
+ _(form.validate).must_equal false
53
+ _(form.errors.messages.inspect).must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"]}"
54
54
  end
55
55
  end
56
56
 
@@ -100,48 +100,48 @@ class ValidateWithoutConfigurationTest < MiniTest::Spec
100
100
  artist: form.artist.object_id, composer: form.songs[1].composer.object_id
101
101
  }
102
102
 
103
- form.validate(
103
+ _(form.validate(
104
104
  "name" => "Best Of",
105
105
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => "Sting"}}],
106
106
  "artist" => {"name" => "The Police"}
107
- ).must_equal true
107
+ )).must_equal true
108
108
 
109
- form.errors.messages.inspect.must_equal "{}"
109
+ _(form.errors.messages.inspect).must_equal "{}"
110
110
 
111
111
  # form has updated.
112
- form.name.must_equal "Best Of"
113
- form.songs[0].title.must_equal "Fallout"
114
- form.songs[1].title.must_equal "Roxanne"
115
- form.songs[1].composer.name.must_equal "Sting"
116
- form.artist.name.must_equal "The Police"
112
+ _(form.name).must_equal "Best Of"
113
+ _(form.songs[0].title).must_equal "Fallout"
114
+ _(form.songs[1].title).must_equal "Roxanne"
115
+ _(form.songs[1].composer.name).must_equal "Sting"
116
+ _(form.artist.name).must_equal "The Police"
117
117
 
118
118
  # objects are still the same.
119
- form.songs[0].object_id.must_equal object_ids[:song]
120
- form.songs[1].object_id.must_equal object_ids[:song_with_composer]
121
- form.songs[1].composer.object_id.must_equal object_ids[:composer]
122
- form.artist.object_id.must_equal object_ids[:artist]
119
+ _(form.songs[0].object_id).must_equal object_ids[:song]
120
+ _(form.songs[1].object_id).must_equal object_ids[:song_with_composer]
121
+ _(form.songs[1].composer.object_id).must_equal object_ids[:composer]
122
+ _(form.artist.object_id).must_equal object_ids[:artist]
123
123
 
124
124
  # model has not changed, yet.
125
- album.name.must_equal "The Dissent Of Man"
126
- album.songs[0].title.must_equal "Broken"
127
- album.songs[1].title.must_equal "Resist Stance"
128
- album.songs[1].composer.name.must_equal "Greg Graffin"
129
- album.artist.name.must_equal "Bad Religion"
125
+ _(album.name).must_equal "The Dissent Of Man"
126
+ _(album.songs[0].title).must_equal "Broken"
127
+ _(album.songs[1].title).must_equal "Resist Stance"
128
+ _(album.songs[1].composer.name).must_equal "Greg Graffin"
129
+ _(album.artist.name).must_equal "Bad Religion"
130
130
  end
131
131
 
132
132
  # with symbols.
133
133
  it do
134
- form.validate(
134
+ _(form.validate(
135
135
  name: "Best Of",
136
136
  songs: [{title: "The X-Creep"}, {title: "Trudging", composer: {name: "SNFU"}}],
137
137
  artist: {name: "The Police"}
138
- ).must_equal true
138
+ )).must_equal true
139
139
 
140
- form.name.must_equal "Best Of"
141
- form.songs[0].title.must_equal "The X-Creep"
142
- form.songs[1].title.must_equal "Trudging"
143
- form.songs[1].composer.name.must_equal "SNFU"
144
- form.artist.name.must_equal "The Police"
140
+ _(form.name).must_equal "Best Of"
141
+ _(form.songs[0].title).must_equal "The X-Creep"
142
+ _(form.songs[1].title).must_equal "Trudging"
143
+ _(form.songs[1].composer.name).must_equal "SNFU"
144
+ _(form.artist.name).must_equal "The Police"
145
145
  end
146
146
 
147
147
  # throws exception when no populators.
@@ -201,66 +201,66 @@ class ValidateWithInternalPopulatorOptionTest < MiniTest::Spec
201
201
 
202
202
  # valid.
203
203
  it("xxx") do
204
- form.validate(
204
+ _(form.validate(
205
205
  "name" => "Best Of",
206
206
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => "Sting"}}],
207
207
  "artist" => {"name" => "The Police"},
208
- ).must_equal true
208
+ )).must_equal true
209
209
 
210
- form.errors.messages.inspect.must_equal "{}"
210
+ _(form.errors.messages.inspect).must_equal "{}"
211
211
 
212
212
  # form has updated.
213
- form.name.must_equal "Best Of"
214
- form.songs[0].title.must_equal "Fallout"
215
- form.songs[1].title.must_equal "Roxanne"
216
- form.songs[1].composer.name.must_equal "Sting"
217
- form.artist.name.must_equal "The Police"
213
+ _(form.name).must_equal "Best Of"
214
+ _(form.songs[0].title).must_equal "Fallout"
215
+ _(form.songs[1].title).must_equal "Roxanne"
216
+ _(form.songs[1].composer.name).must_equal "Sting"
217
+ _(form.artist.name).must_equal "The Police"
218
218
 
219
219
  # model has not changed, yet.
220
- album.name.must_equal "The Dissent Of Man"
221
- album.songs[0].title.must_equal "Broken"
222
- album.songs[1].title.must_equal "Resist Stance"
223
- album.songs[1].composer.name.must_equal "Greg Graffin"
224
- album.artist.name.must_equal "Bad Religion"
220
+ _(album.name).must_equal "The Dissent Of Man"
221
+ _(album.songs[0].title).must_equal "Broken"
222
+ _(album.songs[1].title).must_equal "Resist Stance"
223
+ _(album.songs[1].composer.name).must_equal "Greg Graffin"
224
+ _(album.artist.name).must_equal "Bad Religion"
225
225
  end
226
226
 
227
227
  # invalid.
228
228
  it do
229
- form.validate(
229
+ _(form.validate(
230
230
  "name" => "",
231
231
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => ""}}],
232
232
  "artist" => {"name" => ""},
233
- ).must_equal false
233
+ )).must_equal false
234
234
 
235
- form.errors.messages.inspect.must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"], :\"artist.name\"=>[\"must be filled\"]}"
235
+ _(form.errors.messages.inspect).must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"], :\"artist.name\"=>[\"must be filled\"]}"
236
236
  end
237
237
 
238
238
  # adding to collection via :instance.
239
239
  # valid.
240
240
  it do
241
- form.validate(
241
+ _(form.validate(
242
242
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"}, {"title" => "Rime Of The Ancient Mariner"}],
243
- ).must_equal true
243
+ )).must_equal true
244
244
 
245
- form.errors.messages.inspect.must_equal "{}"
245
+ _(form.errors.messages.inspect).must_equal "{}"
246
246
 
247
247
  # form has updated.
248
- form.name.must_equal "The Dissent Of Man"
249
- form.songs[0].title.must_equal "Fallout"
250
- form.songs[1].title.must_equal "Roxanne"
251
- form.songs[1].composer.name.must_equal "Greg Graffin"
252
- form.songs[1].title.must_equal "Roxanne"
253
- form.songs[2].title.must_equal "Rime Of The Ancient Mariner" # new song added.
254
- form.songs.size.must_equal 3
255
- form.artist.name.must_equal "Bad Religion"
248
+ _(form.name).must_equal "The Dissent Of Man"
249
+ _(form.songs[0].title).must_equal "Fallout"
250
+ _(form.songs[1].title).must_equal "Roxanne"
251
+ _(form.songs[1].composer.name).must_equal "Greg Graffin"
252
+ _(form.songs[1].title).must_equal "Roxanne"
253
+ _(form.songs[2].title).must_equal "Rime Of The Ancient Mariner" # new song added.
254
+ _(form.songs.size).must_equal 3
255
+ _(form.artist.name).must_equal "Bad Religion"
256
256
 
257
257
  # model has not changed, yet.
258
- album.name.must_equal "The Dissent Of Man"
259
- album.songs[0].title.must_equal "Broken"
260
- album.songs[1].title.must_equal "Resist Stance"
261
- album.songs[1].composer.name.must_equal "Greg Graffin"
262
- album.songs.size.must_equal 2
263
- album.artist.name.must_equal "Bad Religion"
258
+ _(album.name).must_equal "The Dissent Of Man"
259
+ _(album.songs[0].title).must_equal "Broken"
260
+ _(album.songs[1].title).must_equal "Resist Stance"
261
+ _(album.songs[1].composer.name).must_equal "Greg Graffin"
262
+ _(album.songs.size).must_equal 2
263
+ _(album.artist.name).must_equal "Bad Religion"
264
264
  end
265
265
 
266
266
  # allow writeable: false even in the deserializer.
@@ -274,7 +274,7 @@ class ValidateWithInternalPopulatorOptionTest < MiniTest::Spec
274
274
  assert_nil form.title
275
275
  form.title = "Unopened"
276
276
  form.sync # only the deserializer is marked as not-writeable.
277
- song.title.must_equal "Unopened"
277
+ _(song.title).must_equal "Unopened"
278
278
  end
279
279
  end
280
280
 
@@ -40,8 +40,8 @@ class ContractValidateTest < MiniTest::Spec
40
40
 
41
41
  # valid
42
42
  it do
43
- form.validate.must_equal true
44
- form.errors.messages.inspect.must_equal "{}"
43
+ _(form.validate).must_equal true
44
+ _(form.errors.messages.inspect).must_equal "{}"
45
45
  end
46
46
 
47
47
  # invalid
@@ -49,8 +49,8 @@ class ContractValidateTest < MiniTest::Spec
49
49
  album.songs[1].composer.name = nil
50
50
  album.name = nil
51
51
 
52
- form.validate.must_equal false
53
- form.errors.messages.inspect.must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"]}"
52
+ _(form.validate).must_equal false
53
+ _(form.errors.messages.inspect).must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"]}"
54
54
  end
55
55
  end
56
56
 
@@ -100,48 +100,48 @@ class ValidateWithoutConfigurationTest < MiniTest::Spec
100
100
  artist: form.artist.object_id, composer: form.songs[1].composer.object_id
101
101
  }
102
102
 
103
- form.validate(
103
+ _(form.validate(
104
104
  "name" => "Best Of",
105
105
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => "Sting"}}],
106
106
  "artist" => {"name" => "The Police"}
107
- ).must_equal true
107
+ )).must_equal true
108
108
 
109
- form.errors.messages.inspect.must_equal "{}"
109
+ _(form.errors.messages.inspect).must_equal "{}"
110
110
 
111
111
  # form has updated.
112
- form.name.must_equal "Best Of"
113
- form.songs[0].title.must_equal "Fallout"
114
- form.songs[1].title.must_equal "Roxanne"
115
- form.songs[1].composer.name.must_equal "Sting"
116
- form.artist.name.must_equal "The Police"
112
+ _(form.name).must_equal "Best Of"
113
+ _(form.songs[0].title).must_equal "Fallout"
114
+ _(form.songs[1].title).must_equal "Roxanne"
115
+ _(form.songs[1].composer.name).must_equal "Sting"
116
+ _(form.artist.name).must_equal "The Police"
117
117
 
118
118
  # objects are still the same.
119
- form.songs[0].object_id.must_equal object_ids[:song]
120
- form.songs[1].object_id.must_equal object_ids[:song_with_composer]
121
- form.songs[1].composer.object_id.must_equal object_ids[:composer]
122
- form.artist.object_id.must_equal object_ids[:artist]
119
+ _(form.songs[0].object_id).must_equal object_ids[:song]
120
+ _(form.songs[1].object_id).must_equal object_ids[:song_with_composer]
121
+ _(form.songs[1].composer.object_id).must_equal object_ids[:composer]
122
+ _(form.artist.object_id).must_equal object_ids[:artist]
123
123
 
124
124
  # model has not changed, yet.
125
- album.name.must_equal "The Dissent Of Man"
126
- album.songs[0].title.must_equal "Broken"
127
- album.songs[1].title.must_equal "Resist Stance"
128
- album.songs[1].composer.name.must_equal "Greg Graffin"
129
- album.artist.name.must_equal "Bad Religion"
125
+ _(album.name).must_equal "The Dissent Of Man"
126
+ _(album.songs[0].title).must_equal "Broken"
127
+ _(album.songs[1].title).must_equal "Resist Stance"
128
+ _(album.songs[1].composer.name).must_equal "Greg Graffin"
129
+ _(album.artist.name).must_equal "Bad Religion"
130
130
  end
131
131
 
132
132
  # with symbols.
133
133
  it do
134
- form.validate(
134
+ _(form.validate(
135
135
  name: "Best Of",
136
136
  songs: [{title: "The X-Creep"}, {title: "Trudging", composer: {name: "SNFU"}}],
137
137
  artist: {name: "The Police"}
138
- ).must_equal true
138
+ )).must_equal true
139
139
 
140
- form.name.must_equal "Best Of"
141
- form.songs[0].title.must_equal "The X-Creep"
142
- form.songs[1].title.must_equal "Trudging"
143
- form.songs[1].composer.name.must_equal "SNFU"
144
- form.artist.name.must_equal "The Police"
140
+ _(form.name).must_equal "Best Of"
141
+ _(form.songs[0].title).must_equal "The X-Creep"
142
+ _(form.songs[1].title).must_equal "Trudging"
143
+ _(form.songs[1].composer.name).must_equal "SNFU"
144
+ _(form.artist.name).must_equal "The Police"
145
145
  end
146
146
 
147
147
  # throws exception when no populators.
@@ -201,68 +201,68 @@ class ValidateWithInternalPopulatorOptionTest < MiniTest::Spec
201
201
 
202
202
  # valid.
203
203
  it("xxx") do
204
- form.validate(
204
+ _(form.validate(
205
205
  "name" => "Best Of",
206
206
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => "Sting"}}],
207
207
  "artist" => {"name" => "The Police"},
208
- ).must_equal true
209
- form.valid?.must_equal true
208
+ )).must_equal true
209
+ _(form.valid?).must_equal true
210
210
 
211
- form.errors.messages.inspect.must_equal "{}"
211
+ _(form.errors.messages.inspect).must_equal "{}"
212
212
 
213
213
  # form has updated.
214
- form.name.must_equal "Best Of"
215
- form.songs[0].title.must_equal "Fallout"
216
- form.songs[1].title.must_equal "Roxanne"
217
- form.songs[1].composer.name.must_equal "Sting"
218
- form.artist.name.must_equal "The Police"
214
+ _(form.name).must_equal "Best Of"
215
+ _(form.songs[0].title).must_equal "Fallout"
216
+ _(form.songs[1].title).must_equal "Roxanne"
217
+ _(form.songs[1].composer.name).must_equal "Sting"
218
+ _(form.artist.name).must_equal "The Police"
219
219
 
220
220
  # model has not changed, yet.
221
- album.name.must_equal "The Dissent Of Man"
222
- album.songs[0].title.must_equal "Broken"
223
- album.songs[1].title.must_equal "Resist Stance"
224
- album.songs[1].composer.name.must_equal "Greg Graffin"
225
- album.artist.name.must_equal "Bad Religion"
221
+ _(album.name).must_equal "The Dissent Of Man"
222
+ _(album.songs[0].title).must_equal "Broken"
223
+ _(album.songs[1].title).must_equal "Resist Stance"
224
+ _(album.songs[1].composer.name).must_equal "Greg Graffin"
225
+ _(album.artist.name).must_equal "Bad Religion"
226
226
  end
227
227
 
228
228
  # invalid.
229
229
  it do
230
- form.validate(
230
+ _(form.validate(
231
231
  "name" => "",
232
232
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => ""}}],
233
233
  "artist" => {"name" => ""},
234
- ).must_equal false
235
- form.valid?.must_equal false
234
+ )).must_equal false
235
+ _(form.valid?).must_equal false
236
236
 
237
- form.errors.messages.inspect.must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"], :\"artist.name\"=>[\"must be filled\"]}"
237
+ _(form.errors.messages.inspect).must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"], :\"artist.name\"=>[\"must be filled\"]}"
238
238
  end
239
239
 
240
240
  # adding to collection via :instance.
241
241
  # valid.
242
242
  it do
243
- form.validate(
243
+ _(form.validate(
244
244
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"}, {"title" => "Rime Of The Ancient Mariner"}],
245
- ).must_equal true
245
+ )).must_equal true
246
246
 
247
- form.errors.messages.inspect.must_equal "{}"
247
+ _(form.errors.messages.inspect).must_equal "{}"
248
248
 
249
249
  # form has updated.
250
- form.name.must_equal "The Dissent Of Man"
251
- form.songs[0].title.must_equal "Fallout"
252
- form.songs[1].title.must_equal "Roxanne"
253
- form.songs[1].composer.name.must_equal "Greg Graffin"
254
- form.songs[1].title.must_equal "Roxanne"
255
- form.songs[2].title.must_equal "Rime Of The Ancient Mariner" # new song added.
256
- form.songs.size.must_equal 3
257
- form.artist.name.must_equal "Bad Religion"
250
+ _(form.name).must_equal "The Dissent Of Man"
251
+ _(form.songs[0].title).must_equal "Fallout"
252
+ _(form.songs[1].title).must_equal "Roxanne"
253
+ _(form.songs[1].composer.name).must_equal "Greg Graffin"
254
+ _(form.songs[1].title).must_equal "Roxanne"
255
+ _(form.songs[2].title).must_equal "Rime Of The Ancient Mariner" # new song added.
256
+ _(form.songs.size).must_equal 3
257
+ _(form.artist.name).must_equal "Bad Religion"
258
258
 
259
259
  # model has not changed, yet.
260
- album.name.must_equal "The Dissent Of Man"
261
- album.songs[0].title.must_equal "Broken"
262
- album.songs[1].title.must_equal "Resist Stance"
263
- album.songs[1].composer.name.must_equal "Greg Graffin"
264
- album.songs.size.must_equal 2
265
- album.artist.name.must_equal "Bad Religion"
260
+ _(album.name).must_equal "The Dissent Of Man"
261
+ _(album.songs[0].title).must_equal "Broken"
262
+ _(album.songs[1].title).must_equal "Resist Stance"
263
+ _(album.songs[1].composer.name).must_equal "Greg Graffin"
264
+ _(album.songs.size).must_equal 2
265
+ _(album.artist.name).must_equal "Bad Religion"
266
266
  end
267
267
 
268
268
  # allow writeable: false even in the deserializer.
@@ -276,7 +276,7 @@ class ValidateWithInternalPopulatorOptionTest < MiniTest::Spec
276
276
  assert_nil form.title
277
277
  form.title = "Unopened"
278
278
  form.sync # only the deserializer is marked as not-writeable.
279
- song.title.must_equal "Unopened"
279
+ _(song.title).must_equal "Unopened"
280
280
  end
281
281
  end
282
282