moosex 0.0.17 → 0.0.18
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/Changelog +38 -33
- data/Gemfile.lock +1 -1
- data/README.md +43 -1
- data/lib/moosex.rb +55 -622
- data/lib/moosex/attribute.rb +192 -0
- data/lib/moosex/attribute/modifiers.rb +303 -0
- data/lib/moosex/core.rb +114 -0
- data/lib/moosex/exceptions.rb +11 -0
- data/lib/moosex/meta.rb +139 -0
- data/lib/moosex/types.rb +35 -23
- data/lib/moosex/version.rb +1 -1
- data/spec/lol_spec.rb +1 -0
- data/spec/meta_spec.rb +90 -0
- data/spec/modifiers_spec.rb +28 -0
- data/spec/types_spec.rb +12 -14
- metadata +11 -2
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'moosex/attribute/modifiers'
|
2
|
+
|
3
|
+
describe MooseX::Attribute::Is do
|
4
|
+
it "should accept only valid parameters" do
|
5
|
+
expect {
|
6
|
+
MooseX::Attribute::Is.new.process({is: :forbidden}, :foo)
|
7
|
+
}.to raise_error(MooseX::InvalidAttributeError,
|
8
|
+
"invalid value for field 'foo' is 'forbidden', must be one of :private, :rw, :rwp, :ro or :lazy")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe MooseX::Attribute::Predicate do
|
13
|
+
it "should accept only valid parameters" do
|
14
|
+
expect {
|
15
|
+
MooseX::Attribute::Predicate.new.process({predicate: 0}, :foo)
|
16
|
+
}.to raise_error(MooseX::InvalidAttributeError,
|
17
|
+
"cannot coerce field predicate to a symbol for foo: undefined method `to_sym' for 0:Fixnum")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe MooseX::Attribute::Handles do
|
22
|
+
it "should accept only valid parameters" do
|
23
|
+
expect {
|
24
|
+
MooseX::Attribute::Handles.new.process({handles: BasicObject}, :foo)
|
25
|
+
}.to raise_error(MooseX::InvalidAttributeError,
|
26
|
+
"ops, should not use BasicObject for handles in foo")
|
27
|
+
end
|
28
|
+
end
|
data/spec/types_spec.rb
CHANGED
@@ -190,6 +190,10 @@ describe "MooseX::Types" do
|
|
190
190
|
}.to raise_error(MooseX::Types::TypeCheckError,
|
191
191
|
"AnyOf Check violation: caused by [Type violation: value '[]' (Array) is not an instance of [Type Fixnum], Type violation: value '[]' (Array) is not an instance of [Type String], Type violation: value '[]' (Array) is not an instance of [Type Symbol]]")
|
192
192
|
|
193
|
+
expect {
|
194
|
+
Test.isAnyOf(lambda {|x| raise "OPS"}).call(1)
|
195
|
+
}.to raise_error(MooseX::Types::TypeCheckError,
|
196
|
+
'unexpected exception OPS')
|
193
197
|
end
|
194
198
|
end
|
195
199
|
|
@@ -393,19 +397,17 @@ describe "MooseX::Types" do
|
|
393
397
|
expect {
|
394
398
|
Test.isTuple().call([1])
|
395
399
|
}.to raise_error(MooseX::Types::TypeCheckError,
|
396
|
-
|
400
|
+
/Tuple violation: size should be 0 instead 1/)
|
397
401
|
expect {
|
398
402
|
Test.isTuple(Integer).call([])
|
399
403
|
}.to raise_error(MooseX::Types::TypeCheckError,
|
400
|
-
|
404
|
+
/Tuple violation: size should be 1 instead 0/)
|
401
405
|
expect {
|
402
406
|
Test.isTuple().call(nil)
|
403
|
-
}.to raise_error(MooseX::Types::TypeCheckError
|
404
|
-
"Type violation: value '' (NilClass) is not an instance of [Type Array]")
|
407
|
+
}.to raise_error(MooseX::Types::TypeCheckError)
|
405
408
|
expect {
|
406
409
|
Test.isTuple(Integer, Symbol, Test.isAny, TrueClass).call([1,:symbol, nil, false])
|
407
|
-
}.to raise_error(MooseX::Types::TypeCheckError
|
408
|
-
"Tuple violation: on position 3 caused by Type violation: value 'false' (FalseClass) is not an instance of [Type TrueClass]")
|
410
|
+
}.to raise_error(MooseX::Types::TypeCheckError)
|
409
411
|
end
|
410
412
|
end
|
411
413
|
|
@@ -430,23 +432,19 @@ describe "MooseX::Types" do
|
|
430
432
|
it "should raise error" do
|
431
433
|
expect {
|
432
434
|
Test.isSet(Test.isArray(Test.isMaybe(Integer))).call(nil)
|
433
|
-
}.to raise_error(MooseX::Types::TypeCheckError
|
434
|
-
"Type violation: value '' (NilClass) is not an instance of [Type Array]")
|
435
|
+
}.to raise_error(MooseX::Types::TypeCheckError)
|
435
436
|
|
436
437
|
expect {
|
437
438
|
Test.isSet(Test.isArray(Test.isMaybe(Integer))).call([false])
|
438
|
-
}.to raise_error(MooseX::Types::TypeCheckError
|
439
|
-
"Set violation: caused by Type violation: value 'false' (FalseClass) is not an instance of [Type Array]")
|
439
|
+
}.to raise_error(MooseX::Types::TypeCheckError)
|
440
440
|
|
441
441
|
expect {
|
442
442
|
Test.isSet(Test.isArray(Test.isMaybe(Integer))).call([[false]])
|
443
|
-
}.to raise_error(MooseX::Types::TypeCheckError
|
444
|
-
"Set violation: caused by Array violation: caused by Maybe violation: caused by AnyOf Check violation: caused by [Type violation: value 'false' (FalseClass) is not an instance of [Type Integer], Constant violation: value 'false' (FalseClass) is not '' (NilClass)]")
|
443
|
+
}.to raise_error(MooseX::Types::TypeCheckError)
|
445
444
|
|
446
445
|
expect {
|
447
446
|
Test.isSet(Integer).call([1,2,2])
|
448
|
-
}.to raise_error(MooseX::Types::TypeCheckError
|
449
|
-
"Set violation: has one or more non unique elements: {2=>2} (value => count)")
|
447
|
+
}.to raise_error(MooseX::Types::TypeCheckError)
|
450
448
|
end
|
451
449
|
end
|
452
450
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moosex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Peczenyj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,7 +101,12 @@ files:
|
|
101
101
|
- README.md
|
102
102
|
- Rakefile
|
103
103
|
- lib/moosex.rb
|
104
|
+
- lib/moosex/attribute.rb
|
105
|
+
- lib/moosex/attribute/modifiers.rb
|
106
|
+
- lib/moosex/core.rb
|
104
107
|
- lib/moosex/event.rb
|
108
|
+
- lib/moosex/exceptions.rb
|
109
|
+
- lib/moosex/meta.rb
|
105
110
|
- lib/moosex/types.rb
|
106
111
|
- lib/moosex/version.rb
|
107
112
|
- moosex.gemspec
|
@@ -122,6 +127,8 @@ files:
|
|
122
127
|
- spec/hooks_spec.rb
|
123
128
|
- spec/lazy_spec.rb
|
124
129
|
- spec/lol_spec.rb
|
130
|
+
- spec/meta_spec.rb
|
131
|
+
- spec/modifiers_spec.rb
|
125
132
|
- spec/moosex_spec.rb
|
126
133
|
- spec/parametric_role_spec.rb
|
127
134
|
- spec/point_spec.rb
|
@@ -167,6 +174,8 @@ test_files:
|
|
167
174
|
- spec/hooks_spec.rb
|
168
175
|
- spec/lazy_spec.rb
|
169
176
|
- spec/lol_spec.rb
|
177
|
+
- spec/meta_spec.rb
|
178
|
+
- spec/modifiers_spec.rb
|
170
179
|
- spec/moosex_spec.rb
|
171
180
|
- spec/parametric_role_spec.rb
|
172
181
|
- spec/point_spec.rb
|