disposable 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +31 -29
- data/CHANGES.md +5 -0
- data/Gemfile +1 -1
- data/disposable.gemspec +0 -1
- data/lib/disposable/twin/coercion.rb +4 -1
- data/lib/disposable/twin/property/struct.rb +3 -1
- data/lib/disposable/version.rb +1 -1
- data/test/callback_group_test.rb +27 -27
- data/test/callbacks_test.rb +44 -44
- 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/twin/builder_test.rb +3 -3
- data/test/twin/changed_test.rb +36 -36
- data/test/twin/coercion_test.rb +61 -23
- data/test/twin/collection_test.rb +46 -46
- 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 +38 -38
- data/test/twin/inherit_test.rb +7 -7
- data/test/twin/inheritance_test.rb +6 -6
- data/test/twin/parent_test.rb +5 -5
- data/test/twin/property_processor_test.rb +3 -3
- 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 +4 -4
- data/test/twin/struct_test.rb +41 -38
- data/test/twin/sync_test.rb +29 -29
- data/test/twin/twin_test.rb +14 -14
- 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 +3 -18
@@ -33,9 +33,9 @@ class TwinCollectionTest < MiniTest::Spec
|
|
33
33
|
it do
|
34
34
|
twin = Twin::Album.new(album)
|
35
35
|
|
36
|
-
twin.songs.size.must_equal 1
|
37
|
-
twin.songs[0].title.must_equal "Broken"
|
38
|
-
twin.songs.must_be_instance_of Disposable::Twin::Collection
|
36
|
+
expect(twin.songs.size).must_equal 1
|
37
|
+
expect(twin.songs[0].title).must_equal "Broken"
|
38
|
+
expect(twin.songs).must_be_instance_of Disposable::Twin::Collection
|
39
39
|
|
40
40
|
end
|
41
41
|
end
|
@@ -44,10 +44,10 @@ class TwinCollectionTest < MiniTest::Spec
|
|
44
44
|
let (:album) { Model::Album.new(1, "The Rest Is Silence", [Model::Song.new(3), Model::Song.new(4)]) }
|
45
45
|
let (:twin) { Twin::Album.new(album) }
|
46
46
|
|
47
|
-
it { twin.songs.find_by(id: 1).must_be_nil }
|
48
|
-
it { twin.songs.find_by(id: 3).must_equal twin.songs[0] }
|
49
|
-
it { twin.songs.find_by(id: 4).must_equal twin.songs[1] }
|
50
|
-
it { twin.songs.find_by(id: "4").must_equal twin.songs[1] }
|
47
|
+
it { expect(twin.songs.find_by(id: 1)).must_be_nil }
|
48
|
+
it { expect(twin.songs.find_by(id: 3)).must_equal twin.songs[0] }
|
49
|
+
it { expect(twin.songs.find_by(id: 4)).must_equal twin.songs[1] }
|
50
|
+
it { expect(twin.songs.find_by(id: "4")).must_equal twin.songs[1] }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -92,31 +92,31 @@ class TwinCollectionActiveRecordTest < MiniTest::Spec
|
|
92
92
|
twin.songs << song1 # assuming that we add AR model here.
|
93
93
|
twin.songs << song2
|
94
94
|
|
95
|
-
twin.songs.size.must_equal 2
|
95
|
+
expect(twin.songs.size).must_equal 2
|
96
96
|
|
97
|
-
twin.songs[0].must_be_instance_of Twin::Song # twin wraps << added in twin.
|
98
|
-
twin.songs[1].must_be_instance_of Twin::Song
|
97
|
+
expect(twin.songs[0]).must_be_instance_of Twin::Song # twin wraps << added in twin.
|
98
|
+
expect(twin.songs[1]).must_be_instance_of Twin::Song
|
99
99
|
|
100
|
-
# twin.songs[0].persisted
|
101
|
-
twin.songs[0].send(:model).persisted
|
102
|
-
twin.songs[1].send(:model).persisted
|
100
|
+
# expect(twin.songs[0].persisted?).must_equal false
|
101
|
+
expect(twin.songs[0].send(:model).persisted?).must_equal false
|
102
|
+
expect(twin.songs[1].send(:model).persisted?).must_equal true
|
103
103
|
|
104
|
-
album.songs.size.must_equal 0 # nothing synced, yet.
|
104
|
+
expect(album.songs.size).must_equal 0 # nothing synced, yet.
|
105
105
|
|
106
106
|
# sync: delete removed items, add new?
|
107
107
|
|
108
108
|
# save
|
109
109
|
twin.save
|
110
110
|
|
111
|
-
album.persisted
|
112
|
-
album.name.must_equal "The Rest Is Silence"
|
111
|
+
expect(album.persisted?).must_equal true
|
112
|
+
expect(album.name).must_equal "The Rest Is Silence"
|
113
113
|
|
114
|
-
album.songs.size.must_equal 2 # synced!
|
114
|
+
expect(album.songs.size).must_equal 2 # synced!
|
115
115
|
|
116
|
-
album.songs[0].persisted
|
117
|
-
album.songs[1].persisted
|
118
|
-
album.songs[0].title.must_equal "Snorty Pacifical Rascal"
|
119
|
-
album.songs[1].title.must_equal "At Any Cost"
|
116
|
+
expect(album.songs[0].persisted?).must_equal true
|
117
|
+
expect(album.songs[1].persisted?).must_equal true
|
118
|
+
expect(album.songs[0].title).must_equal "Snorty Pacifical Rascal"
|
119
|
+
expect(album.songs[1].title).must_equal "At Any Cost"
|
120
120
|
end
|
121
121
|
|
122
122
|
# test with adding to existing collection [song1] << song2
|
@@ -128,20 +128,20 @@ class TwinCollectionActiveRecordTest < MiniTest::Spec
|
|
128
128
|
it do
|
129
129
|
twin.songs.delete(twin.songs.first)
|
130
130
|
|
131
|
-
twin.songs.size.must_equal 0
|
132
|
-
album.songs.size.must_equal 1 # not synced, yet.
|
131
|
+
expect(twin.songs.size).must_equal 0
|
132
|
+
expect(album.songs.size).must_equal 1 # not synced, yet.
|
133
133
|
|
134
134
|
twin.save
|
135
135
|
|
136
|
-
twin.songs.size.must_equal 0
|
137
|
-
album.songs.size.must_equal 0
|
138
|
-
song1.persisted
|
136
|
+
expect(twin.songs.size).must_equal 0
|
137
|
+
expect(album.songs.size).must_equal 0
|
138
|
+
expect(song1.persisted?).must_equal true
|
139
139
|
end
|
140
140
|
|
141
141
|
# non-existant delete.
|
142
142
|
it do
|
143
143
|
twin.songs.delete("non-existant") # won't delete anything.
|
144
|
-
twin.songs.size.must_equal 1
|
144
|
+
expect(twin.songs.size).must_equal 1
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -151,14 +151,14 @@ class TwinCollectionActiveRecordTest < MiniTest::Spec
|
|
151
151
|
it do
|
152
152
|
twin.songs.destroy(twin.songs.first)
|
153
153
|
|
154
|
-
twin.songs.size.must_equal 0
|
155
|
-
album.songs.size.must_equal 1 # not synced, yet.
|
154
|
+
expect(twin.songs.size).must_equal 0
|
155
|
+
expect(album.songs.size).must_equal 1 # not synced, yet.
|
156
156
|
|
157
157
|
twin.save
|
158
158
|
|
159
|
-
twin.songs.size.must_equal 0
|
160
|
-
album.songs.size.must_equal 0
|
161
|
-
song1.persisted
|
159
|
+
expect(twin.songs.size).must_equal 0
|
160
|
+
expect(album.songs.size).must_equal 0
|
161
|
+
expect(song1.persisted?).must_equal false
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -169,11 +169,11 @@ class TwinCollectionActiveRecordTest < MiniTest::Spec
|
|
169
169
|
it do
|
170
170
|
twin = Twin::Album.new(album)
|
171
171
|
|
172
|
-
twin.songs.added.must_equal []
|
172
|
+
expect(twin.songs.added).must_equal []
|
173
173
|
twin.songs << song2
|
174
|
-
twin.songs.added.must_equal [twin.songs[1]]
|
174
|
+
expect(twin.songs.added).must_equal [twin.songs[1]]
|
175
175
|
twin.songs.insert(2, Song.new)
|
176
|
-
twin.songs.added.must_equal [twin.songs[1], twin.songs[2]]
|
176
|
+
expect(twin.songs.added).must_equal [twin.songs[1], twin.songs[2]]
|
177
177
|
|
178
178
|
# TODO: what to do if we override an item (insert)?
|
179
179
|
end
|
@@ -185,20 +185,20 @@ class TwinCollectionActiveRecordTest < MiniTest::Spec
|
|
185
185
|
it do
|
186
186
|
twin = Twin::Album.new(album)
|
187
187
|
|
188
|
-
twin.songs.deleted.must_equal []
|
188
|
+
expect(twin.songs.deleted).must_equal []
|
189
189
|
|
190
190
|
twin.songs.delete(deleted1 = twin.songs[-1])
|
191
191
|
twin.songs.delete(deleted2 = twin.songs[-1])
|
192
192
|
|
193
|
-
twin.songs.must_equal [twin.songs[0]]
|
193
|
+
expect(twin.songs).must_equal [twin.songs[0]]
|
194
194
|
|
195
|
-
twin.songs.deleted.must_equal [deleted1, deleted2]
|
195
|
+
expect(twin.songs.deleted).must_equal [deleted1, deleted2]
|
196
196
|
end
|
197
197
|
|
198
198
|
# non-existant delete.
|
199
199
|
it do
|
200
200
|
twin.songs.delete("non-existant") # won't delete anything.
|
201
|
-
twin.songs.deleted.must_equal []
|
201
|
+
expect(twin.songs.deleted).must_equal []
|
202
202
|
end
|
203
203
|
end
|
204
204
|
end
|
@@ -223,24 +223,24 @@ class CollectionUnitTest < MiniTest::Spec
|
|
223
223
|
|
224
224
|
# #insert(index, model)
|
225
225
|
it do
|
226
|
-
collection.insert(0, Model::Album.new).must_be_instance_of Twin::Album
|
226
|
+
expect(collection.insert(0, Model::Album.new)).must_be_instance_of Twin::Album
|
227
227
|
end
|
228
228
|
|
229
229
|
# #append(model)
|
230
230
|
it do
|
231
|
-
collection.append(Model::Album.new).must_be_instance_of Twin::Album
|
232
|
-
collection[0].must_be_instance_of Twin::Album
|
231
|
+
expect(collection.append(Model::Album.new)).must_be_instance_of Twin::Album
|
232
|
+
expect(collection[0]).must_be_instance_of Twin::Album
|
233
233
|
|
234
234
|
# allows subsequent calls.
|
235
235
|
collection.append(Model::Album.new)
|
236
|
-
collection[1].must_be_instance_of Twin::Album
|
236
|
+
expect(collection[1]).must_be_instance_of Twin::Album
|
237
237
|
|
238
|
-
collection.size.must_equal 2
|
238
|
+
expect(collection.size).must_equal 2
|
239
239
|
end
|
240
240
|
|
241
241
|
# #<<
|
242
242
|
it do
|
243
|
-
(collection << Model::Album.new).must_be_instance_of Array
|
244
|
-
collection[0].must_be_instance_of Twin::Album
|
243
|
+
expect((collection << Model::Album.new)).must_be_instance_of Array
|
244
|
+
expect(collection[0]).must_be_instance_of Twin::Album
|
245
245
|
end
|
246
246
|
end
|
@@ -26,34 +26,34 @@ class TwinCompositionTest < MiniTest::Spec
|
|
26
26
|
let (:request) { Request.new(song: song, requester: requester) }
|
27
27
|
|
28
28
|
it do
|
29
|
-
request.song_title.must_equal "Extraction"
|
30
|
-
request.song_id.must_equal 2
|
31
|
-
request.name.must_equal "Greg Howe"
|
32
|
-
request.id.must_equal 1
|
29
|
+
expect(request.song_title).must_equal "Extraction"
|
30
|
+
expect(request.song_id).must_equal 2
|
31
|
+
expect(request.name).must_equal "Greg Howe"
|
32
|
+
expect(request.id).must_equal 1
|
33
33
|
|
34
34
|
request.song_title = "Tease"
|
35
35
|
request.name = "Wooten"
|
36
36
|
|
37
37
|
|
38
|
-
request.song_title.must_equal "Tease"
|
39
|
-
request.name.must_equal "Wooten"
|
38
|
+
expect(request.song_title).must_equal "Tease"
|
39
|
+
expect(request.name).must_equal "Wooten"
|
40
40
|
|
41
41
|
# does not write to model.
|
42
|
-
song.title.must_equal "Extraction"
|
43
|
-
requester.name.must_equal "Greg Howe"
|
42
|
+
expect(song.title).must_equal "Extraction"
|
43
|
+
expect(requester.name).must_equal "Greg Howe"
|
44
44
|
|
45
45
|
|
46
46
|
res = request.save
|
47
|
-
res.must_equal true
|
47
|
+
expect(res).must_equal true
|
48
48
|
|
49
49
|
# make sure models got synced and saved.
|
50
|
-
song.id.must_equal 2
|
51
|
-
song.title.must_equal "Tease"
|
52
|
-
requester.id.must_equal 1
|
53
|
-
requester.name.must_equal "Wooten"
|
50
|
+
expect(song.id).must_equal 2
|
51
|
+
expect(song.title).must_equal "Tease"
|
52
|
+
expect(requester.id).must_equal 1
|
53
|
+
expect(requester.name).must_equal "Wooten"
|
54
54
|
|
55
|
-
song.saved
|
56
|
-
requester.saved
|
55
|
+
expect(song.saved?).must_equal true
|
56
|
+
expect(requester.saved?).must_equal true
|
57
57
|
end
|
58
58
|
|
59
59
|
# save with block.
|
@@ -63,8 +63,8 @@ class TwinCompositionTest < MiniTest::Spec
|
|
63
63
|
request.captcha = "Awesome!"
|
64
64
|
|
65
65
|
# does not write to model.
|
66
|
-
song.title.must_equal "Extraction"
|
67
|
-
requester.name.must_equal "Greg Howe"
|
66
|
+
expect(song.title).must_equal "Extraction"
|
67
|
+
expect(requester.name).must_equal "Greg Howe"
|
68
68
|
|
69
69
|
|
70
70
|
nested_hash = nil
|
@@ -72,13 +72,13 @@ class TwinCompositionTest < MiniTest::Spec
|
|
72
72
|
nested_hash = hash
|
73
73
|
end
|
74
74
|
|
75
|
-
nested_hash.must_equal(:song=>{"title"=>"Tease", "id"=>2}, :requester=>{"name"=>"Wooten", "id"=>1, "captcha"=>"Awesome!"})
|
75
|
+
expect(nested_hash).must_equal(:song=>{"title"=>"Tease", "id"=>2}, :requester=>{"name"=>"Wooten", "id"=>1, "captcha"=>"Awesome!"})
|
76
76
|
end
|
77
77
|
|
78
78
|
# save with one unsaveable model.
|
79
79
|
#save returns result.
|
80
80
|
it do
|
81
81
|
song.instance_eval { def save; false; end }
|
82
|
-
request.save.must_equal false
|
82
|
+
expect(request.save).must_equal false
|
83
83
|
end
|
84
|
-
end
|
84
|
+
end
|
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.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
|