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
@@ -31,19 +31,19 @@ class AsTest < BaseTest
31
31
 
32
32
  subject { AlbumForm.new(Album.new("Best Of", hit, [Song.new("Fallout"), song2])) }
33
33
 
34
- it { subject.name.must_equal "Best Of" }
35
- it { subject.single.title.must_equal "Roxanne" }
36
- it { subject.tracks[0].name.must_equal "Fallout" }
37
- it { subject.tracks[1].name.must_equal "Roxanne" }
34
+ it { _(subject.name).must_equal "Best Of" }
35
+ it { _(subject.single.title).must_equal "Roxanne" }
36
+ it { _(subject.tracks[0].name).must_equal "Fallout" }
37
+ it { _(subject.tracks[1].name).must_equal "Roxanne" }
38
38
 
39
39
  describe "#validate" do
40
40
 
41
41
  before { subject.validate(params) }
42
42
 
43
- it { subject.name.must_equal "Best Of The Police" }
44
- it { subject.single.title.must_equal "So Lonely" }
45
- it { subject.tracks[0].name.must_equal "Message In A Bottle" }
46
- it { subject.tracks[1].name.must_equal "Roxanne" }
43
+ it { _(subject.name).must_equal "Best Of The Police" }
44
+ it { _(subject.single.title).must_equal "So Lonely" }
45
+ it { _(subject.tracks[0].name).must_equal "Message In A Bottle" }
46
+ it { _(subject.tracks[1].name).must_equal "Roxanne" }
47
47
  end
48
48
 
49
49
  describe "#sync" do
@@ -52,7 +52,7 @@ class AsTest < BaseTest
52
52
  subject.sync
53
53
  end
54
54
 
55
- it { song2.title.must_equal "Livin' Ain't No Crime" }
55
+ it { _(song2.title).must_equal "Livin' Ain't No Crime" }
56
56
  end
57
57
 
58
58
  describe "#save (nested hash)" do
@@ -65,7 +65,7 @@ class AsTest < BaseTest
65
65
  hash = nested_hash
66
66
  end
67
67
 
68
- hash.must_equal({"title" => "Best Of The Police", "hit" => {"title" => "So Lonely"}, "songs" => [{"title" => "Message In A Bottle"}, {"title" => "Roxanne"}], "band" => nil})
68
+ _(hash).must_equal({"title" => "Best Of The Police", "hit" => {"title" => "So Lonely"}, "songs" => [{"title" => "Message In A Bottle"}, {"title" => "Roxanne"}], "band" => nil})
69
69
  end
70
70
  end
71
71
  end
@@ -52,46 +52,46 @@ class InheritTest < BaseTest
52
52
 
53
53
  it do
54
54
  subject.validate("hit" => {"title" => "LA Drone", "rating" => 10})
55
- subject.hit.title.must_equal "LA Drone"
56
- subject.hit.rating.must_equal 10
57
- subject.errors.messages.must_equal({})
55
+ _(subject.hit.title).must_equal "LA Drone"
56
+ _(subject.hit.rating).must_equal 10
57
+ _(subject.errors.messages).must_equal({})
58
58
  end
59
59
 
60
60
  it do
61
61
  subject.validate({})
62
62
  assert_nil subject.model.hit.title
63
63
  assert_nil subject.model.hit.rating
64
- subject.errors.messages.must_equal("hit.title": ["must be filled"], "hit.rating": ["must be filled"])
64
+ _(subject.errors.messages).must_equal("hit.title": ["must be filled"], "hit.rating": ["must be filled"])
65
65
  end
66
66
 
67
67
  it "xxx" do
68
68
  # sub hashes like :deserializer must be properly cloned when inheriting.
69
- AlbumForm.options_for(:title)[:deserializer].object_id.wont_equal CompilationForm.options_for(:title)[:deserializer].object_id
69
+ _(AlbumForm.options_for(:title)[:deserializer].object_id).wont_equal CompilationForm.options_for(:title)[:deserializer].object_id
70
70
 
71
71
  # don't overwrite direct deserializer: {} configuration.
