smart_properties 1.6.1 → 1.7.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 +4 -4
- data/lib/smart_properties.rb +2 -2
- data/spec/smart_properties_spec.rb +22 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e43f13ab772a153c4729a1f20be52f140934555
|
4
|
+
data.tar.gz: 5dab533362b6132ee4b67c4eaef9269d957b4211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b3c1e442d65b38c7571a2380b9bbdc643dd6f3b3d9931be1edeafcd3f9eedf9432e0637ce585e6a2d383274a3090eae0bde5473c461dcb7a1346ff3671769cb
|
7
|
+
data.tar.gz: 80ebfc6a118202f954e7b347b8685132e23478bbc9f9ef4e8dbd0d34bb5d98f009f71fab9b4f213f9618938c1d62b6de762989b4e89ef9c70224e22468b5e15d
|
data/lib/smart_properties.rb
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
# :required => true
|
22
22
|
#
|
23
23
|
module SmartProperties
|
24
|
-
VERSION = "1.
|
24
|
+
VERSION = "1.7.0"
|
25
25
|
|
26
26
|
class Error < ::ArgumentError; end
|
27
27
|
class ConfigurationError < Error; end
|
@@ -339,7 +339,7 @@ module SmartProperties
|
|
339
339
|
|
340
340
|
# Check presence of all required properties
|
341
341
|
faulty_properties =
|
342
|
-
properties.select { |_, property| property.required?(self) &&
|
342
|
+
properties.select { |_, property| property.required?(self) && instance_variable_get("@#{property.name}").nil? }.map(&:last)
|
343
343
|
unless faulty_properties.empty?
|
344
344
|
error = SmartProperties::InitializationError.new(self, faulty_properties)
|
345
345
|
raise error
|
@@ -431,6 +431,28 @@ describe SmartProperties do
|
|
431
431
|
end
|
432
432
|
end
|
433
433
|
|
434
|
+
context 'when used to build a class that has a required property with no default called :text whose getter is overriden' do
|
435
|
+
subject(:klass) do
|
436
|
+
Class.new.tap do |c|
|
437
|
+
c.send(:include, described_class)
|
438
|
+
|
439
|
+
c.instance_eval do
|
440
|
+
property :text, required: true
|
441
|
+
end
|
442
|
+
|
443
|
+
c.class_eval do
|
444
|
+
def text
|
445
|
+
"<em>#{super}</em>"
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should raise an error during initilization if no value for :text has been specified" do
|
452
|
+
expect { klass.new }.to raise_error(SmartProperties::InitializationError)
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
434
456
|
context 'when used to build a class that has a property called :id whose default value is a lambda statement for retrieving the object_id' do
|
435
457
|
subject(:klass) do
|
436
458
|
Class.new.tap do |c|
|