reform 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/reform/form/dry/new_api.rb +2 -4
- data/lib/reform/version.rb +1 -1
- data/test/call_new_api.rb +6 -6
- data/test/call_old_api.rb +6 -6
- data/test/changed_test.rb +6 -6
- data/test/coercion_test.rb +13 -13
- data/test/composition_new_api.rb +24 -24
- data/test/composition_old_api.rb +24 -24
- data/test/contract_new_api.rb +8 -8
- data/test/contract_old_api.rb +8 -8
- data/test/default_test.rb +2 -2
- data/test/deserialize_test.rb +8 -8
- data/test/errors_new_api.rb +38 -38
- data/test/errors_old_api.rb +38 -38
- data/test/feature_test.rb +2 -2
- data/test/form_new_api.rb +3 -3
- data/test/form_old_api.rb +3 -3
- data/test/form_option_new_api.rb +1 -1
- data/test/form_option_old_api.rb +1 -1
- data/test/from_test.rb +10 -10
- data/test/inherit_new_api.rb +17 -17
- data/test/inherit_old_api.rb +17 -17
- data/test/module_new_api.rb +8 -8
- data/test/module_old_api.rb +9 -9
- data/test/parse_option_test.rb +7 -7
- data/test/parse_pipeline_test.rb +1 -1
- data/test/populate_new_api.rb +53 -53
- data/test/populate_old_api.rb +53 -53
- data/test/populator_skip_test.rb +2 -2
- data/test/prepopulator_test.rb +15 -15
- data/test/read_only_test.rb +2 -2
- data/test/readable_test.rb +3 -3
- data/test/reform_new_api.rb +19 -19
- data/test/reform_old_api.rb +19 -19
- data/test/save_new_api.rb +4 -4
- data/test/save_old_api.rb +4 -4
- data/test/setup_test.rb +9 -9
- data/test/skip_if_new_api.rb +12 -12
- data/test/skip_if_old_api.rb +15 -15
- data/test/skip_setter_and_getter_test.rb +6 -6
- data/test/validate_new_api.rb +62 -62
- data/test/validate_old_api.rb +64 -64
- data/test/validation/dry_validation_new_api.rb +115 -116
- data/test/validation/dry_validation_old_api.rb +105 -105
- data/test/validation/result_test.rb +14 -14
- data/test/virtual_test.rb +7 -7
- data/test/writeable_test.rb +8 -8
- metadata +2 -2
data/test/populate_old_api.rb
CHANGED
@@ -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
|
+
_(form.name).must_equal "!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
|
+
_(form.artist.model.object_id).must_equal 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
|
+
_(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
|
+
)).must_equal true
|
76
76
|
|
77
|
-
form.errors.messages.inspect.must_equal "{}"
|
77
|
+
_(form.errors.messages.inspect).must_equal "{}"
|
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
|
+
_(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"
|
84
84
|
|
85
|
-
form.songs[1].composer.model.must_be_instance_of Artist
|
85
|
+
_(form.songs[1].composer.model).must_be_instance_of 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
|
+
_(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"
|
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
|
+
_(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"
|
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
|
+
_(form.title).must_equal "!em edirrevo"
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -141,7 +141,7 @@ class PopulateWithCallableTest < Minitest::Spec
|
|
141
141
|
it "runs populator method" do
|
142
142
|
form.validate("title" => "override me!")
|
143
143
|
|
144
|
-
form.title.must_equal "!em edirrevo"
|
144
|
+
_(form.title).must_equal "!em edirrevo"
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -161,7 +161,7 @@ class PopulateWithProcTest < Minitest::Spec
|
|
161
161
|
it "runs populator method" do
|
162
162
|
form.validate("title" => "override me!")
|
163
163
|
|
164
|
-
form.title.must_equal "!em edirrevo"
|
164
|
+
_(form.title).must_equal "!em edirrevo"
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
@@ -216,35 +216,35 @@ class PopulateIfEmptyTest < MiniTest::Spec
|
|
216
216
|
let(:form) { AlbumForm.new(album) }
|
217
217
|
|
218
218
|
it do
|
219
|
-
form.songs.size.must_equal 2
|
219
|
+
_(form.songs.size).must_equal 2
|
220
220
|
|
221
|
-
form.validate(
|
221
|
+
_(form.validate(
|
222
222
|
"songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"},
|
223
223
|
{"title" => "Rime Of The Ancient Mariner"}, # new song.
|
224
224
|
{"title" => "Re-Education", "composer" => {"name" => "Rise Against"}}], # new song with new composer.
|
225
|
-
).must_equal true
|
225
|
+
)).must_equal true
|
226
226
|
|
227
|
-
form.errors.messages.inspect.must_equal "{}"
|
227
|
+
_(form.errors.messages.inspect).must_equal "{}"
|
228
228
|
|
229
229
|
# 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"
|
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"
|
240
240
|
|
241
241
|
# 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"
|
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"
|
248
248
|
end
|
249
249
|
|
250
250
|
# trigger artist populator. lambda calling form instance method.
|
@@ -252,11 +252,11 @@ class PopulateIfEmptyTest < MiniTest::Spec
|
|
252
252
|
form = AlbumForm.new(album = Album.new)
|
253
253
|
form.validate("artist" => {"name" => "From Autumn To Ashes"})
|
254
254
|
|
255
|
-
form.artist.name.must_equal "From Autumn To Ashes"
|
255
|
+
_(form.artist.name).must_equal "From Autumn To Ashes"
|
256
256
|
# test lambda was executed in form context.
|
257
|
-
form.artist.model.must_be_instance_of AlbumForm::Sting
|
257
|
+
_(form.artist.model).must_be_instance_of AlbumForm::Sting
|
258
258
|
# test lambda block arguments.
|
259
|
-
form.artist.model.args.to_s.must_equal "[{\"name\"=>\"From Autumn To Ashes\"}, nil]"
|
259
|
+
_(form.artist.model.args.to_s).must_equal "[{\"name\"=>\"From Autumn To Ashes\"}, nil]"
|
260
260
|
|
261
261
|
assert_nil album.artist
|
262
262
|
end
|
@@ -292,13 +292,13 @@ class PopulateIfEmptyWithDeletionTest < MiniTest::Spec
|
|
292
292
|
let(:form) { AlbumForm.new(album) }
|
293
293
|
|
294
294
|
it do
|
295
|
-
form.validate(
|
295
|
+
_(form.validate(
|
296
296
|
"songs" => [{"title" => "Broken, delete me!"}, {"title" => "Roxanne"}]
|
297
|
-
).must_equal true
|
297
|
+
)).must_equal true
|
298
298
|
|
299
|
-
form.errors.messages.inspect.must_equal "{}"
|
299
|
+
_(form.errors.messages.inspect).must_equal "{}"
|
300
300
|
|
301
|
-
form.songs.size.must_equal 1
|
302
|
-
form.songs[0].title.must_equal "Roxanne"
|
301
|
+
_(form.songs.size).must_equal 1
|
302
|
+
_(form.songs[0].title).must_equal "Roxanne"
|
303
303
|
end
|
304
304
|
end
|
data/test/populator_skip_test.rb
CHANGED
@@ -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
|
+
_(form.songs.size).must_equal 2
|
25
25
|
assert_nil form.songs[0].title
|
26
|
-
form.songs[1].title.must_equal "Bad"
|
26
|
+
_(form.songs[1].title).must_equal "Bad"
|
27
27
|
end
|
28
28
|
end
|
data/test/prepopulator_test.rb
CHANGED
@@ -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
|
+
_(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
|
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
|
+
_(form.hit.band.model).must_equal Band.new("Potemkin City Limits")
|
50
50
|
end
|
51
51
|
|
52
52
|
# add to existing collection.
|
53
53
|
it do
|
54
54
|
form = AlbumForm.new(OpenStruct.new(songs: [Song.new])).prepopulate!
|
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
|
+
_(form.songs.size).must_equal 2
|
57
|
+
_(form.songs[0].model).must_equal Song.new
|
58
|
+
_(form.songs[1].model).must_equal 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 { _(subject.songs.size).must_equal 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
|
+
_(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"
|
110
110
|
end
|
111
111
|
end
|
data/test/read_only_test.rb
CHANGED
@@ -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 { _(form.readonly?(:artist)).must_equal false }
|
13
|
+
it { _(form.readonly?(:title)).must_equal true }
|
14
14
|
end
|
data/test/readable_test.rb
CHANGED
@@ -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
|
+
_(form.password).must_equal "123"
|
19
19
|
|
20
20
|
form.sync
|
21
|
-
cred.password.must_equal "123" # password written.
|
21
|
+
_(cred.password).must_equal "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
|
+
_(hash).must_equal("password" => "123")
|
29
29
|
}
|
30
30
|
end
|
data/test/reform_new_api.rb
CHANGED
@@ -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
|
+
_(form.name).must_be_nil
|
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
|
+
_(form.name).must_equal "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
|
+
_(form.name).must_equal "Duran Duran"
|
38
|
+
_(form.title).must_equal "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
|
+
_(form.validate("name" => "Duran Duran")).must_equal 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
|
+
_(form.name).must_equal "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
|
+
_(form.validate({})).must_equal 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
|
+
_(form.errors.messages).must_equal(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
|
+
_(comp.name).must_equal "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
|
+
_(hash).must_equal("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 { _(form.model).must_equal 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
|
+
_(form.title).must_equal "The Body"
|
136
136
|
assert_nil form.position
|
137
|
-
form.errors.messages.must_equal(name: ["must be filled"], position: ["must be filled"])
|
137
|
+
_(form.errors.messages).must_equal(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 { _(subject.title).must_equal "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 { _(subject.title).must_equal "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
|
+
_(hash["title"]).must_equal "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
|
+
_(song.title).must_equal "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 { _(subject.title).must_equal "The Suffer And The Witness" }
|
203
|
+
it { _(subject.hit.title).must_equal "Drones" }
|
204
204
|
end
|
data/test/reform_old_api.rb
CHANGED
@@ -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
|
+
_(form.name).must_be_nil
|
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
|
+
_(form.name).must_equal "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
|
+
_(form.name).must_equal "Duran Duran"
|
38
|
+
_(form.title).must_equal "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
|
+
_(form.validate("name" => "Duran Duran")).must_equal 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
|
+
_(form.name).must_equal "Duran Duran"
|
60
60
|
end
|
61
61
|
|
62
62
|
it "doesn't change model properties" do
|
@@ -79,12 +79,12 @@ class ReformTest < Minitest::Spec
|
|
79
79
|
let(:form) { ValidatingForm.new(comp) }
|
80
80
|
|
81
81
|
it "returns false when invalid" do
|
82
|
-
form.validate({}).must_equal false
|
82
|
+
_(form.validate({})).must_equal false
|
83
83
|
end
|
84
84
|
|
85
85
|
it "populates errors" do
|
86
86
|
form.validate({})
|
87
|
-
form.errors.messages.must_equal({name: ["must be filled"], title: ["must be filled"]})
|
87
|
+
_(form.errors.messages).must_equal({name: ["must be filled"], title: ["must be filled"]})
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -98,7 +98,7 @@ class ReformTest < Minitest::Spec
|
|
98
98
|
it "xxpushes data to models" do
|
99
99
|
form.save
|
100
100
|
|
101
|
-
comp.name.must_equal "Diesel Boy"
|
101
|
+
_(comp.name).must_equal "Diesel Boy"
|
102
102
|
assert_nil comp.title
|
103
103
|
end
|
104
104
|
|
@@ -110,13 +110,13 @@ class ReformTest < Minitest::Spec
|
|
110
110
|
hash = map
|
111
111
|
end
|
112
112
|
|
113
|
-
hash.must_equal({"name" => "Diesel Boy", "title" => nil})
|
113
|
+
_(hash).must_equal({"name" => "Diesel Boy", "title" => nil})
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
describe "#model" do
|
119
|
-
it { form.model.must_equal comp }
|
119
|
+
it { _(form.model).must_equal comp }
|
120
120
|
end
|
121
121
|
|
122
122
|
describe "inheritance" do
|
@@ -130,9 +130,9 @@ class ReformTest < Minitest::Spec
|
|
130
130
|
let(:form) { HitForm.new(OpenStruct.new()) }
|
131
131
|
it do
|
132
132
|
form.validate({"title" => "The Body"})
|
133
|
-
form.title.must_equal "The Body"
|
133
|
+
_(form.title).must_equal "The Body"
|
134
134
|
assert_nil form.position
|
135
|
-
form.errors.messages.must_equal({name: ["must be filled"], position: ["must be filled"]})
|
135
|
+
_(form.errors.messages).must_equal({name: ["must be filled"], position: ["must be filled"]})
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -154,18 +154,18 @@ class OverridingAccessorsTest < BaseTest
|
|
154
154
|
subject { SongForm.new(song) }
|
155
155
|
|
156
156
|
# override reader for presentation.
|
157
|
-
it { subject.title.must_equal "pray" }
|
157
|
+
it { _(subject.title).must_equal "pray" }
|
158
158
|
|
159
159
|
describe "#save" do
|
160
160
|
before { subject.validate("title" => "Hey Little World") }
|
161
161
|
|
162
162
|
# reader always used
|
163
|
-
it { subject.title.must_equal "hey little worldhey little world" }
|
163
|
+
it { _(subject.title).must_equal "hey little worldhey little world" }
|
164
164
|
|
165
165
|
# the reader is not used when saving/syncing.
|
166
166
|
it do
|
167
167
|
subject.save do |hash|
|
168
|
-
hash["title"].must_equal "Hey Little WorldHey Little World"
|
168
|
+
_(hash["title"]).must_equal "Hey Little WorldHey Little World"
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -173,7 +173,7 @@ class OverridingAccessorsTest < BaseTest
|
|
173
173
|
it do
|
174
174
|
song.extend(Saveable)
|
175
175
|
subject.save
|
176
|
-
song.title.must_equal "Hey Little WorldHey Little World"
|
176
|
+
_(song.title).must_equal "Hey Little WorldHey Little World"
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
@@ -197,6 +197,6 @@ class MethodInFormTest < MiniTest::Spec
|
|
197
197
|
|
198
198
|
# methods can be used instead of created accessors.
|
199
199
|
subject { AlbumForm.new(OpenStruct.new(hit: OpenStruct.new)) }
|
200
|
-
it { subject.title.must_equal "The Suffer And The Witness" }
|
201
|
-
it { subject.hit.title.must_equal "Drones" }
|
200
|
+
it { _(subject.title).must_equal "The Suffer And The Witness" }
|
201
|
+
it { _(subject.hit.title).must_equal "Drones" }
|
202
202
|
end
|