reform 2.2.4 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +17 -0
  3. data/.gitignore +5 -1
  4. data/CHANGES.md +80 -4
  5. data/CONTRIBUTING.md +31 -0
  6. data/Gemfile +2 -16
  7. data/ISSUE_TEMPLATE.md +25 -0
  8. data/LICENSE.txt +1 -1
  9. data/README.md +10 -12
  10. data/Rakefile +6 -10
  11. data/lib/reform/contract/custom_error.rb +41 -0
  12. data/lib/reform/contract/validate.rb +53 -23
  13. data/lib/reform/contract.rb +7 -17
  14. data/lib/reform/errors.rb +61 -0
  15. data/lib/reform/form/call.rb +1 -1
  16. data/lib/reform/form/composition.rb +2 -2
  17. data/lib/reform/form/dry/input_hash.rb +37 -0
  18. data/lib/reform/form/dry.rb +25 -35
  19. data/lib/reform/form/populator.rb +20 -26
  20. data/lib/reform/form/prepopulate.rb +5 -4
  21. data/lib/reform/form/validate.rb +29 -14
  22. data/lib/reform/form.rb +36 -10
  23. data/lib/reform/result.rb +90 -0
  24. data/lib/reform/validation/groups.rb +12 -28
  25. data/lib/reform/validation.rb +19 -11
  26. data/lib/reform/version.rb +1 -1
  27. data/lib/reform.rb +1 -0
  28. data/reform.gemspec +13 -13
  29. data/test/benchmarking.rb +39 -6
  30. data/test/call_test.rb +9 -9
  31. data/test/changed_test.rb +14 -14
  32. data/test/coercion_test.rb +57 -25
  33. data/test/composition_test.rb +85 -49
  34. data/test/contract/custom_error_test.rb +55 -0
  35. data/test/contract_test.rb +20 -20
  36. data/test/default_test.rb +4 -4
  37. data/test/deserialize_test.rb +17 -20
  38. data/test/docs/validation_test.rb +134 -0
  39. data/test/errors_test.rb +142 -82
  40. data/test/feature_test.rb +10 -12
  41. data/test/fixtures/dry_error_messages.yml +83 -23
  42. data/test/form_option_test.rb +5 -5
  43. data/test/form_test.rb +8 -8
  44. data/test/from_test.rb +18 -22
  45. data/test/inherit_test.rb +54 -68
  46. data/test/module_test.rb +27 -32
  47. data/test/parse_option_test.rb +40 -0
  48. data/test/parse_pipeline_test.rb +4 -4
  49. data/test/populate_test.rb +217 -100
  50. data/test/populator_skip_test.rb +11 -11
  51. data/test/prepopulator_test.rb +24 -25
  52. data/test/read_only_test.rb +12 -1
  53. data/test/readable_test.rb +9 -9
  54. data/test/reform_test.rb +47 -66
  55. data/test/save_test.rb +35 -23
  56. data/test/setup_test.rb +17 -17
  57. data/test/skip_if_test.rb +33 -22
  58. data/test/skip_setter_and_getter_test.rb +9 -10
  59. data/test/test_helper.rb +23 -14
  60. data/test/validate_test.rb +165 -145
  61. data/test/validation/dry_validation_test.rb +630 -146
  62. data/test/validation/result_test.rb +77 -0
  63. data/test/validation_library_provided_test.rb +16 -0
  64. data/test/virtual_test.rb +47 -7
  65. data/test/writeable_test.rb +38 -9
  66. metadata +46 -38
  67. data/.travis.yml +0 -11
  68. data/gemfiles/Gemfile.disposable-0.3 +0 -6
  69. data/lib/reform/contract/errors.rb +0 -43
  70. data/lib/reform/form/mongoid.rb +0 -37
  71. data/lib/reform/form/orm.rb +0 -26
  72. data/lib/reform/mongoid.rb +0 -4
  73. data/test/deprecation_test.rb +0 -27
  74. data/test/readonly_test.rb +0 -14
  75. data/test/validation/dry_test.rb +0 -60
  76. data/test/validation/errors.yml +0 -4
