bound 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bound.rb +8 -0
- data/lib/bound/version.rb +1 -1
- data/spec/bound_spec.rb +14 -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: d49b1e7d8ae733c85d4adc9745275673ee409ff6
|
4
|
+
data.tar.gz: 16d268a92eda75a87f4cc0e144866aed12eed7d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af6cb0fee682b4e6a1b0245d4e8da571e05585c1d2b14f6a4c61c161a186a4a099d8aa0497ca86a5141aca35d3e58da6a8d09b6a8b611500e2c356c22821ef0b
|
7
|
+
data.tar.gz: 048b801aeae0fd2bc5b99ef9225bbdaef12f8510f3ca37828aebb358944ce0e9a9bed7cf5f58921aa8cc44fb7e283043184d3e092fd30a05a7d2ac318de23177
|
data/lib/bound.rb
CHANGED
@@ -32,6 +32,10 @@ class Bound
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def set_attributes(*attributes)
|
35
|
+
if attributes.any? { |a| !a.kind_of? Symbol }
|
36
|
+
raise ArgumentError.new("Invalid list of attributes: #{attributes.inspect}")
|
37
|
+
end
|
38
|
+
|
35
39
|
self.attributes += attributes
|
36
40
|
attr_accessor *attributes
|
37
41
|
|
@@ -39,6 +43,10 @@ class Bound
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def optional(*optionals)
|
46
|
+
if optionals.any? { |a| !a.kind_of? Symbol }
|
47
|
+
raise ArgumentError.new("Invalid list of optional attributes: #{optionals.inspect}")
|
48
|
+
end
|
49
|
+
|
42
50
|
self.optional_attributes += optionals
|
43
51
|
attr_accessor *optionals
|
44
52
|
|
data/lib/bound/version.rb
CHANGED
data/spec/bound_spec.rb
CHANGED
@@ -55,6 +55,20 @@ describe Bound do
|
|
55
55
|
assert_match(/unknown.+gender/i, exception.message)
|
56
56
|
end
|
57
57
|
|
58
|
+
describe 'wrong initialization' do
|
59
|
+
it 'fails if new is not called with symbols' do
|
60
|
+
assert_raises ArgumentError do
|
61
|
+
Bound.new(:events => [])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'fails if optional is not called with symbols' do
|
66
|
+
assert_raises ArgumentError do
|
67
|
+
Bound.new.optional(:events => [])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
58
72
|
describe 'inspect' do
|
59
73
|
let(:inspection) { user.inspect }
|
60
74
|
let(:user) { User.build(hash) }
|