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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d17fbfc73eb6b25b90136d515733b694ac2631ad3861f47d62dde5517ec394b
4
- data.tar.gz: be69f4aaed8fda60749dcb3dc3188bb57def014cd91715198baab0eebd801386
3
+ metadata.gz: 60b151f3e5bb984a08ae4631bb836caa4b08b62e64b57d260a93e156129c4729
4
+ data.tar.gz: f793d20d7b3fb398d07baddbaf9c835e1944b4f6bfe60f1fb36eb325bf6a5919
5
5
  SHA512:
6
- metadata.gz: eb4b2eca60ed3001be80d50eff19fe008abf68030a99101eb0282b5fe65d091c21d62537a3dcbfafb32484e985d4e670377d701413de25832b8195f0ff08cdeb
7
- data.tar.gz: b95131034f38c0907672943108c0633164817981ba0107c508e618467b69f0c7f2e914c91d1152219b3488e6432cd1a9839e394704a1465e1792ef540140613e
6
+ metadata.gz: e8ab3254e28140e886dc65341cb8d3f8ae53328f7bb304cd8e0760869e894440c615cafaae1b2d5b2aab1bf721d86d5d659fc40ac1f7301bb6a39d1303cbea02
7
+ data.tar.gz: ac09aaa979ddc3de44d409740d3d8a1121d07b498c59ac2d77496091c799b692fcc22d7f495174886a75491d71f230e1544fb87ebc89713e0d97d5bf22db9d82
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
17
  Gemfile*.lock
18
+ .rubocop*
@@ -1,42 +1,44 @@
1
1
  language: ruby
2
- sudo: false
3
2
  rvm:
4
3
  - ruby-head
4
+ - 2.6
5
5
  - 2.5
6
6
  - 2.4
7
- - 2.3
8
- - 2.2
9
7
  env:
10
- - "DRY_TYPES=1.1"
11
- - "DRY_TYPES=1.0"
12
- - "DRY_TYPES=0.15"
13
- - "DRY_TYPES=0.13"
14
- - "DRY_TYPES=0.12"
15
- - "ACTIVERECORD=5.0"
16
- - "ACTIVERECORD=5.1"
17
- - "ACTIVERECORD=5.2"
8
+ - "ACTIVERECORD=5.0 DRY_TYPES=0.13"
9
+ - "ACTIVERECORD=5.0 DRY_TYPES=0.14"
10
+ - "ACTIVERECORD=5.0 DRY_TYPES=0.15"
11
+ - "ACTIVERECORD=5.0 DRY_TYPES=1.0"
12
+ - "ACTIVERECORD=5.0 DRY_TYPES=1.1"
13
+ - "ACTIVERECORD=5.0 DRY_TYPES=1.2"
14
+ - "ACTIVERECORD=5.1 DRY_TYPES=0.13"
15
+ - "ACTIVERECORD=5.1 DRY_TYPES=0.14"
16
+ - "ACTIVERECORD=5.1 DRY_TYPES=0.15"
17
+ - "ACTIVERECORD=5.1 DRY_TYPES=1.0"
18
+ - "ACTIVERECORD=5.1 DRY_TYPES=1.1"
19
+ - "ACTIVERECORD=5.1 DRY_TYPES=1.2"
20
+ - "ACTIVERECORD=5.2 DRY_TYPES=0.13"
21
+ - "ACTIVERECORD=5.2 DRY_TYPES=0.14"
22
+ - "ACTIVERECORD=5.2 DRY_TYPES=0.15"
23
+ - "ACTIVERECORD=5.2 DRY_TYPES=1.0"
24
+ - "ACTIVERECORD=5.2 DRY_TYPES=1.1"
25
+ - "ACTIVERECORD=5.2 DRY_TYPES=1.2"
26
+ - "ACTIVERECORD=6.0 DRY_TYPES=0.13"
27
+ - "ACTIVERECORD=6.0 DRY_TYPES=0.14"
28
+ - "ACTIVERECORD=6.0 DRY_TYPES=0.15"
29
+ - "ACTIVERECORD=6.0 DRY_TYPES=1.0"
30
+ - "ACTIVERECORD=6.0 DRY_TYPES=1.1"
31
+ - "ACTIVERECORD=6.0 DRY_TYPES=1.2"
18
32
  gemfile:
