disposable 0.4.5 → 0.6.0

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +29 -0
  3. data/.gitignore +1 -0
  4. data/CHANGES.md +20 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile_builder_test.rb +6 -0
  7. data/README.md +4 -0
  8. data/Rakefile +8 -2
  9. data/disposable.gemspec +3 -6
  10. data/lib/disposable/twin/builder.rb +1 -0
  11. data/lib/disposable/twin/coercion.rb +7 -2
  12. data/lib/disposable/twin/default.rb +3 -3
  13. data/lib/disposable/twin/property/struct.rb +3 -1
  14. data/lib/disposable/twin/property/unnest.rb +4 -3
  15. data/lib/disposable/twin.rb +10 -4
  16. data/lib/disposable/version.rb +1 -1
  17. data/test/callback_group_test.rb +27 -27
  18. data/test/callbacks_test.rb +44 -44
  19. data/test/expose_test.rb +16 -16
  20. data/test/persisted_test.rb +30 -30
  21. data/test/rescheme_test.rb +22 -22
  22. data/test/skip_getter_test.rb +14 -14
  23. data/test/test_helper.rb +1 -1
  24. data/test/twin/builder_test.rb +7 -3
  25. data/test/twin/changed_test.rb +38 -38
  26. data/test/twin/coercion_test.rb +63 -26
  27. data/test/twin/collection_test.rb +46 -46
  28. data/test/twin/composition_test.rb +20 -20
  29. data/test/twin/default_test.rb +15 -15
  30. data/test/twin/expose_test.rb +15 -15
  31. data/test/twin/feature_test.rb +10 -10
  32. data/test/twin/from_collection_test.rb +4 -4
  33. data/test/twin/from_test.rb +3 -3
  34. data/test/twin/hash_test.rb +38 -38
  35. data/test/twin/inherit_test.rb +7 -7
  36. data/test/twin/inheritance_test.rb +6 -6
  37. data/test/twin/parent_test.rb +5 -5
  38. data/test/twin/property_processor_test.rb +3 -3
  39. data/test/twin/readable_test.rb +9 -9
  40. data/test/twin/save_test.rb +44 -44
  41. data/test/twin/setup_test.rb +25 -25
  42. data/test/twin/skip_unchanged_test.rb +6 -6
  43. data/test/twin/struct/coercion_test.rb +5 -5
  44. data/test/twin/struct_test.rb +41 -38
  45. data/test/twin/sync_test.rb +29 -29
  46. data/test/twin/twin_test.rb +24 -14
  47. data/test/twin/unnest_test.rb +7 -7
  48. data/test/twin/virtual_test.rb +3 -3
  49. data/test/twin/writeable_test.rb +8 -8
  50. metadata +14 -69
  51. data/.travis.yml +0 -31
@@ -28,28 +28,28 @@ class TwinExposeTest < MiniTest::Spec
28
28
  let (:request) { Request.new(song) }
29
29
 
30
30
  it do
31
- request.song_title.must_equal "Extraction"
32
- request.id.must_equal 2
31
+ expect(request.song_title).must_equal "Extraction"
32
+ expect(request.id).must_equal 2
33
33
 
34
34
  request.song_title = "Tease"
35
35
  request.id = 1
36
36
 
37
37
 
38
- request.song_title.must_equal "Tease"
39
- request.id.must_equal 1
38
+ expect(request.song_title).must_equal "Tease"
39
+ expect(request.id).must_equal 1
40
40
 
41
41
  # does not write to model.
42
- song.title.must_equal "Extraction"
43
- song.id.must_equal 2
42
+ expect(song.title).must_equal "Extraction"
43
+ expect(song.id).must_equal 2
44
44
 
45
45
  request.save
46
46
 
47
47
  # make sure models got synced and saved.
48
- song.id.must_equal 1
49
- song.title.must_equal "Tease"
50
- song.album.must_equal album # nested objects don't get twinned or anything.
48
+ expect(song.id).must_equal 1
49
+ expect(song.title).must_equal "Tease"
50
+ expect(song.album).must_equal album # nested objects don't get twinned or anything.
51
51
 
52
- song.saved?.must_equal true
52
+ expect(song.saved?).must_equal true
53
53
  end
54
54
 
55
55
  # save with block.
@@ -63,11 +63,11 @@ class TwinExposeTest < MiniTest::Spec
63
63
  nested_hash = hash
64
64
  end
65
65
 
66
- nested_hash.must_equal({"title"=>"Tease", "id"=>1, "captcha" => "Awesome!", "album"=>{"getName"=>"Appeal To Reason"}})
66
+ expect(nested_hash).must_equal({"title"=>"Tease", "id"=>1, "captcha" => "Awesome!", "album"=>{"getName"=>"Appeal To Reason"}})
67
67
 
68
68
  # does not write to model.
69
- song.title.must_equal "Extraction"
70
- song.id.must_equal 2
71
- album.getName.must_equal "Appeal To Reason"
69
+ expect(song.title).must_equal "Extraction"
70
+ expect(song.id).must_equal 2
71
+ expect(album.getName).must_equal "Appeal To Reason"
72
72
  end