72
- AlbumForm.options_for(:title)[:internal_populator].must_be_instance_of Reform::Form::Populator::Sync
73
- AlbumForm.options_for(:title)[:deserializer][:skip_parse].must_equal "skip_if in AlbumForm"
72
+ _(AlbumForm.options_for(:title)[:internal_populator]).must_be_instance_of Reform::Form::Populator::Sync
73
+ _(AlbumForm.options_for(:title)[:deserializer][:skip_parse]).must_equal "skip_if in AlbumForm"
74
74
 
75
75
  # AlbumForm.options_for(:hit)[:internal_populator].inspect.must_match /Reform::Form::Populator:.+ @user_proc="Populator"/
76
76
  # AlbumForm.options_for(:hit)[:deserializer][:instance].inspect.must_be_instance_with Reform::Form::Populator, user_proc: "Populator"
77
77
 
78
- AlbumForm.options_for(:songs)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
79
- AlbumForm.options_for(:songs)[:deserializer][:skip_parse].must_be_instance_of Reform::Form::Validate::Skip::AllBlank
78
+ _(AlbumForm.options_for(:songs)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
79
+ _(AlbumForm.options_for(:songs)[:deserializer][:skip_parse]).must_be_instance_of Reform::Form::Validate::Skip::AllBlank
80
80
 
81
- AlbumForm.options_for(:band)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
81
+ _(AlbumForm.options_for(:band)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
82
82
 
83
- CompilationForm.options_for(:title)[:deserializer][:skip_parse].must_equal "skip_if from CompilationForm"
83
+ _(CompilationForm.options_for(:title)[:deserializer][:skip_parse]).must_equal "skip_if from CompilationForm"
84
84
  # pp CompilationForm.options_for(:songs)
85
- CompilationForm.options_for(:songs)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
85
+ _(CompilationForm.options_for(:songs)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
86
86
 
87
- CompilationForm.options_for(:band)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
87
+ _(CompilationForm.options_for(:band)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
88
88
 
89
89
  # completely overwrite inherited.
90
- CompilationForm.options_for(:hit)[:deserializer][:skip_parse].must_be_instance_of SkipParse
90
+ _(CompilationForm.options_for(:hit)[:deserializer][:skip_parse]).must_be_instance_of SkipParse
91
91
 
92
92
  # inherit: true with block will still inherit the original class.
93
- AlbumForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id.must_equal 1
94
- CompilationForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id.must_equal 1
93
+ _(AlbumForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id).must_equal 1
94
+ _(CompilationForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id).must_equal 1
95
95
  end
96
96
 
97
97
  class CDForm < AlbumForm
@@ -101,5 +101,5 @@ class InheritTest < BaseTest
101
101
  end
102
102
  end
103
103
 
104
- it { CDForm.options_for(:band)[:internal_populator].instance_variable_get(:@user_proc).must_equal "CD Populator" }
104
+ it { _(CDForm.options_for(:band)[:internal_populator].instance_variable_get(:@user_proc)).must_equal "CD Populator" }
105
105
  end
@@ -52,46 +52,46 @@ class InheritTest < BaseTest
52
52
 
53
53
  it do
54
54
  subject.validate("hit" => {"title" => "LA Drone", "rating" => 10})
55
- subject.hit.title.must_equal "LA Drone"
56
- subject.hit.rating.must_equal 10
57
- subject.errors.messages.must_equal({})
55
+ _(subject.hit.title).must_equal "LA Drone"
56
+ _(subject.hit.rating).must_equal 10
57
+ _(subject.errors.messages).must_equal({})
58
58
  end
59
59
 
60
60
  it do
61
61
  subject.validate({})
62
62
  assert_nil subject.model.hit.title
63
63
  assert_nil subject.model.hit.rating
64
- subject.errors.messages.must_equal("hit.title": ["must be filled"], "hit.rating": ["must be filled"])
64
+ _(subject.errors.messages).must_equal("hit.title": ["must be filled"], "hit.rating": ["must be filled"])
65
65
  end
66
66
 
67
67
  it "xxx" do
68
68
  # sub hashes like :deserializer must be properly cloned when inheriting.
69
- AlbumForm.options_for(:title)[:deserializer].object_id.wont_equal CompilationForm.options_for(:title)[:deserializer].object_id
69
+ _(AlbumForm.options_for(:title)[:deserializer].object_id).wont_equal CompilationForm.options_for(:title)[:deserializer].object_id
70
70
 
71
71
  # don't overwrite direct deserializer: {} configuration.
72
- AlbumForm.options_for(:title)[:internal_populator].must_be_instance_of Reform::Form::Populator::Sync
73
- AlbumForm.options_for(:title)[:deserializer][:skip_parse].must_equal "skip_if in AlbumForm"
72
+ _(AlbumForm.options_for(:title)[:internal_populator]).must_be_instance_of Reform::Form::Populator::Sync
73
+ _(AlbumForm.options_for(:title)[:deserializer][:skip_parse]).must_equal "skip_if in AlbumForm"
74
74
 
75
75
  # AlbumForm.options_for(:hit)[:internal_populator].inspect.must_match /Reform::Form::Populator:.+ @user_proc="Populator"/
76
76
  # AlbumForm.options_for(:hit)[:deserializer][:instance].inspect.must_be_instance_with Reform::Form::Populator, user_proc: "Populator"
77
77
 
78
- AlbumForm.options_for(:songs)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
79
- AlbumForm.options_for(:songs)[:deserializer][:skip_parse].must_be_instance_of Reform::Form::Validate::Skip::AllBlank
78
+ _(AlbumForm.options_for(:songs)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
79
+ _(AlbumForm.options_for(:songs)[:deserializer][:skip_parse]).must_be_instance_of Reform::Form::Validate::Skip::AllBlank
80
80
 
81
- AlbumForm.options_for(:band)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
81
+ _(AlbumForm.options_for(:band)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
82
82
 
83
- CompilationForm.options_for(:title)[:deserializer][:skip_parse].must_equal "skip_if from CompilationForm"
83
+ _(CompilationForm.options_for(:title)[:deserializer][:skip_parse]).must_equal "skip_if from CompilationForm"
84
84
  # pp CompilationForm.options_for(:songs)
85
- CompilationForm.options_for(:songs)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
85
+ _(CompilationForm.options_for(:songs)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
86
86
 
87
- CompilationForm.options_for(:band)[:internal_populator].must_be_instance_of Reform::Form::Populator::IfEmpty
87
+ _(CompilationForm.options_for(:band)[:internal_populator]).must_be_instance_of Reform::Form::Populator::IfEmpty
88
88
 
89
89
  # completely overwrite inherited.
90
- CompilationForm.options_for(:hit)[:deserializer][:skip_parse].must_be_instance_of SkipParse
90
+ _(CompilationForm.options_for(:hit)[:deserializer][:skip_parse]).must_be_instance_of SkipParse
91
91
 
92
92
  # inherit: true with block will still inherit the original class.
93
- AlbumForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id.must_equal 1
94
- CompilationForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id.must_equal 1
93
+ _(AlbumForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id).must_equal 1
94
+ _(CompilationForm.new(OpenStruct.new(band: OpenStruct.new)).band.band_id).must_equal 1
95
95
  end
96
96
 
97
97
  class CDForm < AlbumForm
@@ -101,5 +101,5 @@ class InheritTest < BaseTest
101
101
  end
102
102
  end
103
103
 
104
- it { CDForm.options_for(:band)[:internal_populator].instance_variable_get(:@user_proc).must_equal "CD Populator" }
104
+ it { _(CDForm.options_for(:band)[:internal_populator].instance_variable_get(:@user_proc)).must_equal "CD Populator" }
105
105
  end
@@ -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 { _(SongForm.new(song).band.title).must_equal "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 { _(SongForm.new(song).id).must_equal 1 }
67
+ it { _(SongForm.new(song).band.id).must_equal 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
+ _(form.errors.messages).must_equal(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
+ _(form.cool).must_equal true
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
+ _(form.errors.messages).must_equal("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
+ _(IncludingSongForm.new(song).id).must_equal 1
134
+ _(IncludingSongForm.new(song).title).must_equal "INSTANT MASH"
135
135
  end
136
136
  end
137
137
  end
@@ -68,25 +68,25 @@ class ModuleInclusionTest < MiniTest::Spec
68
68
  let(:song) { OpenStruct.new(band: OpenStruct.new(title: "Time Again"), artist: "Ketama") }
69
69
 
70
70
  # nested form from module is present and creates accessor.
71
- it { SongForm.new(song).band.title.must_equal "Time Again" }
72
- it { SongForm.new(song).artist.must_equal "Ketama" }
71
+ it { _(SongForm.new(song).band.title).must_equal "Time Again" }
72
+ it { _(SongForm.new(song).artist).must_equal "Ketama" }
73
73
 
74
74
  # methods from module get included.
75
- it { SongForm.new(song).id.must_equal 1 }
76
- it { SongForm.new(song).band.id.must_equal 2 }
75
+ it { _(SongForm.new(song).id).must_equal 1 }
76
+ it { _(SongForm.new(song).band.id).must_equal 2 }
77
77
 
78
78
  # validators get inherited.
79
79
  it do
80
80
  form = SongForm.new(OpenStruct.new)
81
81
  form.validate(artist: nil)
82
- form.errors.messages.must_equal(artist: ["this needs to be filled"], band: ["must be filled"])
82
+ _(form.errors.messages).must_equal(artist: ["this needs to be filled"], band: ["must be filled"])
83
83
  end
84
84
 
85
85
  # coercion works
86
86
  it do
87
87
  form = SongForm.new(OpenStruct.new)
88
88
  form.validate({cool: "1"})
89
- form.cool.must_equal true
89
+ _(form.cool).must_equal true
90
90
  end
91
91
 
92
92
  # include a module into a module into a class :)
@@ -115,7 +115,7 @@ class ModuleInclusionTest < MiniTest::Spec
115
115
  it do
116
116
  form = AlbumForm.new(OpenStruct.new(band: OpenStruct.new))
117
117
  form.validate("band" => {})
118
- form.errors.messages.must_equal("band.title": ["must be filled"], "band.label": ["must be filled"], name: ["must be filled"])
118
+ _(form.errors.messages).must_equal("band.title": ["must be filled"], "band.label": ["must be filled"], name: ["must be filled"])
119
119
  end
120
120
 
121
121
  describe "module with custom accessors" do
@@ -139,8 +139,8 @@ class ModuleInclusionTest < MiniTest::Spec
139
139
  let(:song) { OpenStruct.new(id: 1, title: "Instant Mash") }
140
140
 
141
141
  it do
142
- IncludingSongForm.new(song).id.must_equal 1
143
- IncludingSongForm.new(song).title.must_equal "INSTANT MASH"
142
+ _(IncludingSongForm.new(song).id).must_equal 1
143
+ _(IncludingSongForm.new(song).title).must_equal "INSTANT MASH"
144
144
  end
145
145
  end
146
146
  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
+ _(form.user).must_equal 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
+ _(form.content).must_equal lorem
22
+ _(form.user).must_equal 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
+ _(ArticleCommentForm.definitions.get(:user)[:deserializer][:writeable]).must_equal false
34
+ _(ArticleCommentForm.definitions.get(:user)[:deserializer][:instance]).must_equal "Instance"
35
35
 
36
- ArticleCommentForm.definitions.get(:article)[:deserializer][:writeable].must_equal true
37
- ArticleCommentForm.definitions.get(:article)[:deserializer][:instance].must_equal "Instance"
36
+ _(ArticleCommentForm.definitions.get(:article)[:deserializer][:writeable]).must_equal true
37
+ _(ArticleCommentForm.definitions.get(:article)[:deserializer][:instance]).must_equal "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
+ _(form.name).must_equal "{\"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
+ _(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