disposable 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +31 -29
  4. data/CHANGES.md +5 -0
  5. data/Gemfile +1 -1
  6. data/disposable.gemspec +0 -1
  7. data/lib/disposable/twin/coercion.rb +4 -1
  8. data/lib/disposable/twin/property/struct.rb +3 -1
  9. data/lib/disposable/version.rb +1 -1
  10. data/test/callback_group_test.rb +27 -27
  11. data/test/callbacks_test.rb +44 -44
  12. data/test/expose_test.rb +16 -16
  13. data/test/persisted_test.rb +30 -30
  14. data/test/rescheme_test.rb +22 -22
  15. data/test/skip_getter_test.rb +14 -14
  16. data/test/twin/builder_test.rb +3 -3
  17. data/test/twin/changed_test.rb +36 -36
  18. data/test/twin/coercion_test.rb +61 -23
  19. data/test/twin/collection_test.rb +46 -46
  20. data/test/twin/composition_test.rb +20 -20
  21. data/test/twin/default_test.rb +15 -15
  22. data/test/twin/expose_test.rb +15 -15
  23. data/test/twin/feature_test.rb +10 -10
  24. data/test/twin/from_collection_test.rb +4 -4
  25. data/test/twin/from_test.rb +3 -3
  26. data/test/twin/hash_test.rb +38 -38
  27. data/test/twin/inherit_test.rb +7 -7
  28. data/test/twin/inheritance_test.rb +6 -6
  29. data/test/twin/parent_test.rb +5 -5
  30. data/test/twin/property_processor_test.rb +3 -3
  31. data/test/twin/readable_test.rb +9 -9
  32. data/test/twin/save_test.rb +44 -44
  33. data/test/twin/setup_test.rb +25 -25
  34. data/test/twin/skip_unchanged_test.rb +6 -6
  35. data/test/twin/struct/coercion_test.rb +4 -4
  36. data/test/twin/struct_test.rb +41 -38
  37. data/test/twin/sync_test.rb +29 -29
  38. data/test/twin/twin_test.rb +14 -14
  39. data/test/twin/unnest_test.rb +7 -7
  40. data/test/twin/virtual_test.rb +3 -3
  41. data/test/twin/writeable_test.rb +8 -8
  42. metadata +3 -18
@@ -40,20 +40,20 @@ class InheritTest < MiniTest::Spec
40
40
 
41
41
  # definitions are not shared.
42
42
  it do
43
- Twin::Album.definitions.get(:name).extend(Declarative::Inspect).inspect.must_equal "#<Disposable::Twin::Definition: @options={:fromage=>:_name, :private_name=>:name, :name=>\"name\"}>"
44
- Twin::Compilation.definitions.get(:name).extend(Declarative::Inspect).inspect.must_equal "#<Disposable::Twin::Definition: @options={:fromage=>:_name, :private_name=>:name, :name=>\"name\", :writeable=>false}>" # FIXME: where did :inherit go?
43
+ expect(Twin::Album.definitions.get(:name).extend(Declarative::Inspect).inspect).must_equal "#<Disposable::Twin::Definition: @options={:fromage=>:_name, :private_name=>:name, :name=>\"name\"}>"
44
+ expect(Twin::Compilation.definitions.get(:name).extend(Declarative::Inspect).inspect).must_equal "#<Disposable::Twin::Definition: @options={:fromage=>:_name, :private_name=>:name, :name=>\"name\", :writeable=>false}>" # FIXME: where did :inherit go?
45
45
  end
46
46
 
47
47
 
48
48
  let (:album) { Model::Album.new("In The Meantime And Inbetween Time", [], Model::Artist.new) }
49
49
 
50
- it { Twin::Album.new(album).artist.artist_id.must_equal 1 }
50
+ it { expect(Twin::Album.new(album).artist.artist_id).must_equal 1 }
51
51
 
52
52
  # inherit inline twins when not overriding.
53
- it { Twin::EmptyCompilation.new(album).artist.artist_id.must_equal 1 }
53
+ it { expect(Twin::EmptyCompilation.new(album).artist.artist_id).must_equal 1 }
54
54
 
55
55
  # inherit inline twins when overriding.
56
- it { Twin::Compilation.new(album).artist.artist_id.must_equal 1 }
56
+ it { expect(Twin::Compilation.new(album).artist.artist_id).must_equal 1 }
57
57
 
58
58
  describe "custom accessors get inherited" do