73
- end
73
+ end
@@ -44,14 +44,14 @@ class FeatureTest < MiniTest::Spec
44
44
  let (:form) { AlbumForm.new(album) }
45
45
 
46
46
  it do
47
- form.date.must_equal "May 16"
48
- form.artist.date.must_equal "May 16"
49
- form.songs[0].date.must_equal "May 16"
50
- form.songs[1].date.must_equal "May 16"
51
- form.songs[1].composer.date.must_equal "May 16"
52
- form.songs[1].wont_be_kind_of(Instrument)
53
- form.songs[1].composer.must_be_kind_of(Instrument)
54
- form.songs[1].composer.instrument.must_equal "Violins"
55
- form.artist.date.must_equal "May 16"
47
+ expect(form.date).must_equal "May 16"
48
+ expect(form.artist.date).must_equal "May 16"
49
+ expect(form.songs[0].date).must_equal "May 16"
50
+ expect(form.songs[1].date).must_equal "May 16"
51
+ expect(form.songs[1].composer.date).must_equal "May 16"
52
+ expect(form.songs[1]).wont_be_kind_of(Instrument)
53
+ expect(form.songs[1].composer).must_be_kind_of(Instrument)
54
+ expect(form.songs[1].composer.instrument).must_equal "Violins"
55
+ expect(form.artist.date).must_equal "May 16"
56
56
  end
57
- end
57
+ end
@@ -20,10 +20,10 @@ class TwinFromCollectionDecoratorTest < MiniTest::Spec
20
20
  it do
21
21
  twined_collection = Twin::Artist.from_collection(collection)
22
22
 
23
- twined_collection[0].must_be_instance_of Twin::Artist
24
- twined_collection[0].model.must_equal artist1
25
- twined_collection[1].must_be_instance_of Twin::Artist
26
- twined_collection[1].model.must_equal artist2
23
+ expect(twined_collection[0]).must_be_instance_of Twin::Artist
24
+ expect(twined_collection[0].model).must_equal artist1
25
+ expect(twined_collection[1]).must_be_instance_of Twin::Artist
26
+ expect(twined_collection[1].model).must_equal artist2
27
27
  end
28
28
  end
29
29
  end
@@ -27,11 +27,11 @@ class FromTest < MiniTest::Spec
27
27
  let (:twin) { Twin::Album.new(album) }
28
28
 
29
29
  it do
30
- twin.full_name.must_equal "Black Sails In The Sunset"
31
- twin.artist.name.must_equal "AFI"
30
+ expect(twin.full_name).must_equal "Black Sails In The Sunset"
31
+ expect(twin.artist.name).must_equal "AFI"
32
32
 
33
33
  twin.save
34
34
 
35
35
 
36
36
  end
37
- end
37
+ end
@@ -29,31 +29,31 @@ class HashTest < MiniTest::Spec
29
29
 
30
30
  it "allows reading from existing hash" do
31
31
  model = Model.new(1, {})
32
- model.inspect.must_equal "#<struct HashTest::Model id=1, content={}>"
32
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=1, content={}>"
33
33
 
34
34
  song = Song.new(model)
35
- song.id.must_equal 1
36
- song.content.title.must_be_nil
37
- song.content.band.name.must_be_nil
38
- song.content.band.label.location.must_be_nil
39
- song.content.releases.must_equal []
35
+ expect(song.id).must_equal 1
36
+ expect(song.content.title).must_be_nil
37
+ expect(song.content.band.name).must_be_nil
38
+ expect(song.content.band.label.location).must_be_nil
39
+ expect(song.content.releases).must_equal []
40
40
 
41
41
  # model's hash hasn't changed.
42
- model.inspect.must_equal "#<struct HashTest::Model id=1, content={}>"
42
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=1, content={}>"
43
43
  end
44
44
 
45
45
  it "defaults to hash when value is nil" do
46
46
  model = Model.new(1)
47
- model.inspect.must_equal "#<struct HashTest::Model id=1, content=nil>"
47
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=1, content=nil>"
48
48
 
49
49
  song = Song.new(model)
50
- song.id.must_equal 1
51
- song.content.title.must_be_nil
52
- song.content.band.name.must_be_nil
53
- song.content.band.label.location.must_be_nil
50
+ expect(song.id).must_equal 1
51
+ expect(song.content.title).must_be_nil
52
+ expect(song.content.band.name).must_be_nil
53
+ expect(song.content.band.label.location).must_be_nil
54
54
 
55
55
  # model's hash hasn't changed.
56
- model.inspect.must_equal "#<struct HashTest::Model id=1, content=nil>"
56
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=1, content=nil>"
57
57
  end
58
58
 
59
59
  it "#sync writes to model" do
@@ -64,7 +64,7 @@ class HashTest < MiniTest::Spec
64
64
 
65
65
  song.sync
66
66
 
67
- model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
67
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
68
68
  end
69
69
 
70
70
  it "#appends to collections" do
@@ -76,7 +76,7 @@ class HashTest < MiniTest::Spec
76
76
 
77
77
  song.sync
78
78
 
