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
data/test/twin/sync_test.rb
CHANGED
@@ -47,23 +47,23 @@ class TwinSyncTest < MiniTest::Spec
|
|
47
47
|
fill_out!(twin)
|
48
48
|
|
49
49
|
# not written to model, yet.
|
50
|
-
album.name.must_be_nil
|
51
|
-
album.songs[0].title.must_be_nil
|
52
|
-
album.songs[1].title.must_be_nil
|
53
|
-
album.songs[1].composer.name.must_be_nil
|
54
|
-
album.artist.name.must_be_nil
|
50
|
+
expect(album.name).must_be_nil
|
51
|
+
expect(album.songs[0].title).must_be_nil
|
52
|
+
expect(album.songs[1].title).must_be_nil
|
53
|
+
expect(album.songs[1].composer.name).must_be_nil
|
54
|
+
expect(album.artist.name).must_be_nil
|
55
55
|
|
56
56
|
twin.sync
|
57
57
|
|
58
|
-
album.name.must_equal "Live And Dangerous"
|
59
|
-
album.songs[0].must_be_instance_of Model::Song
|
60
|
-
album.songs[1].must_be_instance_of Model::Song
|
61
|
-
album.songs[0].title.must_equal "Southbound"
|
62
|
-
album.songs[1].title.must_equal "The Boys Are Back In Town"
|
63
|
-
album.songs[1].composer.must_be_instance_of Model::Artist
|
64
|
-
album.songs[1].composer.name.must_equal "Lynott"
|
65
|
-
album.artist.must_be_instance_of Model::Artist
|
66
|
-
album.artist.name.must_equal "Thin Lizzy"
|
58
|
+
expect(album.name).must_equal "Live And Dangerous"
|
59
|
+
expect(album.songs[0]).must_be_instance_of Model::Song
|
60
|
+
expect(album.songs[1]).must_be_instance_of Model::Song
|
61
|
+
expect(album.songs[0].title).must_equal "Southbound"
|
62
|
+
expect(album.songs[1].title).must_equal "The Boys Are Back In Town"
|
63
|
+
expect(album.songs[1].composer).must_be_instance_of Model::Artist
|
64
|
+
expect(album.songs[1].composer.name).must_equal "Lynott"
|
65
|
+
expect(album.artist).must_be_instance_of Model::Artist
|
66
|
+
expect(album.artist.name).must_equal "Thin Lizzy"
|
67
67
|
end
|
68
68
|
|
69
69
|
# with empty, not populated model.
|
@@ -82,16 +82,16 @@ class TwinSyncTest < MiniTest::Spec
|
|
82
82
|
twin.songs[1].composer.name = "Lynott"
|
83
83
|
|
84
84
|
# not written to model, yet.
|
85
|
-
album.name.must_be_nil
|
86
|
-
album.songs.must_equal []
|
87
|
-
album.artist.must_be_nil
|
85
|
+
expect(album.name).must_be_nil
|
86
|
+
expect(album.songs).must_equal []
|
87
|
+
expect(album.artist).must_be_nil
|
88
88
|
|
89
89
|
twin.sync # this assigns a new collection via #songs=.
|
90
90
|
|
91
|
-
album.name.must_equal "Live And Dangerous"
|
92
|
-
album.songs[0].title.must_equal "Southbound"
|
93
|
-
album.songs[1].title.must_equal "The Boys Are Back In Town"
|
94
|
-
album.songs[1].composer.name.must_equal "Lynott"
|
91
|
+
expect(album.name).must_equal "Live And Dangerous"
|
92
|
+
expect(album.songs[0].title).must_equal "Southbound"
|
93
|
+
expect(album.songs[1].title).must_equal "The Boys Are Back In Town"
|
94
|
+
expect(album.songs[1].composer.name).must_equal "Lynott"
|
95
95
|
end
|
96
96
|
|
97
97
|
# save with block.
|
@@ -107,14 +107,14 @@ class TwinSyncTest < MiniTest::Spec
|
|
107
107
|
nested_hash = hash
|
108
108
|
end
|
109
109
|
|
110
|
-
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"}})
|
110
|
+
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"}})
|
111
111
|
|
112
112
|
# nothing written to model.
|
113
|
-
album.name.must_be_nil
|
114
|
-
album.songs[0].title.must_be_nil
|
115
|
-
album.songs[1].title.must_be_nil
|
116
|
-
album.songs[1].composer.name.must_be_nil
|
117
|
-
album.artist.name.must_be_nil
|
113
|
+
expect(album.name).must_be_nil
|
114
|
+
expect(album.songs[0].title).must_be_nil
|
115
|
+
expect(album.songs[1].title).must_be_nil
|
116
|
+
expect(album.songs[1].composer.name).must_be_nil
|
117
|
+
expect(album.artist.name).must_be_nil
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "nil values" do
|
@@ -127,7 +127,7 @@ class TwinSyncTest < MiniTest::Spec
|
|
127
127
|
nested_hash = nil
|
128
128
|
twin.sync { |hash| nested_hash = hash }
|
129
129
|
|
130
|
-
nested_hash.must_equal({"name"=>nil, "artist"=>nil})
|
130
|
+
expect(nested_hash).must_equal({"name"=>nil, "artist"=>nil})
|
131
131
|
end
|
132
132
|
|
133
133
|
it "includes empty collections" do
|
@@ -139,7 +139,7 @@ class TwinSyncTest < MiniTest::Spec
|
|
139
139
|
nested_hash = nil
|
140
140
|
twin.sync { |hash| nested_hash = hash }
|
141
141
|
|
142
|
-
nested_hash.must_equal({"name"=>nil, "songs"=>[], "artist"=>nil})
|
142
|
+
expect(nested_hash).must_equal({"name"=>nil, "songs"=>[], "artist"=>nil})
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
data/test/twin/twin_test.rb
CHANGED
@@ -35,17 +35,17 @@ class TwinTest < MiniTest::Spec
|
|
35
35
|
twin = Twin::Song.new(song)
|
36
36
|
song.id = 2
|
37
37
|
# :from maps public name
|
38
|
-
twin.title.must_equal "Broken" # public: #record_name
|
39
|
-
twin.id.must_equal 1
|
38
|
+
expect(twin.title).must_equal "Broken" # public: #record_name
|
39
|
+
expect(twin.id).must_equal 1
|
40
40
|
end
|
41
41
|
|
42
42
|
# allows passing options.
|
43
43
|
it do
|
44
44
|
# override twin's value...
|
45
|
-
Twin::Song.new(song, :title => "Kenny").title.must_equal "Kenny"
|
45
|
+
expect(Twin::Song.new(song, :title => "Kenny").title).must_equal "Kenny"
|
46
46
|
|
47
47
|
# .. but do not write to the model!
|
48
|
-
song.title.must_equal "Broken"
|
48
|
+
expect(song.title).must_equal "Broken"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -59,28 +59,28 @@ class TwinTest < MiniTest::Spec
|
|
59
59
|
twin.album = album # this is a model, not a twin.
|
60
60
|
|
61
61
|
# updates twin
|
62
|
-
twin.id.must_equal 3
|
63
|
-
twin.title.must_equal "Lucky"
|
62
|
+
expect(twin.id).must_equal 3
|
63
|
+
expect(twin.title).must_equal "Lucky"
|
64
64
|
|
65
65
|
# setter for nested property will twin value.
|
66
66
|
twin.album.extend(Disposable::Comparable)
|
67
|
-
assert twin.album == Twin::Album.new(album) # FIXME: why does must_equal not call #== ?
|
67
|
+
assert twin.album == Twin::Album.new(album) # FIXME: why does) must_equal not call #== ?
|
68
68
|
|
69
69
|
# setter for nested collection.
|
70
70
|
|
71
71
|
# DOES NOT update model
|
72
|
-
song.id.must_equal 1
|
73
|
-
song.title.must_equal "Broken"
|
72
|
+
expect(song.id).must_equal 1
|
73
|
+
expect(song.title).must_equal "Broken"
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "deleting" do
|
77
77
|
it "allows overwriting nested twin with nil" do
|
78
78
|
album = Model::Album.new(1, "Uncertain Terms", [], Model::Artist.new("Greg Howe"))
|
79
79
|
twin = Twin::Album.new(album)
|
80
|
-
twin.artist.id.must_equal "Greg Howe"
|
80
|
+
expect(twin.artist.id).must_equal "Greg Howe"
|
81
81
|
|
82
82
|
twin.artist = nil
|
83
|
-
twin.artist.must_be_nil
|
83
|
+
expect(twin.artist).must_be_nil
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -109,8 +109,8 @@ class OverridingAccessorsTest < TwinTest
|
|
109
109
|
end
|
110
110
|
|
111
111
|
let (:model) { Model::Song.new(1, "A Tale That Wasn't Right") }
|
112
|
-
it { Song.new(model).title.must_equal "a tale that wasn't right" }
|
113
|
-
it { Song.new(model).id.must_equal 2 }
|
112
|
+
it { expect(Song.new(model).title).must_equal "a tale that wasn't right" }
|
113
|
+
it { expect(Song.new(model).id).must_equal 2 }
|
114
114
|
end
|
115
115
|
|
116
116
|
|
@@ -148,7 +148,7 @@ class AccessorsTest < Minitest::Spec
|
|
148
148
|
|
149
149
|
it do
|
150
150
|
twin = Twin.new(Song.new("bla"))
|
151
|
-
twin.format.must_equal "bla"
|
151
|
+
expect(twin.format).must_equal "bla"
|
152
152
|
twin.format = "blubb"
|
153
153
|
end
|
154
154
|
end
|
data/test/twin/unnest_test.rb
CHANGED
@@ -16,22 +16,22 @@ class UnnestTest < MiniTest::Spec
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "copies property option" do
|
19
|
-
Twin.definitions.get(:id).extend(Declarative::Inspect).inspect.must_equal %{#<Disposable::Twin::Definition: @options={:nice=>\"yes\", :private_name=>:id, :name=>\"id\", :readable=>false, :writeable=>false}>}
|
20
|
-
Twin.definitions.get(:ids).extend(Declarative::Inspect).inspect.must_equal %{#<Disposable::Twin::Definition: @options={:status=>\"healthy\", :collection=>true, :private_name=>:ids, :name=>\"ids\", :readable=>false, :writeable=>false}>}
|
19
|
+
expect(Twin.definitions.get(:id).extend(Declarative::Inspect).inspect).must_equal %{#<Disposable::Twin::Definition: @options={:nice=>\"yes\", :private_name=>:id, :name=>\"id\", :readable=>false, :writeable=>false}>}
|
20
|
+
expect(Twin.definitions.get(:ids).extend(Declarative::Inspect).inspect).must_equal %{#<Disposable::Twin::Definition: @options={:status=>\"healthy\", :collection=>true, :private_name=>:ids, :name=>\"ids\", :readable=>false, :writeable=>false}>}
|
21
21
|
# also copies :nested.
|
22
|
-
Twin.definitions.get(:email).extend(Declarative::Inspect).inspect.must_equal %{#<Disposable::Twin::Definition: @options={:private_name=>:email, :nested=>#<Class:>, :name=>\"email\", :readable=>false, :writeable=>false}>}
|
22
|
+
expect(Twin.definitions.get(:email).extend(Declarative::Inspect).inspect).must_equal %{#<Disposable::Twin::Definition: @options={:private_name=>:email, :nested=>#<Class:>, :name=>\"email\", :readable=>false, :writeable=>false}>}
|
23
23
|
end
|
24
24
|
|
25
25
|
it "exposes accessors on top-level twin" do
|
26
26
|
twin = Twin.new(OpenStruct.new(content: OpenStruct.new()))
|
27
27
|
|
28
|
-
twin.email.must_be_nil
|
28
|
+
expect(twin.email).must_be_nil
|
29
29
|
twin.email= 2
|
30
|
-
twin.email.model.must_equal 2
|
30
|
+
expect(twin.email.model).must_equal 2
|
31
31
|
|
32
32
|
|
33
|
-
twin.id.must_be_nil
|
33
|
+
expect(twin.id).must_be_nil
|
34
34
|
twin.id = 1
|
35
|
-
twin.id.must_equal 1
|
35
|
+
expect(twin.id).must_equal 1
|
36
36
|
end
|
37
37
|
end
|
data/test/twin/virtual_test.rb
CHANGED
@@ -11,7 +11,7 @@ class VirtualTest < MiniTest::Spec
|
|
11
11
|
it {
|
12
12
|
twin.credit_card_number = "123"
|
13
13
|
|
14
|
-
twin.credit_card_number.must_equal "123" # this is still readable in the UI.
|
14
|
+
expect(twin.credit_card_number).must_equal "123" # this is still readable in the UI.
|
15
15
|
|
16
16
|
twin.sync
|
17
17
|
|
@@ -20,7 +20,7 @@ class VirtualTest < MiniTest::Spec
|
|
20
20
|
hash = nested
|
21
21
|
end
|
22
22
|
|
23
|
-
hash.must_equal("credit_card_number"=> "123")
|
23
|
+
expect(hash).must_equal("credit_card_number"=> "123")
|
24
24
|
}
|
25
25
|
|
26
26
|
describe "setter should never be called with virtual:true" do
|
@@ -33,7 +33,7 @@ class VirtualTest < MiniTest::Spec
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "what" do
|
36
|
-
Raising.new(Object.new).id.must_be_nil
|
36
|
+
expect(Raising.new(Object.new).id).must_be_nil
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/test/twin/writeable_test.rb
CHANGED
@@ -30,20 +30,20 @@ class WriteableTest < MiniTest::Spec
|
|
30
30
|
let (:twin) { PasswordForm.new(cred) }
|
31
31
|
|
32
32
|
it {
|
33
|
-
twin.password.must_equal "secret"
|
34
|
-
twin.credit_card.name.must_equal "Jonny"
|
35
|
-
twin.credit_card.number.must_equal "0987654321"
|
33
|
+
expect(twin.password).must_equal "secret"
|
34
|
+
expect(twin.credit_card.name).must_equal "Jonny"
|
35
|
+
expect(twin.credit_card.number).must_equal "0987654321"
|
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
|
-
cred.inspect.must_equal '#<struct WriteableTest::Credentials password="secret", credit_card=#<struct WriteableTest::CreditCard name="Jonny", number="0987654321">>'
|
46
|
+
expect(cred.inspect).must_equal '#<struct WriteableTest::Credentials password="secret", credit_card=#<struct WriteableTest::CreditCard name="Jonny", number="0987654321">>'
|
47
47
|
|
48
48
|
# test sync{}.
|
49
49
|
hash = {}
|
@@ -51,6 +51,6 @@ class WriteableTest < MiniTest::Spec
|
|
51
51
|
hash = nested
|
52
52
|
end
|
53
53
|
|
54
|
-
hash.must_equal("password"=> "123", "credit_card"=>{"name"=>"Jonny", "number"=>"456"})
|
54
|
+
expect(hash).must_equal("password"=> "123", "credit_card"=>{"name"=>"Jonny", "number"=>"456"})
|
55
55
|
}
|
56
|
-
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disposable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uber
|
@@ -148,20 +148,6 @@ dependencies:
|
|
148
148
|
- - ">="
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
|
-
- !ruby/object:Gem::Dependency
|
152
|
-
name: sqlite3
|
153
|
-
requirement: !ruby/object:Gem::Requirement
|
154
|
-
requirements:
|
155
|
-
- - "~>"
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 1.3.0
|
158
|
-
type: :development
|
159
|
-
prerelease: false
|
160
|
-
version_requirements: !ruby/object:Gem::Requirement
|
161
|
-
requirements:
|
162
|
-
- - "~>"
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
version: 1.3.0
|
165
151
|
- !ruby/object:Gem::Dependency
|
166
152
|
name: dry-types
|
167
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,8 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
259
|
- !ruby/object:Gem::Version
|
274
260
|
version: '0'
|
275
261
|
requirements: []
|
276
|
-
|
277
|
-
rubygems_version: 2.7.6.2
|
262
|
+
rubygems_version: 3.0.6
|
278
263
|
signing_key:
|
279
264
|
specification_version: 4
|
280
265
|
summary: Decorators on top of your ORM layer with change tracking, collection semantics
|