@@ -1,25 +1,21 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class ContractValidateTest < MiniTest::Spec
4
- Song = Struct.new(:title, :album, :composer)
5
- Album = Struct.new(:name, :songs, :artist)
6
- Artist = Struct.new(:name)
7
-
8
- class AlbumForm < Reform::Contract
4
+ class AlbumForm < TestContract
9
5
  property :name
10
6
  validation do
11
- key(:name).required
7
+ params { required(:name).filled }
12
8
  end
13
9
 
14
10
  collection :songs do
15
11
  property :title
16
12
  validation do
17
- key(:title).required
13
+ params { required(:title).filled }
18
14
  end
19
15
 
20
16
  property :composer do
21
17
  validation do
22
- key(:name).required
18
+ params { required(:name).filled }
23
19
  end
24
20
  property :name
25
21
  end
@@ -30,18 +26,18 @@ class ContractValidateTest < MiniTest::Spec
30
26
  end
31
27
  end
32
28
 
33
- let (:song) { Song.new("Broken") }
34
- let (:song_with_composer) { Song.new("Resist Stance", nil, composer) }
35
- let (:composer) { Artist.new("Greg Graffin") }
36
- let (:artist) { Artist.new("Bad Religion") }
37
- let (:album) { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }
29
+ let(:song) { Song.new("Broken") }
30
+ let(:song_with_composer) { Song.new("Resist Stance", nil, composer) }
31
+ let(:composer) { Artist.new("Greg Graffin") }
32
+ let(:artist) { Artist.new("Bad Religion") }
33
+ let(:album) { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }
38
34
 
39
- let (:form) { AlbumForm.new(album) }
35
+ let(:form) { AlbumForm.new(album) }
40
36
 
41
37
  # valid
42
38
  it do
43
- form.validate.must_equal true
44
- form.errors.messages.inspect.must_equal "{}"
39
+ assert form.validate
40
+ assert_equal form.errors.messages.inspect, "{}"
45
41
  end
46
42
 
47
43
  # invalid
@@ -49,35 +45,29 @@ class ContractValidateTest < MiniTest::Spec
49
45
  album.songs[1].composer.name = nil
50
46
  album.name = nil
51
47
 
52
- form.validate.must_equal false
53
- form.errors.messages.inspect.must_equal "{:name=>[\"is missing\"], :\"songs.composer.name\"=>[\"is missing\"]}"
48
+ assert_equal form.validate, false
49
+ assert_equal form.errors.messages.inspect, "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"]}"
54
50
  end
55
51
  end
56
52
 
57
-
58
53
  # no configuration results in "sync" (formerly known as parse_strategy: :sync).
59
54
  class ValidateWithoutConfigurationTest < MiniTest::Spec
60
- Song = Struct.new(:title, :album, :composer)
61
- Album = Struct.new(:name, :songs, :artist)
62
- Artist = Struct.new(:name)
63
-
64
- class AlbumForm < Reform::Form
55
+ class AlbumForm < TestForm
65
56
  property :name
66
57
  validation do
67
- key(:name).required
58
+ params { required(:name).filled }
68
59
  end
69
60
 
70
61
  collection :songs do
71
-
72
62
  property :title
73
63
  validation do
74
- key(:title).required
64
+ params { required(:title).filled }
75
65
  end
76
66
 
77
67
  property :composer do
78
68
  property :name
79
69
  validation do
80
- key(:name).required
70
+ params { required(:name).filled }
81
71
  end
82
72
  end
83
73
  end
@@ -87,62 +77,63 @@ class ValidateWithoutConfigurationTest < MiniTest::Spec
87
77
  end
88
78
  end
89
79
 
90
- let (:song) { Song.new("Broken") }
91
- let (:song_with_composer) { Song.new("Resist Stance", nil, composer) }
92
- let (:composer) { Artist.new("Greg Graffin") }
93
- let (:artist) { Artist.new("Bad Religion") }
94
- let (:album) { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }
80
+ let(:song) { Song.new("Broken") }
81
+ let(:song_with_composer) { Song.new("Resist Stance", nil, composer) }
82
+ let(:composer) { Artist.new("Greg Graffin") }
83
+ let(:artist) { Artist.new("Bad Religion") }
84
+ let(:album) { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }
95
85
 
