virtus-matchers 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -13,9 +13,10 @@ module Virtus
|
|
13
13
|
attribute = @klass.attribute_set[@name]
|
14
14
|
return false unless attribute
|
15
15
|
if @type.class == Array
|
16
|
-
attribute.
|
16
|
+
attribute.primitive == Array &&
|
17
|
+
attribute.options[:member_type].primitive == @type.first
|
17
18
|
else
|
18
|
-
attribute.
|
19
|
+
attribute.primitive == @type
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
describe Virtus::Matchers::HaveAttributeMatcher do
|
4
4
|
class Example
|
5
|
-
include Virtus
|
5
|
+
include Virtus.model
|
6
6
|
|
7
7
|
attribute :foo, String
|
8
8
|
attribute :bar, Array[String]
|
9
|
+
attribute :baz, Array
|
9
10
|
end
|
10
11
|
|
11
12
|
context 'when attribute is defined', 'with simple type' do
|
@@ -34,6 +35,19 @@ describe Virtus::Matchers::HaveAttributeMatcher do
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
context 'when attribute is defined', 'with array type', 'and no member type' do
|
39
|
+
let(:matcher) { described_class.new(:baz, Array) }
|
40
|
+
|
41
|
+
it 'should match' do
|
42
|
+
matcher.matches?(Example).should be_true
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should have a description' do
|
46
|
+
matcher.matches?(Example)
|
47
|
+
matcher.description.should == 'have attribute baz of type Array'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
37
51
|
context 'when attribute is defined', 'with array type', 'but wrong member type' do
|
38
52
|
let(:matcher) { described_class.new(:bar, Array[Integer]) }
|
39
53
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtus-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: virtus
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.0.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
segments:
|
137
137
|
- 0
|
138
|
-
hash:
|
138
|
+
hash: -4562127897980208695
|
139
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
140
|
none: false
|
141
141
|
requirements:
|
@@ -144,10 +144,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
segments:
|
146
146
|
- 0
|
147
|
-
hash:
|
147
|
+
hash: -4562127897980208695
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.8.
|
150
|
+
rubygems_version: 1.8.23
|
151
151
|
signing_key:
|
152
152
|
specification_version: 3
|
153
153
|
summary: RSpec matchers for Virtus
|