smart_properties 1.16.1 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_properties/property_collection.rb +1 -1
- data/lib/smart_properties/version.rb +1 -1
- data/spec/inheritance_spec.rb +50 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d970dbdc63b4c78e01ec7f569bd00d9c37a61c672f97d084a5a01b205c80159
|
4
|
+
data.tar.gz: 0db3dca56f41fafc8c96cef4c2ebd54068ce505101a3f949549724522b88bf3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 186ffbca4f484bd2dcf39fef28bf49523323d195c515567266dfe1c1166b513a426b8da3548a350025d11ca4188984ad312302198ec8d365de00d120b93921a5
|
7
|
+
data.tar.gz: dffb5d926bc985cf751d654782d152acb38ef1a9b1febd9ccec9bb2589fb61e55b6f471d83d82f106d2f504b1276c2f00166ff18b2f3ea48fc550687d60cf5de
|
data/spec/inheritance_spec.rb
CHANGED
@@ -226,43 +226,67 @@ RSpec.describe SmartProperties, 'intheritance' do
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
229
|
-
|
230
|
-
m
|
231
|
-
|
232
|
-
|
229
|
+
context "through modules" do
|
230
|
+
let(:m) do
|
231
|
+
m = Module.new do
|
232
|
+
include SmartProperties
|
233
|
+
property :m, default: 1
|
234
|
+
end
|
233
235
|
end
|
234
236
|
|
235
|
-
n
|
236
|
-
|
237
|
-
|
237
|
+
let(:n) do
|
238
|
+
n = Module.new do
|
239
|
+
include SmartProperties
|
240
|
+
property :n, default: 2
|
241
|
+
end
|
238
242
|
end
|
239
243
|
|
240
|
-
|
244
|
+
it "is supported" do
|
245
|
+
n = self.n
|
246
|
+
m = self.m
|
247
|
+
o = Module.new {}
|
241
248
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
249
|
+
klass = Class.new do
|
250
|
+
include m
|
251
|
+
include o
|
252
|
+
include n
|
253
|
+
end
|
254
|
+
|
255
|
+
n.module_eval do
|
256
|
+
property :p, default: 3
|
257
|
+
end
|
258
|
+
|
259
|
+
instance = klass.new
|
247
260
|
|
248
|
-
|
249
|
-
|
261
|
+
expect(instance.m).to eq(1)
|
262
|
+
expect(instance.n).to eq(2)
|
263
|
+
expect(instance.p).to eq(3)
|
264
|
+
|
265
|
+
expect { klass.new(m: 4, n: 5, p: 6) }.to_not raise_error
|
250
266
|
end
|
251
267
|
|
252
|
-
|
268
|
+
it "yields properly ordered properties – child properties have higher precedence than parent properties" do
|
269
|
+
n = self.n
|
270
|
+
m = self.m
|
271
|
+
|
272
|
+
parent = Class.new do
|
273
|
+
include m
|
274
|
+
include n
|
275
|
+
end
|
276
|
+
expect(parent.new.m).to eq(1)
|
253
277
|
|
254
|
-
|
255
|
-
|
256
|
-
|
278
|
+
child = Class.new(parent) do
|
279
|
+
property :m, default: 0
|
280
|
+
end
|
281
|
+
expect(child.new.m).to eq(0)
|
257
282
|
|
258
|
-
|
283
|
+
grandchild = Class.new(child)
|
284
|
+
expect(grandchild.new.m).to eq(0)
|
259
285
|
|
260
|
-
|
261
|
-
|
262
|
-
|
286
|
+
grandgrandchild = Class.new(grandchild) do
|
287
|
+
property :m, default: 1000
|
288
|
+
end
|
289
|
+
expect(grandgrandchild.new.m).to eq(1000)
|
263
290
|
end
|
264
|
-
|
265
|
-
expect { klass.new(m: 4, n: 5, p: 6) }.to_not raise_error
|
266
|
-
expect { klass2.new(m: 4, n: 5, p: 6) }.to_not raise_error
|
267
291
|
end
|
268
292
|
end
|