96
- let (:form) { AlbumForm.new(album) }
86
+ let(:form) { AlbumForm.new(album) }
97
87
 
98
88
  # valid.
99
89
  it do
100
- object_ids = {song: form.songs[0].object_id, song_with_composer: form.songs[1].object_id,
101
- artist: form.artist.object_id, composer: form.songs[1].composer.object_id}
90
+ object_ids = {
91
+ song: form.songs[0].object_id, song_with_composer: form.songs[1].object_id,
92
+ artist: form.artist.object_id, composer: form.songs[1].composer.object_id
93
+ }
102
94
 
103
- form.validate(
95
+ assert form.validate(
104
96
  "name" => "Best Of",
105
97
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => "Sting"}}],
106
- "artist" => {"name" => "The Police"},
107
- ).must_equal true
98
+ "artist" => {"name" => "The Police"}
99
+ )
108
100
 
109
- form.errors.messages.inspect.must_equal "{}"
101
+ assert_equal form.errors.messages.inspect, "{}"
110
102
 
111
103
  # 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"
104
+ assert_equal form.name, "Best Of"
105
+ assert_equal form.songs[0].title, "Fallout"
106
+ assert_equal form.songs[1].title, "Roxanne"
107
+ assert_equal form.songs[1].composer.name, "Sting"
108
+ assert_equal form.artist.name, "The Police"
117
109
 
118
110
  # 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]
123
-
111
+ assert_equal form.songs[0].object_id, object_ids[:song]
112
+ assert_equal form.songs[1].object_id, object_ids[:song_with_composer]
113
+ assert_equal form.songs[1].composer.object_id, object_ids[:composer]
114
+ assert_equal form.artist.object_id, object_ids[:artist]
124
115
 
125
116
  # model has not changed, yet.
126
- album.name.must_equal "The Dissent Of Man"
127
- album.songs[0].title.must_equal "Broken"
128
- album.songs[1].title.must_equal "Resist Stance"
129
- album.songs[1].composer.name.must_equal "Greg Graffin"
130
- album.artist.name.must_equal "Bad Religion"
117
+ assert_equal album.name, "The Dissent Of Man"
118
+ assert_equal album.songs[0].title, "Broken"
119
+ assert_equal album.songs[1].title, "Resist Stance"
120
+ assert_equal album.songs[1].composer.name, "Greg Graffin"
121
+ assert_equal album.artist.name, "Bad Religion"
131
122
  end
132
123
 
133
124
  # with symbols.
134
125
  it do
135
- form.validate(
126
+ assert form.validate(
136
127
  name: "Best Of",
137
128
  songs: [{title: "The X-Creep"}, {title: "Trudging", composer: {name: "SNFU"}}],
138
- artist: {name: "The Police"},
139
- ).must_equal true
140
-
141
- form.name.must_equal "Best Of"
142
- form.songs[0].title.must_equal "The X-Creep"
143
- form.songs[1].title.must_equal "Trudging"
144
- form.songs[1].composer.name.must_equal "SNFU"
145
- form.artist.name.must_equal "The Police"
129
+ artist: {name: "The Police"}
130
+ )
131
+
132
+ assert_equal form.name, "Best Of"
133
+ assert_equal form.songs[0].title, "The X-Creep"
134
+ assert_equal form.songs[1].title, "Trudging"
135
+ assert_equal form.songs[1].composer.name, "SNFU"
136
+ assert_equal form.artist.name, "The Police"
146
137
  end
147
138
 
148
139
  # throws exception when no populators.
@@ -156,135 +147,172 @@ class ValidateWithoutConfigurationTest < MiniTest::Spec
156
147
  end
157
148
 
158
149
  class ValidateWithInternalPopulatorOptionTest < MiniTest::Spec
159
- Song = Struct.new(:title, :album, :composer)
160
- Album = Struct.new(:name, :songs, :artist)
161
- Artist = Struct.new(:name)
162
-
163
- class AlbumForm < Reform::Form
150
+ class AlbumForm < TestForm
164
151
  property :name