59
59
  class Singer < Disposable::Twin
@@ -75,11 +75,11 @@ class InheritTest < MiniTest::Spec
75
75
 
76
76
  it do
77
77
  artist = Star.new(model)
78
- artist.name.must_equal("neewolleh")
78
+ expect(artist.name).must_equal("neewolleh")
79
79
 
80
80
  artist.name = "HELLOWEEN"
81
81
  # artist.with_custom_setter = "this gets ignored"
82
- artist.name.must_equal("neewolleh")
82
+ expect(artist.name).must_equal("neewolleh")
83
83
  end
84
84
  end
85
85
  end
@@ -20,7 +20,7 @@ class InheritanceTest < Minitest::Spec
20
20
 
21
21
  it do
22
22
  twin = Twin.new(song)
23
- twin.id.must_equal 0
23
+ expect(twin.id).must_equal 0
24
24
  end
25
25
 
26
26
  class TwinComposition < Disposable::Twin
@@ -32,9 +32,9 @@ class InheritanceTest < Minitest::Spec
32
32
 
33
33
  it do
34
34
  twin = TwinComposition.new(song: song)
35
- twin.id.must_equal 0
35
+ expect(twin.id).must_equal 0
36
36
  twin.id= 3
37
- twin.id.must_equal 3
37
+ expect(twin.id).must_equal 3
38
38
  end
39
39
 
40
40
 
@@ -50,7 +50,7 @@ class InheritanceTest < Minitest::Spec
50
50
 
51
51
  it do
52
52
  twin = TwinCompositionDefineMethod.new(song: song)
53
- twin.id.must_equal 9
53
+ expect(twin.id).must_equal 9
54
54
  end
55
55
 
56
56
 
@@ -66,8 +66,8 @@ class InheritanceTest < Minitest::Spec
66
66
  end
67
67
 
68
68
  it do
69
- TwinWithFrom.new(song).id.must_equal 1
70
- InheritingFrom.new(song).id.must_equal 1
69
+ expect(TwinWithFrom.new(song).id).must_equal 1
70
+ expect(InheritingFrom.new(song).id).must_equal 1
71
71
  end
72
72
  end
73
73
  end
@@ -27,15 +27,15 @@ class TwinParentTest < MiniTest::Spec
27
27
 
28
28
  let (:album) { Album.new(Model::Album.new(1, Model::Artist.new("Helloween"), [Model::Song.new("I'm Alive", Model::Artist.new("Kai Hansen"))])) }
29
29
 
30
- it { album.parent.must_be_nil }
31
- it { album.artist.parent.must_equal album }
32
- it { album.songs[0].parent.must_equal album }
33
- it { album.songs[0].composer.parent.must_equal album.songs[0] }
30
+ it { expect(album.parent).must_be_nil }
31
+ it { expect(album.artist.parent).must_equal album }
32
+ it { expect(album.songs[0].parent).must_equal album }
33
+ it { expect(album.songs[0].composer.parent).must_equal album.songs[0] }
34
34
 
35
35
  describe "Collection#append" do
36
36
  it do
37
37
  album.songs.append(Model::Song.new)
38
- album.songs[1].parent.must_equal album
38
+ expect(album.songs[1].parent).must_equal album
39
39
  end
40
40
  end
41
41
  end
@@ -23,14 +23,14 @@ class PropertyProcessorTest < Minitest::Spec
23
23
  called = []
24
24
  Disposable::Twin::PropertyProcessor.new(twin.class.definitions.get(:songs), twin).() { |v, i| called << [v.model, i] }
25
25
 