19
33
  - Gemfile
20
34
  matrix:
21
35
  fast_finish: true
22
- include:
23
- - { rvm: 2.3, env: ACTIVERECORD=4.2 }
24
- - { rvm: 2.2, env: ACTIVERECORD=4.2 }
25
- - { rvm: 2.3, env: ACTIVERECORD=4.1 }
26
- - { rvm: 2.2, env: ACTIVERECORD=4.1 }
27
- - rvm: 2.1
28
- env:
29
- - ACTIVERECORD=4.1
30
- - DRY_TYPES=0.10
31
36
  allow_failures:
32
37
  - rvm: ruby-head
33
- - env: ACTIVERECORD=4.1
34
- - rvm: 2.1
35
- - rvm: 2.2
36
38
  exclude:
37
- - { rvm: 2.3, env: DRY_TYPES=1.1 }
38
- - { rvm: 2.2, env: DRY_TYPES=1.1 }
39
- - { rvm: 2.3, env: DRY_TYPES=1.0 }
40
- - { rvm: 2.2, env: DRY_TYPES=1.0 }
41
- - { rvm: 2.3, env: DRY_TYPES=0.15 }
42
- - { rvm: 2.2, env: DRY_TYPES=0.15 }
39
+ - {rvm: 2.4, env: "ACTIVERECORD=6.0 DRY_TYPES=0.13"}
40
+ - {rvm: 2.4, env: "ACTIVERECORD=6.0 DRY_TYPES=0.14"}
41
+ - {rvm: 2.4, env: "ACTIVERECORD=6.0 DRY_TYPES=0.15"}
42
+ - {rvm: 2.4, env: "ACTIVERECORD=6.0 DRY_TYPES=1.0"}
43
+ - {rvm: 2.4, env: "ACTIVERECORD=6.0 DRY_TYPES=1.1"}
44
+ - {rvm: 2.4, env: "ACTIVERECORD=6.0 DRY_TYPES=1.2"}
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.4.7
2
+
3
+ * Deprecation warning for nilify options for dry-v >= 1.x
4
+ * Fix initializer struct when using `false` as value
5
+
1
6
  # 0.4.6
2
7
 
3
8
  * Remove deprecation warnings for newer versions of dry-types
data/Gemfile CHANGED
@@ -7,4 +7,4 @@ gem "minitest-line"
7
7
  gem gem_name, dependency
8
8
  end
9
9
 
10
-
10
+ gem "sqlite3", ENV.fetch('ACTIVERECORD', '5.2').to_f >= 6 ? '~> 1.4' : '~> 1.3.0'
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake"
27
27
  spec.add_development_dependency "minitest"
28
28
  spec.add_development_dependency "activerecord"#, "4.2.5"
29
- spec.add_development_dependency "sqlite3", '~> 1.3.0'
30
29
  spec.add_development_dependency "dry-types"# "~> 0.6"
31
30
  # spec.add_development_dependency "database_cleaner"
32
31
  end
@@ -18,7 +18,10 @@ module Disposable::Twin::Coercion
18
18
  end
19
19
 
20
20
  def coercing_setter!(name, type, nilify=false)
21
- type = type ? (DRY_TYPES_CONSTANT::Nil | type) : DRY_TYPES_CONSTANT::Nil if nilify
21
+ # TODO: remove nilily with next release (0.5) for new dry-type versions
22
+ type = type ? (DRY_TYPES_CONSTANT::Nil | type) : DRY_TYPES_CONSTANT::Nil if nilify
23
+
24
+ warn "DEPRECATION WARNING [Disposable]: nilify is deprecated and it will be removed with the next release" if nilify && DRY_TYPES_VERSION >= Gem::Version.new("1.0.0")
22
25
 
23
26
  mod = Module.new do
24
27
  define_method("#{name}=") do |value|
@@ -6,7 +6,9 @@ class Disposable::Twin
6
6
  module Struct