165
152
  validation do
166
- key(:name).required
153
+ params { required(:name).filled }
167
154
  end
168
155
 
169
156
  collection :songs,
170
- internal_populator: lambda { |input, options|
171
- collection = options[:represented].songs
172
- (item = collection[options[:index]]) ? item : collection.insert(options[:index], Song.new) } do
173
-
157
+ internal_populator: ->(input, options) {
158
+ collection = options[:represented].songs
159
+ (item = collection[options[:index]]) ? item : collection.insert(options[:index], Song.new)
160
+ } do
174
161
  property :title
175
162
  validation do
176
- key(:title).required
163
+ params { required(:title).filled }
177
164
  end
178
165
 
179
- property :composer, internal_populator: lambda { |input, options| (item = options[:represented].composer) ? item : Artist.new } do
166
+ property :composer, internal_populator: ->(input, options) { (item = options[:represented].composer) ? item : Artist.new } do
180
167
  property :name
181
168
  validation do
182
- key(:name).required
169
+ params { required(:name).filled }
183
170
  end
184
171
  end
185
172
  end
186
173
 
187
- property :artist, internal_populator: lambda { |input, options| (item = options[:represented].artist) ? item : Artist.new } do
174
+ property :artist, internal_populator: ->(input, options) { (item = options[:represented].artist) ? item : Artist.new } do
188
175
  property :name
189
176
  validation do
190
- key(:name).required
177
+ params { required(:name).filled }
191
178
  end
192
179
  end
193
180
  end
194
181
 
195
- let (:song) { Song.new("Broken") }
196
- let (:song_with_composer) { Song.new("Resist Stance", nil, composer) }
197
- let (:composer) { Artist.new("Greg Graffin") }
198
- let (:artist) { Artist.new("Bad Religion") }
199
- let (:album) { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }
182
+ let(:song) { Song.new("Broken") }
183
+ let(:song_with_composer) { Song.new("Resist Stance", nil, composer) }
184
+ let(:composer) { Artist.new("Greg Graffin") }
185
+ let(:artist) { Artist.new("Bad Religion") }
186
+ let(:album) { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }
200
187
 
201
- let (:form) { AlbumForm.new(album) }
188
+ let(:form) { AlbumForm.new(album) }
202
189
 
203
190
  # valid.
204
191
  it("xxx") do
205
- form.validate(
192
+ assert form.validate(
206
193
  "name" => "Best Of",
207
194
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => "Sting"}}],
208
- "artist" => {"name" => "The Police"},
209
- ).must_equal true
195
+ "artist" => {"name" => "The Police"}
196
+ )
210
197
 
211
- form.errors.messages.inspect.must_equal "{}"
198
+ assert_equal form.errors.messages.inspect, "{}"
212
199
 
213
200
  # 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"
219
-
201
+ assert_equal form.name, "Best Of"
202
+ assert_equal form.songs[0].title, "Fallout"
203
+ assert_equal form.songs[1].title, "Roxanne"
204
+ assert_equal form.songs[1].composer.name, "Sting"
205
+ assert_equal form.artist.name, "The Police"
220
206
 
221
207
  # model has not changed, yet.
222
- album.name.must_equal "The Dissent Of Man"
223
- album.songs[0].title.must_equal "Broken"
224
- album.songs[1].title.must_equal "Resist Stance"
225
- album.songs[1].composer.name.must_equal "Greg Graffin"
226
- album.artist.name.must_equal "Bad Religion"
208
+ assert_equal album.name, "The Dissent Of Man"
209
+ assert_equal album.songs[0].title, "Broken"
210
+ assert_equal album.songs[1].title, "Resist Stance"
211
+ assert_equal album.songs[1].composer.name, "Greg Graffin"
212
+ assert_equal album.artist.name, "Bad Religion"
227
213
  end
228
214
 
229
215
  # invalid.
230
216
  it do
231
- form.validate(
217
+ assert_equal form.validate(
232
218
  "name" => "",
233
219
  "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne", "composer" => {"name" => ""}}],
