disposable 0.4.3 → 0.5.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.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +29 -0
- data/.gitignore +1 -0
- data/CHANGES.md +23 -0
- data/Gemfile +5 -12
- data/README.md +2 -2
- data/disposable.gemspec +6 -9
- data/lib/disposable/rescheme.rb +1 -3
- data/lib/disposable/twin.rb +7 -0
- data/lib/disposable/twin/coercion.rb +11 -3
- data/lib/disposable/twin/default.rb +3 -3
- data/lib/disposable/twin/property/struct.rb +3 -1
- data/lib/disposable/twin/setup.rb +1 -1
- data/lib/disposable/twin/sync.rb +1 -1
- data/lib/disposable/version.rb +1 -1
- data/test/callback_group_test.rb +29 -30
- data/test/callbacks_test.rb +49 -49
- data/test/expose_test.rb +16 -16
- data/test/persisted_test.rb +30 -30
- data/test/rescheme_test.rb +22 -22
- data/test/skip_getter_test.rb +14 -14
- data/test/test_helper.rb +9 -6
- data/test/twin/builder_test.rb +3 -3
- data/test/twin/changed_test.rb +38 -38
- data/test/twin/coercion_test.rb +75 -38
- data/test/twin/collection_test.rb +48 -48
- data/test/twin/composition_test.rb +20 -20
- data/test/twin/default_test.rb +15 -15
- data/test/twin/expose_test.rb +15 -15
- data/test/twin/feature_test.rb +10 -10
- data/test/twin/from_collection_test.rb +4 -4
- data/test/twin/from_test.rb +3 -3
- data/test/twin/hash_test.rb +78 -31
- data/test/twin/inherit_test.rb +7 -7
- data/test/twin/inheritance_test.rb +6 -6
- data/test/twin/option_test.rb +1 -1
- data/test/twin/parent_test.rb +6 -6
- data/test/twin/property_processor_test.rb +5 -5
- data/test/twin/readable_test.rb +9 -9
- data/test/twin/save_test.rb +44 -44
- data/test/twin/setup_test.rb +25 -25
- data/test/twin/skip_unchanged_test.rb +6 -6
- data/test/twin/struct/coercion_test.rb +36 -0
- data/test/twin/struct_test.rb +41 -38
- data/test/twin/sync_option_test.rb +2 -2
- data/test/twin/sync_test.rb +29 -29
- data/test/twin/twin_test.rb +25 -15
- data/test/twin/unnest_test.rb +7 -7
- data/test/twin/virtual_test.rb +3 -3
- data/test/twin/writeable_test.rb +8 -8
- metadata +25 -57
- data/.travis.yml +0 -13
- data/gemfiles/Gemfile.rails-2.3 +0 -7
- data/gemfiles/Gemfile.rails-3.0 +0 -7
- data/gemfiles/Gemfile.rails-3.2 +0 -7
- data/gemfiles/Gemfile.rails-4.0 +0 -8
- data/gemfiles/Gemfile.rails-4.1 +0 -7
data/test/twin/default_test.rb
CHANGED
@@ -19,28 +19,28 @@ class DefaultTest < Minitest::Spec
|
|
19
19
|
# all given.
|
20
20
|
it do
|
21
21
|
twin = Twin.new(Song.new("Anarchy Camp", false, true, "Punk", Composer.new("Nofx")))
|
22
|
-
twin.title.must_equal "Anarchy Camp"
|
23
|
-
twin.genre.must_equal "Punk"
|
24
|
-
twin.composer.name.must_equal "Nofx"
|
25
|
-
twin.published.must_equal true
|
26
|
-
twin.new_album.must_equal false
|
22
|
+
expect(twin.title).must_equal "Anarchy Camp"
|
23
|
+
expect(twin.genre).must_equal "Punk"
|
24
|
+
expect(twin.composer.name).must_equal "Nofx"
|
25
|
+
expect(twin.published).must_equal true
|
26
|
+
expect(twin.new_album).must_equal false
|
27
27
|
end
|
28
28
|
|
29
29
|
# defaults, please.
|
30
30
|
it do
|
31
31
|
twin = Twin.new(Song.new)
|
32
|
-
twin.title.must_equal "Medio-Core"
|
33
|
-
twin.composer.name.must_equal "NOFX"
|
34
|
-
twin.genre.must_equal "Punk Rock DefaultTest::Song"
|
35
|
-
twin.published.must_equal false
|
36
|
-
twin.new_album.must_equal true
|
32
|
+
expect(twin.title).must_equal "Medio-Core"
|
33
|
+
expect(twin.composer.name).must_equal "NOFX"
|
34
|
+
expect(twin.genre).must_equal "Punk Rock DefaultTest::Song"
|
35
|
+
expect(twin.published).must_equal false
|
36
|
+
expect(twin.new_album).must_equal true
|
37
37
|
end
|
38
38
|
|
39
39
|
# false value is not defaulted.
|
40
40
|
it do
|
41
41
|
twin = Twin.new(Song.new(false, false))
|
42
|
-
twin.title.must_equal false
|
43
|
-
twin.new_album.must_equal false
|
42
|
+
expect(twin.title).must_equal false
|
43
|
+
expect(twin.new_album).must_equal false
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "inheritance" do
|
@@ -51,7 +51,7 @@ class DefaultTest < Minitest::Spec
|
|
51
51
|
class MegaTwin < SuperTwin
|
52
52
|
end
|
53
53
|
|
54
|
-
it { MegaTwin.new(Composer.new).name.must_equal "n/a" }
|
54
|
+
it { expect(MegaTwin.new(Composer.new).name).must_equal "n/a" }
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -65,8 +65,8 @@ class DefaultAndVirtualTest < Minitest::Spec
|
|
65
65
|
|
66
66
|
it do
|
67
67
|
twin = Twin.new(Object.new)
|
68
|
-
twin.title.must_equal "0"
|
69
|
-
# twin.changed.must_equal []
|
68
|
+
expect(twin.title).must_equal "0"
|
69
|
+
# expect(twin.changed).must_equal []
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
data/test/twin/expose_test.rb
CHANGED
@@ -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
|
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
|
data/test/twin/feature_test.rb
CHANGED
@@ -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
|
data/test/twin/from_test.rb
CHANGED
@@ -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
|
data/test/twin/hash_test.rb
CHANGED
@@ -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.
|
37
|
-
song.content.band.name.
|
38
|
-
song.content.band.label.location.
|
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.
|
52
|
-
song.content.band.name.
|
53
|
-
song.content.band.label.location.
|
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
|
|
@@ -137,7 +137,7 @@ class HashTest < MiniTest::Spec
|
|
137
137
|
include Property::Hash
|
138
138
|
feature Coercion
|
139
139
|
|
140
|
-
property :id, type: Types::Coercible
|
140
|
+
property :id, type: const_get("Types::Coercible::#{DRY_TYPES_INT_CONSTANT}")
|
141
141
|
property :content, field: :hash do
|
142
142
|
property :title
|
143
143
|
property :band do
|
@@ -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
|
|
@@ -161,7 +161,7 @@ class HashTest < MiniTest::Spec
|
|
161
161
|
include Property::Hash
|
162
162
|
|
163
163
|
property :id
|
164
|
-
|
164
|
+
property :content, field: :hash do
|
165
165
|
property :title
|
166
166
|
property :band do
|
167
167
|
property :name
|
@@ -190,18 +190,65 @@ 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.
|
202
|
-
song.content.band.name.
|
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
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe 'collection schema' do
|
209
|
+
AlbumModel = Struct.new(:id, :songs)
|
210
|
+
class Album < Disposable::Twin
|
211
|
+
feature Sync
|
212
|
+
feature Property::Hash
|
213
|
+
|
214
|
+
property :id
|
215
|
+
collection :songs, field: :hash do
|
216
|
+
property :title
|
217
|
+
property :band do
|
218
|
+
property :name
|
219
|
+
|
220
|
+
property :label do
|
221
|
+
property :location
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
collection :featured_artists do
|
226
|
+
property :name
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
it "exposes reader and writer" do
|
232
|
+
model = AlbumModel.new(1, [
|
233
|
+
{ title: "Sherry", band: { name: 'The Four Seasons', label: { location: 'US' } }, featured_artists: [{ name: 'Frankie Valli' }, { name: 'The Variatones' }] },
|
234
|
+
{ title: "Walk Like a Man", band: { name: 'The Four Seasons', label: { location: 'US' } }, featured_artists: [{ name: 'Frankie Valli' }] }
|
235
|
+
])
|
236
|
+
contract = Album.new(model)
|
237
|
+
|
238
|
+
song1 = contract.songs[0]
|
239
|
+
|
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
|
+
|
246
|
+
song2 = contract.songs[1]
|
247
|
+
|
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'
|
205
252
|
end
|
206
253
|
end
|
207
254
|
end
|
data/test/twin/inherit_test.rb
CHANGED
@@ -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
|
data/test/twin/option_test.rb
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
# # option is not delegated to model.
|
29
29
|
# it { twin.preview?.must_equal false }
|
30
30
|
# # not passing option means zero.
|
31
|
-
# it { twin.current_user.
|
31
|
+
# it { twin.current_user.must_be_nil }
|
32
32
|
|
33
33
|
# describe "passing all options" do
|
34
34
|
# let (:twin) { Song.new(song, :preview? => false, current_user: Object) }
|