26
- called.inspect.must_equal %{[[#<struct PropertyProcessorTest::Song id=1>, 0], [#<struct PropertyProcessorTest::Song id=2>, 1]]}
26
+ expect(called.inspect).must_equal %{[[#<struct PropertyProcessorTest::Song id=1>, 0], [#<struct PropertyProcessorTest::Song id=2>, 1]]}
27
27
  end
28
28
 
29
29
  it "yields twin" do
30
30
  called = []
31
31
  Disposable::Twin::PropertyProcessor.new(twin.class.definitions.get(:songs), twin).() { |v| called << [v.model] }
32
32
 
33
- called.inspect.must_equal %{[[#<struct PropertyProcessorTest::Song id=1>], [#<struct PropertyProcessorTest::Song id=2>]]}
33
+ expect(called.inspect).must_equal %{[[#<struct PropertyProcessorTest::Song id=1>], [#<struct PropertyProcessorTest::Song id=2>]]}
34
34
  end
35
35
 
36
36
  it "allows nil collection" do
@@ -39,7 +39,7 @@ class PropertyProcessorTest < Minitest::Spec
39
39
  called = []
40
40
  Disposable::Twin::PropertyProcessor.new(twin.class.definitions.get(:songs), twin).() { |v, i| called << [v.model, i] }
41
41
 
42
- called.inspect.must_equal %{[]}
42
+ expect(called.inspect).must_equal %{[]}
43
43
  end
44
44
  end
45
45
  end
@@ -30,21 +30,21 @@ class ReadableTest < MiniTest::Spec
30
30
  let (:twin) { PasswordForm.new(cred) }
31
31
 
32
32
  it {
33
- twin.password.must_be_nil # not readable.
34
- twin.credit_card.name.must_equal "Jonny"
35
- twin.credit_card.number.must_be_nil # not readable.
33
+ expect(twin.password).must_be_nil # not readable.
34
+ expect(twin.credit_card.name).must_equal "Jonny"
35
+ expect(twin.credit_card.number).must_be_nil # not readable.
36
36
 
37
37
  # manual setting on the twin works.
38
38
  twin.password = "123"
39
- twin.password.must_equal "123"
39
+ expect(twin.password).must_equal "123"
40
40
 
41
41
  twin.credit_card.number = "456"
42
- twin.credit_card.number.must_equal "456"
42
+ expect(twin.credit_card.number).must_equal "456"
43
43
 
44
44
  twin.sync
45
45
 
46
46
  # it writes, but does not read.
47
- cred.inspect.must_equal '#<struct ReadableTest::Credentials password="123", credit_card=#<struct ReadableTest::CreditCard name="Jonny", number="456">>'
47
+ expect(cred.inspect).must_equal '#<struct ReadableTest::Credentials password="123", credit_card=#<struct ReadableTest::CreditCard name="Jonny", number="456">>'
48
48
 
49
49
  # test sync{}.
50
50
  hash = {}
@@ -52,12 +52,12 @@ class ReadableTest < MiniTest::Spec
52
52
  hash = nested
53
53
  end
54
54
 
55
- hash.must_equal("password"=> "123", "credit_card"=>{"name"=>"Jonny", "number"=>"456"})
55
+ expect(hash).must_equal("password"=> "123", "credit_card"=>{"name"=>"Jonny", "number"=>"456"})
56
56
  }
57
57
 
58
58
  # allow passing non-readable value as option.
59
59
  it do
60
60
  twin = PasswordForm.new(cred, password: "open sesame!")
61
- twin.password.must_equal "open sesame!"
61
+ expect(twin.password).must_equal "open sesame!"
62
62
  end
63
- end
63
+ end
@@ -48,29 +48,29 @@ class SaveTest < MiniTest::Spec
48
48
  twin.save
49
49
 
50
50
  # sync happened.
51
- album.name.must_equal "Live And Dangerous"
52
- album.songs[0].must_be_instance_of Model::Song
53
- album.songs[1].must_be_instance_of Model::Song
54
- album.songs[0].title.must_equal "Southbound"
55
- album.songs[1].title.must_equal "The Boys Are Back In Town"
56
- album.songs[1].composer.must_be_instance_of Model::Artist
57
- album.songs[1].composer.name.must_equal "Lynott"
58
- album.artist.must_be_instance_of Model::Artist
59
- album.artist.name.must_equal "Thin Lizzy"
51
+ expect(album.name).must_equal "Live And Dangerous"
52
+ expect(album.songs[0]).must_be_instance_of Model::Song
53
+ expect(album.songs[1]).must_be_instance_of Model::Song
54
+ expect(album.songs[0].title).must_equal "Southbound"
55
+ expect(album.songs[1].title).must_equal "The Boys Are Back In Town"
56
+ expect(album.songs[1].composer).must_be_instance_of Model::Artist
57
+ expect(album.songs[1].composer.name).must_equal "Lynott"
58
+ expect(album.artist).must_be_instance_of Model::Artist
59
+ expect(album.artist.name).must_equal "Thin Lizzy"
60
60
 
61
61
  # saved?
62
- album.saved?.must_equal true
63
- album.songs[0].saved?.must_equal true
64
- album.songs[1].saved?.must_equal true
65
- album.songs[1].composer.saved?.must_equal true
66
- album.artist.saved?.must_equal true
62
+ expect(album.saved?).must_equal true
63
+ expect(album.songs[0].saved?).must_equal true
64
+ expect(album.songs[1].saved?).must_equal true
65
+ expect(album.songs[1].composer.saved?).must_equal true
66
+ expect(album.artist.saved?).must_equal true
67
67
  end
68
68
 
69
69
  #save returns result.
70
- it { twin.save.must_equal true }
70
+ it { expect(twin.save).must_equal true }
71
71
  it do
72
72
  album.instance_eval { def save; false; end }
73
- twin.save.must_equal false
73
+ expect(twin.save).must_equal false
74
74
  end
75
75
 
76
76
  # with save{}.
@@ -85,22 +85,22 @@ class SaveTest < MiniTest::Spec
85
85
  nested_hash = hash
86
86
  end
87
87
 
88
- nested_hash.must_equal({"name"=>"Live And Dangerous", "songs"=>[{"title"=>"Southbound", "composer"=>nil}, {"title"=>"The Boys Are Back In Town", "composer"=>{"name"=>"Lynott"}}], "artist"=>{"name"=>"Thin Lizzy"}})
88
+ expect(nested_hash).must_equal({"name"=>"Live And Dangerous", "songs"=>[{"title"=>"Southbound", "composer"=>nil}, {"title"=>"The Boys Are Back In Town", "composer"=>{"name"=>"Lynott"}}], "artist"=>{"name"=>"Thin Lizzy"}})
89
89
 
90
90
  # nothing written to model.
91
- album.name.must_be_nil
92
- album.songs[0].title.must_be_nil
93
- album.songs[1].title.must_be_nil
94
- album.songs[1].composer.name.must_be_nil
95
- album.artist.name.must_be_nil
91
+ expect(album.name).must_be_nil
92
+ expect(album.songs[0].title).must_be_nil
93
+ expect(album.songs[1].title).must_be_nil
94
+ expect(album.songs[1].composer.name).must_be_nil
95
+ expect(album.artist.name).must_be_nil
96
96
 
97
97
  # nothing saved.
98
98
  # saved?
99
- album.saved?.must_be_nil
100
- album.songs[0].saved?.must_be_nil
101
- album.songs[1].saved?.must_be_nil
102
- album.songs[1].composer.saved?.must_be_nil
103
- album.artist.saved?.must_be_nil
99
+ expect(album.saved?).must_be_nil
100
+ expect(album.songs[0].saved?).must_be_nil
101
+ expect(album.songs[1].saved?).must_be_nil
102
+ expect(album.songs[1].composer.saved?).must_be_nil
103
+ expect(album.artist.saved?).must_be_nil
104
104
  end
105
105
 
106
106
 
@@ -136,22 +136,22 @@ class SaveTest < MiniTest::Spec
136
136
  twin.save
137
137
 
138
138
  # sync happened.
139
- album.name.must_equal "Live And Dangerous"
140
- album.songs[0].must_be_instance_of Model::Song
141
- album.songs[1].must_be_instance_of Model::Song
142
- album.songs[0].title.must_equal "Southbound"
143
- album.songs[1].title.must_equal "The Boys Are Back In Town"
144
- album.songs[1].composer.must_be_instance_of Model::Artist
145
- album.songs[1].composer.name.must_equal "Lynott"
146
- album.artist.must_be_instance_of Model::Artist
147
- album.artist.name.must_equal "Thin Lizzy"
139
+ expect(album.name).must_equal "Live And Dangerous"
140
+ expect(album.songs[0]).must_be_instance_of Model::Song
141
+ expect(album.songs[1]).must_be_instance_of Model::Song
142
+ expect(album.songs[0].title).must_equal "Southbound"
143
+ expect(album.songs[1].title).must_equal "The Boys Are Back In Town"
144
+ expect(album.songs[1].composer).must_be_instance_of Model::Artist
145
+ expect(album.songs[1].composer.name).must_equal "Lynott"
146
+ expect(album.artist).must_be_instance_of Model::Artist
147
+ expect(album.artist.name).must_equal "Thin Lizzy"
148
148
 
149
149
  # saved?
150
- album.saved?.must_equal true
151
- album.songs[0].saved?.must_be_nil
152
- album.songs[1].saved?.must_be_nil
153
- album.songs[1].composer.saved?.must_be_nil # doesn't get saved.
154
- album.artist.saved?.must_equal true
150
+ expect(album.saved?).must_equal true
151
+ expect(album.songs[0].saved?).must_be_nil
152
+ expect(album.songs[1].saved?).must_be_nil
153
+ expect(album.songs[1].composer.saved?).must_be_nil # doesn't get saved.
154
+ expect(album.artist.saved?).must_equal true
155
155
  end
156
156
 
157
157
  def fill_out!(twin)
@@ -185,8 +185,8 @@ end
185
185
  # length_seconds = 120
186
186
  # form.save(length: lambda { |value, options| form.model.id = "#{value}: #{length_seconds}" })
187
187
 
188
- # song.title.must_equal "A Poor Man's Memory"
189
- # song.length.must_be_nil
190
- # song.id.must_equal "10: 120"
188
+ # song.title).must_equal "A Poor Man's Memory"
189
+ # song.length).must_be_nil
190
+ # song.id).must_equal "10: 120"
191
191
  # end
192
192
  # end
@@ -44,16 +44,16 @@ class TwinSetupTest < MiniTest::Spec
44
44
  it do
45
45
  twin = Twin::Album.new(album)
46
46
 
47
- twin.songs.size.must_equal 2
48
- twin.songs.must_be_instance_of Disposable::Twin::Collection
47
+ expect(twin.songs.size).must_equal 2
48
+ expect(twin.songs).must_be_instance_of Disposable::Twin::Collection
49
49
 
50
- twin.songs[0].must_be_instance_of Twin::Song
51
- twin.songs[0].id.must_equal 1
50
+ expect(twin.songs[0]).must_be_instance_of Twin::Song
51
+ expect(twin.songs[0].id).must_equal 1
52
52
 
53
- twin.songs[1].must_be_instance_of Twin::Song
54
- twin.songs[1].id.must_equal 1
55
- twin.songs[1].composer.must_be_instance_of Twin::Artist
56
- twin.songs[1].composer.id.must_equal 2
53
+ expect(twin.songs[1]).must_be_instance_of Twin::Song
54
+ expect(twin.songs[1].id).must_equal 1
55
+ expect(twin.songs[1].composer).must_be_instance_of Twin::Artist
56
+ expect(twin.songs[1].composer.id).must_equal 2
57
57
  end
58
58
  end
59
59
 
@@ -63,8 +63,8 @@ class TwinSetupTest < MiniTest::Spec
63
63
  it do
64
64
  twin = Twin::Album.new(album)
65
65
 
66
- twin.songs.size.must_equal 0
67
- twin.songs.must_be_instance_of Disposable::Twin::Collection
66
+ expect(twin.songs.size).must_equal 0
67
+ expect(twin.songs).must_be_instance_of Disposable::Twin::Collection
68
68
  end
69
69
  end
70
70
 
@@ -75,7 +75,7 @@ class TwinSetupTest < MiniTest::Spec
75
75
  # it do
76
76
  # twin = Twin::Album.new(album)
77
77
 
78
- # twin.songs.size.must_equal 0
78
+ # twin.songs.size).must_equal 0
79
79
  # twin.songs.must_be_instance_of Disposable::Twin::Collection
80
80
  # end
81
81
  # end
@@ -118,23 +118,23 @@ class TwinSetupWithInlineTwinsTest < MiniTest::Spec
118
118
  twin = AlbumForm.new(album)
119
119
  # pp twin
120
120
 
121
- twin.id.must_equal 0
122
- twin.name.must_equal "Toto Live"
121
+ expect(twin.id).must_equal 0
122
+ expect(twin.name).must_equal "Toto Live"
123
123
 
124
- twin.artist.must_be_kind_of Disposable::Twin
125
- twin.artist.id.must_equal 9
124
+ expect(twin.artist).must_be_kind_of Disposable::Twin
125
+ expect(twin.artist.id).must_equal 9
126
126
 
127
- twin.songs.must_be_instance_of Disposable::Twin::Collection
127
+ expect(twin.songs).must_be_instance_of Disposable::Twin::Collection
128
128
 
129
129
  # nil nested objects work (no composer)
130
- twin.songs[0].must_be_kind_of Disposable::Twin
131
- twin.songs[0].id.must_equal 1
130
+ expect(twin.songs[0]).must_be_kind_of Disposable::Twin
131
+ expect(twin.songs[0].id).must_equal 1
132
132
 
133
- twin.songs[1].must_be_kind_of Disposable::Twin
134
- twin.songs[1].id.must_equal 3
133
+ expect(twin.songs[1]).must_be_kind_of Disposable::Twin
134
+ expect(twin.songs[1].id).must_equal 3
135
135
 
136
- twin.songs[1].composer.must_be_kind_of Disposable::Twin
137
- twin.songs[1].composer.id.must_equal 2
136
+ expect(twin.songs[1].composer).must_be_kind_of Disposable::Twin
137
+ expect(twin.songs[1].composer.id).must_equal 2
138
138
  end
139
139
  end
140
140
 
@@ -149,7 +149,7 @@ class TwinWithVirtualSetupTest < MiniTest::Spec
149
149
 
150
150
  it do
151
151
  twin = AlbumTwin.new(Song.new(1), is_online: true)
152
- twin.id.must_equal 1
153
- twin.is_online.must_equal true
152
+ expect(twin.id).must_equal 1
153
+ expect(twin.is_online).must_equal true
154
154
  end
155
- end
155
+ end
@@ -53,12 +53,12 @@ class SkipUnchangedTest < MiniTest::Spec
53
53
  twin.sync
54
54
 
55
55
  # unchanged, and no exception raised.
56
- album.name.must_equal "30 Years Live"
57
- song_with_composer.title.must_equal "American Jesus"
58
- artist.name.must_equal "Bad Religion"
56
+ expect(album.name).must_equal "30 Years Live"
57
+ expect(song_with_composer.title).must_equal "American Jesus"
58
+ expect(artist.name).must_equal "Bad Religion"
59
59
 
60
60
  # this actually got synced.
61
- song_with_composer.composer.name.must_equal "Greg Graffin" # was nil.
62
- song.title.must_equal "Resist Stance" # was nil.
61
+ expect(song_with_composer.composer.name).must_equal "Greg Graffin" # was nil.
62
+ expect(song.title).must_equal "Resist Stance" # was nil.
63
63
  end
64
- end
64
+ end
@@ -21,16 +21,16 @@ class StructCoercionTest < Minitest::Spec
21
21
  twin = Expense.new( ExpenseModel.new({}) )
22
22
 
23
23
  #- direct access, without unnest
24
- twin.content.amount.must_be_nil
24
+ expect(twin.content.amount).must_be_nil
25
25
  twin.content.amount = "1.8"
26
- twin.content.amount.must_equal 1.8
26
+ expect(twin.content.amount).must_equal 1.8
27
27
  end
28
28
 
29
29
  it "via unnest" do
30
30
  twin = Expense.new( ExpenseModel.new({}) )
31
31
 
32
- twin.amount.must_be_nil
32
+ expect(twin.amount).must_be_nil
33
33
  twin.amount = "1.8"
34
- twin.amount.must_equal 1.8
34
+ expect(twin.amount).must_equal 1.8
35
35
  end
36
36
  end
@@ -11,19 +11,22 @@ class TwinStructTest < MiniTest::Spec
11
11
  end
12
12
 
13
13
  # empty hash
14
- # it { Song.new({}).number.must_equal 1 }
15
- it { Song.new({}).number.must_be_nil } # TODO: implement default.
14
+ # it { Song.new({}).number).must_equal 1 }
15
+ it { expect(Song.new({}).number).must_be_nil } # TODO: implement default.
16
16
 
17
17
  # model hash
18
- it { Song.new(number: 2).number.must_equal 2 }
18
+ it { expect(Song.new(number: 2).number).must_equal 2 }
19
19
 
20
20
  # with hash and options as one hash.
21
- it { Song.new(number: 3, cool?: true).cool?.must_equal true }
22
- it { Song.new(number: 3, cool?: true).number.must_equal 3 }
21
+ it { expect(Song.new(number: 3, cool?: true).cool?).must_equal true }
22
+ it { expect(Song.new(number: 3, cool?: true).number).must_equal 3 }
23
23
 
24
24
  # with model hash and options hash separated.
25
- it { Song.new({number: 3}, {cool?: true}).cool?.must_equal true }
26
- it { Song.new({number: 3}, {cool?: true}).number.must_equal 3 }
25
+ it { expect(Song.new({number: 3}, {cool?: true}).cool?).must_equal true }
26
+ it { expect(Song.new({number: 3}, {cool?: true}).number).must_equal 3 }
27
+
28
+ # with string key and false value
29
+ it { Song.new('number' => 3, 'cool?' => false).cool?.must_equal false }
27
30
 
28
31
 
29
32
  describe "writing" do
@@ -33,8 +36,8 @@ class TwinStructTest < MiniTest::Spec
33
36
  # writer
34
37
  it do
35
38
  song.number = 9
36
- song.number.must_equal 9
37
- model[:number].must_equal 3
39
+ expect(song.number).must_equal 9
40
+ expect(model[:number]).must_equal 3
38
41
  end
39
42
 
40
43
  # writer with sync
@@ -42,10 +45,10 @@ class TwinStructTest < MiniTest::Spec
42
45
  song.number = 9
43
46
  model = song.sync
44
47
 
45
- song.number.must_equal 9
46
- model["number"].must_equal 9
48
+ expect(song.number).must_equal 9
49
+ expect(model["number"]).must_equal 9
47
50
 
48
- # song.send(:model).object_id.must_equal model.object_id
51
+ # song.send(:model).object_id).must_equal model.object_id
49
52
  end
50
53
  end
51
54
  end
@@ -79,26 +82,26 @@ class TwinWithNestedStructTest < MiniTest::Spec
79
82
  preferences: {show_image: true, play_teaser: 2}, roles: [{name: "user"}]}) }
80
83
 
81
84
  # public "hash" reader
82
- it { Song.new(model).options.recorded.must_equal true }
85
+ it { expect(Song.new(model).options.recorded).must_equal true }
83
86
 
84
87
  # public "hash" writer
85
88
  it {
86
89
  song = Song.new(model)
87
90
 
88
91
  song.options.recorded = "yo"
89
- song.options.recorded.must_equal "yo"
92
+ expect(song.options.recorded).must_equal "yo"
90
93
 
91
- song.options.preferences.show_image.must_equal true
92
- song.options.preferences.play_teaser.must_equal 2
94
+ expect(song.options.preferences.show_image).must_equal true
95
+ expect(song.options.preferences.play_teaser).must_equal 2
93
96
 
94
97
  song.options.preferences.show_image= 9
95
98
 
96
99
 
97
100
  song.sync # this is only called on the top model, e.g. in Reform#save.
98
101
 
99
- model.title.must_equal "Seed of Fear and Anger"
100
- model.options["recorded"].must_equal "yo"
101
- model.options["preferences"].must_equal({"show_image" => 9, "play_teaser"=>2})
102
+ expect(model.title).must_equal "Seed of Fear and Anger"
103
+ expect(model.options["recorded"]).must_equal "yo"
104
+ expect(model.options["preferences"]).must_equal({"show_image" => 9, "play_teaser"=>2})
102
105
  }
103
106
 
104
107
  describe "nested writes" do
@@ -111,14 +114,14 @@ class TwinWithNestedStructTest < MiniTest::Spec
111
114
  role = song.options.roles.append({}) # add empty "model" to hash collection.
112
115
  role.name = "admin"
113
116
 
114
- song.options.roles.size.must_equal 2
115
- song.options.roles[0].name.must_equal "user"
116
- song.options.roles[1].name.must_equal "admin"
117
- model.options[:roles].must_equal([{:name=>"user"}]) # model hasn't changed, of course.
117
+ expect(song.options.roles.size).must_equal 2
118
+ expect(song.options.roles[0].name).must_equal "user"
119
+ expect(song.options.roles[1].name).must_equal "admin"
120
+ expect(model.options[:roles]).must_equal([{:name=>"user"}]) # model hasn't changed, of course.
118
121
 
119
122
  song.sync
120
123
 
121
- model.options.must_equal({"recorded"=>true, "released"=>1, "preferences"=>{"show_image"=>true, "play_teaser"=>2}, "roles"=>[{"name"=>"user"}, {"name"=>"admin"}]})
124
+ expect(model.options).must_equal({"recorded"=>true, "released"=>1, "preferences"=>{"show_image"=>true, "play_teaser"=>2}, "roles"=>[{"name"=>"user"}, {"name"=>"admin"}]})
122
125
  end
123
126
 
124
127
  # overwriting nested property via #preferences=.
@@ -126,7 +129,7 @@ class TwinWithNestedStructTest < MiniTest::Spec
126
129
  song.options.preferences = {play_teaser: :maybe}
127
130
  song.sync
128
131
 
129
- model.options.must_equal({"recorded"=>true, "released"=>1, "preferences"=>{"play_teaser"=>:maybe}, "roles"=>[{"name"=>"user"}]})
132
+ expect(model.options).must_equal({"recorded"=>true, "released"=>1, "preferences"=>{"play_teaser"=>:maybe}, "roles"=>[{"name"=>"user"}]})
130
133
  end
131
134
 
132
135
  # overwriting collection via #roles=.
@@ -134,7 +137,7 @@ class TwinWithNestedStructTest < MiniTest::Spec
134
137
  song.options.roles = [{name: "wizard"}]
135
138
  song.sync
136
139
 
137
- model.options.must_equal({"recorded"=>true, "released"=>1, "preferences"=>{"show_image"=>true, "play_teaser"=>2}, "roles"=>[{"name"=>"wizard"}]})
140
+ expect(model.options).must_equal({"recorded"=>true, "released"=>1, "preferences"=>{"show_image"=>true, "play_teaser"=>2}, "roles"=>[{"name"=>"wizard"}]})
138
141
  end
139
142
  end
140
143
 
@@ -146,7 +149,7 @@ class TwinWithNestedStructTest < MiniTest::Spec
146
149
 
147
150
  # song.sync
148
151
 
149
- # model[:options][:roles].must_equal({ })
152
+ # model[:options][:roles]).must_equal({ })
150
153
 
151
154
  # pp song
152
155
 
@@ -178,8 +181,8 @@ class StructReadableWriteableTest < Minitest::Spec
178
181
 
179
182
  it "ignores readable: false" do
180
183
  song = Song.new(length: 123, id: 1)
181
- song.length.must_equal 123
182
- song.id.must_be_nil
184
+ expect(song.length).must_equal 123
185
+ expect(song.id).must_be_nil
183
186
  end
184
187
 
185
188
  it "ignores writeable: false" do
@@ -209,20 +212,20 @@ class DefaultWithStructTest < Minitest::Spec
209
212
  # all given.
210
213
  it do
211
214
  twin = Twin.new(Song.new({enabled: true, roles: {admin: false}}))
212
- twin.settings.enabled.must_equal true
213
- twin.settings.roles.admin.must_equal false
215
+ expect(twin.settings.enabled).must_equal true
216
+ expect(twin.settings.roles.admin).must_equal false
214
217
  end
215
218
 
216
219
  # defaults, please.
217
220
  it do
218
221
  song = Song.new
219
222
  twin = Twin.new(song)
220
- twin.settings.enabled.must_equal "yes"
221
- twin.settings.roles.admin.must_equal "maybe"
223
+ expect(twin.settings.enabled).must_equal "yes"
224
+ expect(twin.settings.roles.admin).must_equal "maybe"
222
225
 
223
226
  twin.sync
224
227
 
225
- song.settings.must_equal({"enabled"=>"yes", "roles"=>{"admin"=>"maybe"}})
228
+ expect(song.settings).must_equal({"enabled"=>"yes", "roles"=>{"admin"=>"maybe"}})
226
229
  end
227
230
  end
228
231
 
@@ -258,7 +261,7 @@ class CompositionWithStructTest < Minitest::Spec
258
261
 
259
262
  twin.sync
260
263
 
261
- model.content.must_equal({"tags"=>["history"], "notes"=>[{"text"=>"Freedom", "index"=>0}, {"text"=>"Like", "index"=>1}, {"text"=>"Canberra trip", "index"=>2}]})
264
+ expect(model.content).must_equal({"tags"=>["history"], "notes"=>[{"text"=>"Freedom", "index"=>0}, {"text"=>"Like", "index"=>1}, {"text"=>"Canberra trip", "index"=>2}]})
262
265
  end
263
266
 
264
267
  class Sheet < Disposable::Twin
@@ -319,9 +322,9 @@ class CompositionWithStructTest < Minitest::Spec
319
322
 
320
323
 
321
324
 
322
- sheet.tags.must_equal "#hashtag"
323
- sheet.notes[0].text.must_equal "Freedom"
324
- sheet.notes[0].index.must_equal 0
325
+ expect(sheet.tags).must_equal "#hashtag"
326
+ expect(sheet.notes[0].text).must_equal "Freedom"
327
+ expect(sheet.notes[0].index).must_equal 0
325
328
 
326
329
  sheet.notes[0].index = 2
327
330