234
220
  "artist" => {"name" => ""},
235
- ).must_equal false
221
+ ), false
236
222
 
237
- form.errors.messages.inspect.must_equal "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"], :\"artist.name\"=>[\"must be filled\"]}"
223
+ assert_equal form.errors.messages.inspect, "{:name=>[\"must be filled\"], :\"songs.composer.name\"=>[\"must be filled\"], :\"artist.name\"=>[\"must be filled\"]}"
238
224
  end
239
225
 
240
226
  # adding to collection via :instance.
241
227
  # valid.
242
228
  it do
243
- form.validate(
244
- "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"}, {"title" => "Rime Of The Ancient Mariner"}],
245
- ).must_equal true
229
+ assert form.validate(
230
+ "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"}, {"title" => "Rime Of The Ancient Mariner"}]
231
+ )
246
232
 
247
- form.errors.messages.inspect.must_equal "{}"
233
+ assert_equal form.errors.messages.inspect, "{}"
248
234
 
249
235
  # 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"
258
-
236
+ assert_equal form.name, "The Dissent Of Man"
237
+ assert_equal form.songs[0].title, "Fallout"
238
+ assert_equal form.songs[1].title, "Roxanne"
239
+ assert_equal form.songs[1].composer.name, "Greg Graffin"
240
+ assert_equal form.songs[1].title, "Roxanne"
241
+ assert_equal form.songs[2].title, "Rime Of The Ancient Mariner" # new song added.
242
+ assert_equal form.songs.size, 3
243
+ assert_equal form.artist.name, "Bad Religion"
259
244
 
260
245
  # model has not changed, yet.
261
- album.name.must_equal "The Dissent Of Man"
262
- album.songs[0].title.must_equal "Broken"
263
- album.songs[1].title.must_equal "Resist Stance"
264
- album.songs[1].composer.name.must_equal "Greg Graffin"
265
- album.songs.size.must_equal 2
266
- album.artist.name.must_equal "Bad Religion"
246
+ assert_equal album.name, "The Dissent Of Man"
247
+ assert_equal album.songs[0].title, "Broken"
248
+ assert_equal album.songs[1].title, "Resist Stance"
249
+ assert_equal album.songs[1].composer.name, "Greg Graffin"
250
+ assert_equal album.songs.size, 2
251
+ assert_equal album.artist.name, "Bad Religion"
267
252
  end
268
253
 
269
-
270
254
  # allow writeable: false even in the deserializer.
271
- class SongForm < Reform::Form
255
+ class SongForm < TestForm
272
256
  property :title, deserializer: {writeable: false}
273
257
  end
274
258
 
275
259
  it do
276
260
  form = SongForm.new(song = Song.new)
277
261
  form.validate("title" => "Ignore me!")
278
- form.title.must_equal nil
262
+ assert_nil form.title
279
263
  form.title = "Unopened"
280
264
  form.sync # only the deserializer is marked as not-writeable.
281
- song.title.must_equal "Unopened"
265
+ assert_equal song.title, "Unopened"
282
266
  end
283
267
  end
284
268
 
285
- # # not sure if we should catch that in Reform or rather do that in disposable. this is https://github.com/apotonick/reform/pull/104
269
+ # memory leak test
270
+ class ValidateUsingDifferentFormObject < MiniTest::Spec
271
+ class AlbumForm < TestForm
272
+ property :name
273
+
274
+ validation do
275
+ option :form
276
+
277
+ params { required(:name).filled(:str?) }
278
+
279
+ rule(:name) do
280
+ if form.name == 'invalid'
281
+ key.failure('Invalid name')
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+ let(:album) { Album.new }
288
+
289
+ let(:form) { AlbumForm.new(album) }
290
+
291
+ it 'sets name correctly' do
292
+ assert form.validate(name: 'valid')
293
+ form.sync
294
+ assert_equal form.model.name, 'valid'
295
+ end
296
+
297
+ it 'validates presence of name' do
298
+ refute form.validate(name: nil)
299
+ assert_equal form.errors[:name], ["must be filled"]
300
+ end
301
+
302
+ it 'validates type of name' do
303
+ refute form.validate(name: 1)
304
+ assert_equal form.errors[:name], ["must be a string"]
305
+ end
306
+
307
+ it 'when name is invalid' do
308
+ refute form.validate(name: 'invalid')
309
+ assert_equal form.errors[:name], ["Invalid name"]
310
+ end
311
+ end
312
+
313
+ # # not sure if we should catch that in Reform or rather do that in disposable. this is https://github.com/trailblazer/reform/pull/104
286
314
  # # describe ":populator with :empty" do