79
- model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{}}, \"releases\"=>[{\"version\"=>1}]}>"
79
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{}}, \"releases\"=>[{\"version\"=>1}]}>"
80
80
  end
81
81
 
82
82
  it "doesn't erase existing, undeclared content" do
@@ -88,7 +88,7 @@ class HashTest < MiniTest::Spec
88
88
  # puts song.content.class.ancestors
89
89
  song.sync
90
90
 
91
- model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"artist\"=>{}, \"band\"=>{\"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
91
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=nil, content={\"artist\"=>{}, \"band\"=>{\"label\"=>{\"location\"=>\"San Francisco\"}}, \"releases\"=>[]}>"
92
92
  end
93
93
 
94
94
  it "doesn't erase existing, undeclared content in existing content" do
@@ -99,7 +99,7 @@ class HashTest < MiniTest::Spec
99
99
 
100
100
  song.sync
101
101
 
102
- model.inspect.must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{\"owner\"=>\"Brett Gurewitz\", \"location\"=>\"San Francisco\"}, \"genre\"=>\"Punkrock\"}, \"releases\"=>[]}>"
102
+ expect(model.inspect).must_equal "#<struct HashTest::Model id=nil, content={\"band\"=>{\"label\"=>{\"owner\"=>\"Brett Gurewitz\", \"location\"=>\"San Francisco\"}, \"genre\"=>\"Punkrock\"}, \"releases\"=>[]}>"
103
103
  end
104
104
 
105
105
 
@@ -125,9 +125,9 @@ class HashTest < MiniTest::Spec
125
125
 
126
126
  it "includes features into all nested twins" do
127
127
  song = Hit.new(Model.new)
128
- song.uuid.must_equal "1224"
129
- song.content.uuid.must_equal "1224"
130
- song.content.band.uuid.must_equal "1224"
128
+ expect(song.uuid).must_equal "1224"
129
+ expect(song.content.uuid).must_equal "1224"
130
+ expect(song.content.band.uuid).must_equal "1224"
131
131
  end
132
132
  end
133
133
 
@@ -149,9 +149,9 @@ class HashTest < MiniTest::Spec
149
149
  it "coerces" do
150
150
  song = Coercing.new(Model.new(1))
151
151
  song.id = "9"
152
- song.id.must_equal 9
152
+ expect(song.id).must_equal 9
153
153
  song.content.band.name = 18
154
- song.content.band.name.must_equal "18"
154
+ expect(song.content.band.name).must_equal "18"
155
155
  end
156
156
  end
157
157
 
@@ -190,18 +190,18 @@ class HashTest < MiniTest::Spec
190
190
  song = Unnesting.new(model)
191
191
 
192
192
  # singular scalar accessors
193
- song.content.title.must_equal "Bedroom Eyes"
194
- song.title.must_equal "Bedroom Eyes"
193
+ expect(song.content.title).must_equal "Bedroom Eyes"
194
+ expect(song.title).must_equal "Bedroom Eyes"
195
195
 
196
196
  song.title = "Notorious"
197
- song.title.must_equal "Notorious"
198
- song.content.title.must_equal "Notorious"
197
+ expect(song.title).must_equal "Notorious"
198
+ expect(song.content.title).must_equal "Notorious"
199
199
 
200
200
  # singular nested accessors
201
- song.band.name.must_be_nil
202
- song.content.band.name.must_be_nil
201
+ expect(song.band.name).must_be_nil
202
+ expect(song.content.band.name).must_be_nil
203
203
  song.band.name = "Duran Duran"
204
- song.band.name.must_equal "Duran Duran"
204
+ expect(song.band.name).must_equal "Duran Duran"
205
205
  end
206
206
  end
207
207
 
@@ -237,18 +237,18 @@ class HashTest < MiniTest::Spec
237
237
 
238
238
  song1 = contract.songs[0]
239
239
 
240
- song1.title.must_equal "Sherry"
241
- song1.band.name.must_equal 'The Four Seasons'
242
- song1.band.label.location.must_equal 'US'
243
- song1.featured_artists[0].name.must_equal 'Frankie Valli'
244
- song1.featured_artists[1].name.must_equal 'The Variatones'
240
+ expect(song1.title).must_equal "Sherry"
241
+ expect(song1.band.name).must_equal 'The Four Seasons'
242
+ expect(song1.band.label.location).must_equal 'US'
243
+ expect(song1.featured_artists[0].name).must_equal 'Frankie Valli'
244
+ expect(song1.featured_artists[1].name).must_equal 'The Variatones'
245
245
 
246
246
  song2 = contract.songs[1]
247
247
 
248
- song2.title.must_equal "Walk Like a Man"
249
- song2.band.name.must_equal 'The Four Seasons'
250
- song2.band.label.location.must_equal 'US'
251
- song2.featured_artists[0].name.must_equal 'Frankie Valli'
248
+ expect(song2.title).must_equal "Walk Like a Man"
249
+ expect(song2.band.name).must_equal 'The Four Seasons'
250
+ expect(song2.band.label.location).must_equal 'US'
251
+ expect(song2.featured_artists[0].name).must_equal 'Frankie Valli'
252
252
  end
253
253
  end
254
254
  end
@@ -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