7
7
  def read_value_for(dfn, options)
8
8
  name = dfn[:name]
9
- @model[name.to_s] || @model[name.to_sym] # TODO: test sym vs. str.
9
+ # TODO: test sym vs. str.
10
+ return unless key_value = model.to_h.find { |k, _| k.to_sym == name.to_sym }
11
+ key_value.last
10
12
  end
11
13
 
12
14
  def sync_hash_representer # TODO: make this without representable, please.
@@ -1,3 +1,3 @@
1
1
  module Disposable
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -55,7 +55,7 @@ class CallbackGroupTest < MiniTest::Spec
55
55
  album = Album.new(songs: [Song.new(title: "Dead To Me"), Song.new(title: "Diesel Boy")])
56
56
  twin = AlbumTwin.new(album)
57
57
 
58
- Group.new(twin).().invocations.must_equal [
58
+ expect(Group.new(twin).().invocations).must_equal [
59
59
  [:on_change, :change!, []],
60
60
  [:on_add, :notify_album!, []],
61
61
  [:on_add, :reset_song!, []],
@@ -76,7 +76,7 @@ class CallbackGroupTest < MiniTest::Spec
76
76
 
77
77
  group = Group.new(twin).(content: content)
78
78
 
79
- group.invocations.must_equal [
79
+ expect(group.invocations).must_equal [
80
80
  [:on_change, :change!, [twin]],
81
81
  [:on_add, :notify_album!, [twin.songs[0], twin.songs[1]]],
82
82
  [:on_add, :reset_song!, [twin.songs[0], twin.songs[1]]],
@@ -85,8 +85,8 @@ class CallbackGroupTest < MiniTest::Spec
85
85
  [:on_update, :expire_cache!, []],
86
86
  ]
87
87
 
88
- content.must_equal "notify_album!notify_album!reset_song!reset_song!"
89
- group.output.must_equal "Album has changed!"
88
+ expect(content).must_equal "notify_album!notify_album!reset_song!reset_song!"
89
+ expect(group.output).must_equal "Album has changed!"
90
90
  end
91
91
 
92
92
 
@@ -129,7 +129,7 @@ class CallbackGroupTest < MiniTest::Spec
129
129
 
130
130
  # pp group.invocations
131
131
 
132
- group.invocations.must_equal [
132
+ expect(group.invocations).must_equal [
133
133
  [:on_change, :change!, [twin]],
134
134
  [:on_add, :notify_album!, [twin.songs[0]]],
135
135
  [:on_add, :reset_song!, [twin.songs[0]]],
@@ -138,7 +138,7 @@ class CallbackGroupTest < MiniTest::Spec
138
138
  [:on_update, :expire_cache!, []],
139
139
  ]
140
140
 
141
- content.must_equal "Op: changed! [CallbackGroupTest::Operation]Op: notify_album! [CallbackGroupTest::Operation]Op: reset_song! [CallbackGroupTest::Operation]"
141
+ expect(content).must_equal "Op: changed! [CallbackGroupTest::Operation]Op: notify_album! [CallbackGroupTest::Operation]Op: reset_song! [CallbackGroupTest::Operation]"
142
142
  end
143
143
  end
144
144
 
@@ -157,12 +157,12 @@ class CallbackGroupInheritanceTest < MiniTest::Spec
157
157
  end
158
158
 
159
159
  it do
160
- Group.hooks.size.must_equal 4
161
- Group.hooks[0].to_s.must_equal "[:on_change, :change!, {}]"
160
+ expect(Group.hooks.size).must_equal 4
161
+ expect(Group.hooks[0].to_s).must_equal "[:on_change, :change!, {}]"
162
162
  # Group.hooks[1][1][:nested].hooks.to_s.must_equal "[[:on_add, [:notify_album!]],[:on_add, [:reset_song!]]]"
163
- Group.hooks[2].to_s.must_equal "[:on_change, :rehash_name!, {:property=>:title}]"
163
+ expect(Group.hooks[2].to_s).must_equal "[:on_change, :rehash_name!, {:property=>:title}]"
164
164
 
165
- Group.definitions.get(Group.hooks[3][1])[:nested].hooks.to_s.must_equal "[[:on_change, :sing!, {}]]"
165
+ expect(Group.definitions.get(Group.hooks[3][1])[:nested].hooks.to_s).must_equal "[[:on_change, :sing!, {}]]"
166
166
  end
167
167
 
168
168
  class EmptyGroup < Group
@@ -171,7 +171,7 @@ class CallbackGroupInheritanceTest < MiniTest::Spec
171
171
 
172
172
 
173
173
  it do
174
- EmptyGroup.hooks.size.must_equal 4
174
+ expect(EmptyGroup.hooks.size).must_equal 4
175
175
  # TODO:
176
176
  end
177
177
 
@@ -183,10 +183,10 @@ class CallbackGroupInheritanceTest < MiniTest::Spec
183
183
  end
184
184
 
185
185
  it do
186
- Group.hooks.size.must_equal 4
186
+ expect(Group.hooks.size).must_equal 4
187
187
  # pp EnhancedGroup.hooks
188
- EnhancedGroup.hooks.size.must_equal 6
189
- EnhancedGroup.definitions.get(EnhancedGroup.hooks[5][1])[:nested].hooks.to_s.must_equal "[[:on_add, :rewind!, {}]]"
188
+ expect(EnhancedGroup.hooks.size).must_equal 6
189
+ expect(EnhancedGroup.definitions.get(EnhancedGroup.hooks[5][1])[:nested].hooks.to_s).must_equal "[[:on_add, :rewind!, {}]]"
190
190
  end
191
191
 
192
192
  class EnhancedWithInheritGroup < EnhancedGroup
@@ -199,13 +199,13 @@ class CallbackGroupInheritanceTest < MiniTest::Spec
199
199
  end
200
200
 
201
201
  it do
202
- Group.hooks.size.must_equal 4
203
- EnhancedGroup.hooks.size.must_equal 6
202
+ expect(Group.hooks.size).must_equal 4
203
+ expect(EnhancedGroup.hooks.size).must_equal 6
204
204
 
205
- EnhancedGroup.definitions.get(EnhancedGroup.hooks[5][1])[:nested].hooks.to_s.must_equal "[[:on_add, :rewind!, {}]]"
206
- EnhancedWithInheritGroup.hooks.size.must_equal 6
207
- EnhancedWithInheritGroup.definitions.get(EnhancedWithInheritGroup.hooks[1][1])[:nested].hooks.to_s.must_equal "[[:on_add, :rewind!, {}], [:on_add, :eat!, {}]]"
208
- EnhancedWithInheritGroup.definitions.get(EnhancedWithInheritGroup.hooks[3][1])[:nested].hooks.to_s.must_equal "[[:on_change, :sing!, {}], [:on_delete, :yell!, {}]]"
205
+ expect(EnhancedGroup.definitions.get(EnhancedGroup.hooks[5][1])[:nested].hooks.to_s).must_equal "[[:on_add, :rewind!, {}]]"
206
+ expect(EnhancedWithInheritGroup.hooks.size).must_equal 6
207
+ expect(EnhancedWithInheritGroup.definitions.get(EnhancedWithInheritGroup.hooks[1][1])[:nested].hooks.to_s).must_equal "[[:on_add, :rewind!, {}], [:on_add, :eat!, {}]]"
208
+ expect(EnhancedWithInheritGroup.definitions.get(EnhancedWithInheritGroup.hooks[3][1])[:nested].hooks.to_s).must_equal "[[:on_change, :sing!, {}], [:on_delete, :yell!, {}]]"
209
209
  end
210
210
 
211
211
  class RemovingInheritGroup < Group
@@ -226,10 +226,10 @@ class CallbackGroupInheritanceTest < MiniTest::Spec
226
226
  # TODO: object_id tests for all nested representers.
227
227
 
228
228
  it do
229
- Group.hooks.size.must_equal 4
230
- RemovingInheritGroup.hooks.size.must_equal 3
231
- RemovingInheritGroup.definitions.get(RemovingInheritGroup.hooks[0][1])[:nested].hooks.to_s.must_equal "[[:on_add, :reset_song!, {}]]"
232
- RemovingInheritGroup.definitions.get(RemovingInheritGroup.hooks[2][1])[:nested].hooks.to_s.must_equal "[[:on_change, :sing!, {}]]"
229
+ expect(Group.hooks.size).must_equal 4
230
+ expect(RemovingInheritGroup.hooks.size).must_equal 3
231
+ expect(RemovingInheritGroup.definitions.get(RemovingInheritGroup.hooks[0][1])[:nested].hooks.to_s).must_equal "[[:on_add, :reset_song!, {}]]"
232
+ expect(RemovingInheritGroup.definitions.get(RemovingInheritGroup.hooks[2][1])[:nested].hooks.to_s).must_equal "[[:on_change, :sing!, {}]]"
233
233
  end
234
234
 
235
235
  # Group::clone
@@ -239,7 +239,7 @@ class CallbackGroupInheritanceTest < MiniTest::Spec
239
239
  end
240
240
 
241
241
  it do
242
- Group.hooks.size.must_equal 4
243
- ClonedGroup.hooks.size.must_equal 3
242
+ expect(Group.hooks.size).must_equal 4
243
+ expect(ClonedGroup.hooks.size).must_equal 3
244
244
  end
245
- end
245
+ end
@@ -46,7 +46,7 @@ class CallbacksTest < MiniTest::Spec
46
46
  it do
47
47
  invokes = []
48
48
  Callback.new(twin).on_create { |t| invokes << t }
49
- invokes.must_equal []
49
+ expect(invokes).must_equal []
50
50
  end
51
51
 
52
52
  # save, without any attributes changed.
@@ -55,7 +55,7 @@ class CallbacksTest < MiniTest::Spec
55
55
 
56
56
  invokes = []
57
57
  Callback.new(twin).on_create { |t| invokes << t }
58
- invokes.must_equal [twin]
58
+ expect(invokes).must_equal [twin]
59
59
  end
60
60
 
61
61
  # before and after save, with attributes changed
@@ -64,12 +64,12 @@ class CallbacksTest < MiniTest::Spec
64
64
  twin.name = "Run For Cover"
65
65
  invokes = []
66
66
  Callback.new(twin).on_create { |t| invokes << t }
67
- invokes.must_equal []
67
+ expect(invokes).must_equal []
68
68
 
69
69
  twin.save
70
70
 
71
71
  Callback.new(twin).on_create { |t| invokes << t }
72
- invokes.must_equal [twin]
72
+ expect(invokes).must_equal [twin]
73
73
  end
74
74
 
75
75
  # for collections.
@@ -80,12 +80,12 @@ class CallbacksTest < MiniTest::Spec
80
80
  invokes = []
81
81
 
82
82
  Callback.new(twin.songs).on_create { |t| invokes << t }
83
- invokes.must_equal []
83
+ expect(invokes).must_equal []
84
84
 
85
85
  twin.save
86
86
 
87
87
  Callback.new(twin.songs).on_create { |t| invokes << t }
88
- invokes.must_equal [twin.songs[0], twin.songs[2]]
88
+ expect(invokes).must_equal [twin.songs[0], twin.songs[2]]
89
89
  end
90
90
  end
91
91
 
@@ -96,7 +96,7 @@ class CallbacksTest < MiniTest::Spec
96
96
  it do
97
97
  invokes = []
98
98
  Callback.new(twin).on_update { |t| invokes << t }
99
- invokes.must_equal []
99
+ expect(invokes).must_equal []
100
100
  end
101
101
 
102
102
  # single twin.
@@ -106,40 +106,40 @@ class CallbacksTest < MiniTest::Spec
106
106
 
107
107
  invokes = []
108
108
  Callback.new(twin).on_update { |t| invokes << t }
109
- invokes.must_equal []
109
+ expect(invokes).must_equal []
110
110
 
111
111
  invokes = []
112
112
  twin.save
113
113
 
114
114
  Callback.new(twin).on_update { |t| invokes << t }
115
- invokes.must_equal []
115
+ expect(invokes).must_equal []
116
116
 
117
117
 
118
118
  # now with the persisted album.
119
119
  twin = AlbumTwin.new(album) # Album is persisted now.
120
120
 
121
121
  Callback.new(twin).on_update { |t| invokes << t }
122
- invokes.must_equal []
122
+ expect(invokes).must_equal []
123
123
 
124
124
  invokes = []
125
125
  twin.save
126
126
 
127
127
  # nothing has changed, yet.
128
128
  Callback.new(twin).on_update { |t| invokes << t }
129
- invokes.must_equal []
129
+ expect(invokes).must_equal []
130
130
 
131
131
  twin.name= "Corridors Of Power"
132
132
 
133
133
  # this will even trigger on_update before saving.
134
134
  Callback.new(twin).on_update { |t| invokes << t }
135
- invokes.must_equal [twin]
135
+ expect(invokes).must_equal [twin]
136
136
 
137
137
  invokes = []
138
138
  twin.save
139
139
 
140
140
  # name changed.
141
141
  Callback.new(twin).on_update { |t| invokes << t }
142
- invokes.must_equal [twin]
142
+ expect(invokes).must_equal [twin]
143
143
  end
144
144
 
145
145
  # for collections.
@@ -150,41 +150,41 @@ class CallbacksTest < MiniTest::Spec
150
150
 
151
151
  invokes = []
152
152
  Callback.new(twin.songs).on_update { |t| invokes << t }
153
- invokes.must_equal []
153
+ expect(invokes).must_equal []
154
154
 
155
155
  invokes = []
156
156
  twin.save
157
157
 
158
158
  # initial save is no update.
159
159
  Callback.new(twin.songs).on_update { |t| invokes << t }
160
- invokes.must_equal []
160
+ expect(invokes).must_equal []
161
161
 
162
162
 
163
163
  # now with the persisted album.
164
164
  twin = AlbumTwin.new(album) # Album is persisted now.
165
165
 
166
166
  Callback.new(twin.songs).on_update { |t| invokes << t }
167
- invokes.must_equal []
167
+ expect(invokes).must_equal []
168
168
 
169
169
  invokes = []
170
170
  twin.save
171
171
 
172
172
  # nothing has changed, yet.
173
173
  Callback.new(twin.songs).on_update { |t| invokes << t }
174
- invokes.must_equal []
174
+ expect(invokes).must_equal []
175
175
 
176
176
  twin.songs[1].title= "After The War"
177
177
  twin.songs[2].title= "Run For Cover"
178
178
 
179
179
  # # this will even trigger on_update before saving.
180
180
  Callback.new(twin.songs).on_update { |t| invokes << t }
181
- invokes.must_equal [twin.songs[1], twin.songs[2]]
181
+ expect(invokes).must_equal [twin.songs[1], twin.songs[2]]
182
182
 
183
183
  invokes = []
184
184
  twin.save
185
185
 
186
186
  Callback.new(twin.songs).on_update { |t| invokes << t }
187
- invokes.must_equal [twin.songs[1], twin.songs[2]]
187
+ expect(invokes).must_equal [twin.songs[1], twin.songs[2]]
188
188
  end
189
189
  # it do
190
190
  # album.songs << song1 = Song.new
@@ -210,7 +210,7 @@ class CallbacksTest < MiniTest::Spec
210
210
  it do
211
211
  invokes = []
212
212
  Callback.new(twin.songs).on_add { |t| invokes << t }
213
- invokes.must_equal []
213
+ expect(invokes).must_equal []
214
214
  end
215
215
 
216
216
  # collection present on initialize are not added.
@@ -220,7 +220,7 @@ class CallbacksTest < MiniTest::Spec
220
220
  album.songs = [ex_song, song]
221
221
 
222
222
  Callback.new(twin.songs).on_add { |t| invokes << t }
223
- invokes.must_equal []
223
+ expect(invokes).must_equal []
224
224
  end
225
225
 
226
226
  # items added after initialization are added.
@@ -232,14 +232,14 @@ class CallbacksTest < MiniTest::Spec
232
232
  twin.songs << song
233
233
 
234
234
  Callback.new(twin.songs).on_add { |t| invokes << t }
235
- invokes.must_equal [twin.songs[1]]
235
+ expect(invokes).must_equal [twin.songs[1]]
236
236
 
237
237
  twin.save
238
238
 
239
239
  # still shows the added after save.
240
240
  invokes = []
241
241
  Callback.new(twin.songs).on_add { |t| invokes << t }
242
- invokes.must_equal [twin.songs[1]]
242
+ expect(invokes).must_equal [twin.songs[1]]
243
243
  end
244
244
  end
245
245
 
@@ -250,7 +250,7 @@ class CallbacksTest < MiniTest::Spec
250
250
  it do
251
251
  invokes = []
252
252
  Callback.new(twin.songs).on_add(:created) { |t| invokes << t }
253
- invokes.must_equal []
253
+ expect(invokes).must_equal []
254
254
  end
255
255
 
256
256
  # collection present on initialize are not added.
@@ -260,7 +260,7 @@ class CallbacksTest < MiniTest::Spec
260
260
  album.songs = [ex_song, song]
261
261
 
262
262
  Callback.new(twin.songs).on_add(:created) { |t| invokes << t }
263
- invokes.must_equal []
263
+ expect(invokes).must_equal []
264
264
  end
265
265
 
266
266
  # items added after initialization are added.
@@ -273,14 +273,14 @@ class CallbacksTest < MiniTest::Spec
273
273
  twin.songs << ex_song # already created.
274
274
 
275
275
  Callback.new(twin.songs).on_add(:created) { |t| invokes << t }
276
- invokes.must_equal []
276
+ expect(invokes).must_equal []
277
277
 
278
278
  twin.save
279
279
 
280
280
  # still shows the added after save.
281
281
  invokes = []
282
282
  Callback.new(twin.songs).on_add(:created) { |t| invokes << t }
283
- invokes.must_equal [twin.songs[1]] # only the created is invoked.
283
+ expect(invokes).must_equal [twin.songs[1]] # only the created is invoked.
284
284
  end
285
285
  end
286
286
 
@@ -291,7 +291,7 @@ class CallbacksTest < MiniTest::Spec
291
291
  it do
292
292
  invokes = []
293
293
  Callback.new(twin.songs).on_delete { |t| invokes << t }
294
- invokes.must_equal []
294
+ expect(invokes).must_equal []
295
295
  end
296
296
 
297
297
  # collection present but nothing deleted.
@@ -301,7 +301,7 @@ class CallbacksTest < MiniTest::Spec
301
301
  album.songs = [ex_song, song]
302
302
 
303
303
  Callback.new(twin.songs).on_delete { |t| invokes << t }
304
- invokes.must_equal []
304
+ expect(invokes).must_equal []
305
305
  end
306
306
 
307
307
  # items deleted.
@@ -313,14 +313,14 @@ class CallbacksTest < MiniTest::Spec
313
313
  twin.songs.delete(deleted = twin.songs[0])
314
314
 
315
315
  Callback.new(twin.songs).on_delete { |t| invokes << t }
316
- invokes.must_equal [deleted]
316
+ expect(invokes).must_equal [deleted]
317
317
 
318
318
  twin.save
319
319
 
320
320
  # still shows the deleted after save.
321
321
  invokes = []
322
322
  Callback.new(twin.songs).on_delete { |t| invokes << t }
323
- invokes.must_equal [deleted]
323
+ expect(invokes).must_equal [deleted]
324
324
  end
325
325
  end
326
326
 
@@ -331,7 +331,7 @@ class CallbacksTest < MiniTest::Spec
331
331
  it do
332
332
  invokes = []
333
333
  Callback.new(twin.songs).on_destroy { |t| invokes << t }
334
- invokes.must_equal []
334
+ expect(invokes).must_equal []
335
335
  end
336
336
 
337
337
  # collection present but nothing deleted.
@@ -341,7 +341,7 @@ class CallbacksTest < MiniTest::Spec
341
341
  album.songs = [ex_song, song]
342
342
 
343
343
  Callback.new(twin.songs).on_destroy { |t| invokes << t }
344
- invokes.must_equal []
344
+ expect(invokes).must_equal []
345
345
  end
346
346
 
347
347
  # items deleted, doesn't trigger on_destroy.
@@ -353,7 +353,7 @@ class CallbacksTest < MiniTest::Spec
353
353
  twin.songs.delete(twin.songs[0])
354
354
 
355
355
  Callback.new(twin.songs).on_destroy { |t| invokes << t }
356
- invokes.must_equal []
356
+ expect(invokes).must_equal []
357
357
  end
358
358
 
359
359
  # items destroyed.
@@ -365,7 +365,7 @@ class CallbacksTest < MiniTest::Spec
365
365
  twin.songs.destroy(deleted = twin.songs[0])
366
366
 
367
367
  Callback.new(twin.songs).on_destroy { |t| invokes << t }
368
- invokes.must_equal []
368
+ expect(invokes).must_equal []
369
369
 
370
370
  twin.extend(Disposable::Twin::Collection::Semantics) # now #save will destroy.
371
371
  twin.save
@@ -373,7 +373,7 @@ class CallbacksTest < MiniTest::Spec
373
373
  # still shows the deleted after save.
374
374
  invokes = []
375
375
  Callback.new(twin.songs).on_destroy { |t| invokes << t }
376
- invokes.must_equal [deleted]
376
+ expect(invokes).must_equal [deleted]
377
377
  end
378
378
  end
379
379
 
@@ -384,7 +384,7 @@ class CallbacksTest < MiniTest::Spec
384
384
  # after initialization
385
385
  it do
386
386
  Callback.new(twin).on_change { |t| invokes << t }
387
- invokes.must_equal []
387
+ expect(invokes).must_equal []
388
388
  end
389
389
 
390
390
  # save, without any attributes changed. unpersisted before.
@@ -394,7 +394,7 @@ class CallbacksTest < MiniTest::Spec
394
394
  twin.save
395
395
 
396
396
  Callback.new(twin).on_change { |t| invokes << t }
397
- invokes.must_equal [] # nothing has changed, not even persisted?.
397
+ expect(invokes).must_equal [] # nothing has changed, not even persisted?.
398
398
  end
399
399
 
400
400
  # save, without any attributes changed. persisted before.
@@ -402,7 +402,7 @@ class CallbacksTest < MiniTest::Spec
402
402
  twin.save
403
403
 
404
404
  Callback.new(twin).on_change { |t| invokes << t }
405
- invokes.must_equal [twin]
405
+ expect(invokes).must_equal [twin]
406
406
  end
407
407
 
408
408
  # before and after save, with attributes changed
@@ -411,24 +411,24 @@ class CallbacksTest < MiniTest::Spec
411
411
  twin.name = "Run For Cover"
412
412
  invokes = []
413
413
  Callback.new(twin).on_change { |t| invokes << t }
414
- invokes.must_equal [twin]
414
+ expect(invokes).must_equal [twin]
415
415
 
416
416
  twin.save
417
417
 
418
418
  invokes = []
419
419
  Callback.new(twin).on_change { |t| invokes << t }
420
- invokes.must_equal [twin]
420
+ expect(invokes).must_equal [twin]
421
421
  end
422
422
 
423
423
  # for scalars: on_change(:email).
424
424
  it do
425
425
  Callback.new(twin).on_change(property: :name) { |t| invokes << t }
426
- invokes.must_equal []
426
+ expect(invokes).must_equal []
427
427
 
428
428
  twin.name = "Unforgiven"
429
429
 
430
430
  Callback.new(twin).on_change(property: :name) { |t| invokes << t }
431
- invokes.must_equal [twin]
431
+ expect(invokes).must_equal [twin]
432
432
  end
433
433
 
434
434
  # for collections.
@@ -447,4 +447,4 @@ class CallbacksTest < MiniTest::Spec
447
447
  # invokes.must_equal [twin.songs[0], twin.songs[2]]
448
448
  # end
449
449
  end
450
- end
450
+ end