287
- # # let (:form) {
315
+ # # let(:form) {
288
316
  # # Class.new(Reform::Form) do
289
317
  # # collection :songs, :empty => true, :populator => lambda { |fragment, index, args|
290
318
  # # songs[index] = args.binding[:form].new(Song.new)
@@ -294,7 +322,7 @@ end
294
322
  # # end
295
323
  # # }
296
324
 
297
- # # let (:params) {
325
+ # # let(:params) {
298
326
  # # {
299
327
  # # "songs" => [{"title" => "Fallout"}, {"title" => "Roxanne"}]
300
328
  # # }
@@ -308,10 +336,9 @@ end
308
336
  # # it { subject.songs[1].title.must_equal "Roxanne" }
309
337
  # # end
310
338
 
311
-
312
339
  # # test cardinalities.
313
340
  # describe "with empty collection and cardinality" do
314
- # let (:album) { Album.new }
341
+ # let(:album) { Album.new }
315
342
 
316
343
  # subject { Class.new(Reform::Form) do
317
344
  # include Reform::Form::ActiveModel
@@ -329,7 +356,6 @@ end
329
356
  # validates :hit, :presence => true
330
357
  # end.new(album) }
331
358
 
332
-
333
359
  # describe "invalid" do
334
360
  # before { subject.validate({}).must_equal false }
335
361
 
@@ -342,9 +368,8 @@ end
342
368
  # end
343
369
  # end
344
370
 
345
-
346
371
  # describe "valid" do
347
- # let (:album) { Album.new(nil, Song.new, [Song.new("Urban Myth")]) }
372
+ # let(:album) { Album.new(nil, Song.new, [Song.new("Urban Myth")]) }
348
373
 
349
374
  # before {
350
375
  # subject.validate({"songs" => [{"title"=>"Daddy, Brother, Lover, Little Boy"}], "hit" => {"title"=>"The Horse"}}).
@@ -355,13 +380,9 @@ end
355
380
  # end
356
381
  # end
357
382
 
358
-
359
-
360
-
361
-
362
383
  # # providing manual validator method allows accessing form's API.
363
384
  # describe "with ::validate" do
364
- # let (:form) {
385
+ # let(:form) {
365
386
  # Class.new(Reform::Form) do
366
387
  # property :title
367
388
 
@@ -373,8 +394,8 @@ end
373
394
  # end
374
395
  # }
375
396
 
376
- # let (:params) { {"title" => "Fallout"} }
377
- # let (:song) { Song.new("Englishman") }
397
+ # let(:params) { {"title" => "Fallout"} }
398
+ # let(:song) { Song.new("Englishman") }
378
399
 
379
400
  # subject { form.new(song) }
380
401
 
@@ -384,10 +405,9 @@ end
384
405
  # it { subject.errors.messages.must_equal({:title=>["not lowercase"]}) }
385
406
  # end
386
407
 
387
-
388
408
  # # overriding the reader for a nested form should only be considered when rendering.
389
409
  # describe "with overridden reader for nested form" do
390
- # let (:form) {
410
+ # let(:form) {
391
411
  # Class.new(Reform::Form) do
392
412
  # property :band, :populate_if_empty => lambda { |*| Band.new } do
393
413
  # property :label
@@ -407,7 +427,7 @@ end
407
427
  # end.new(album)
408
428
  # }
409
429
 
410
- # let (:album) { Album.new }
430
+ # let(:album) { Album.new }
411
431
 
412
432
  # # don't use #artist when validating!
413
433
  # it do