virtus-matchers 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,8 +8,12 @@ module Virtus
8
8
  @klass.included_modules.include?(Virtus::ValueObject)
9
9
  end
10
10
 
11
+ def description
12
+ 'be a value object'
13
+ end
14
+
11
15
  def failure_message
12
- "expected #{@klass} to include module Virtus::ValueObject"
16
+ "expected #{@klass} to #{description}"
13
17
  end
14
18
  end
15
19
 
@@ -19,8 +19,13 @@ module Virtus
19
19
  end
20
20
  end
21
21
 
22
+ def description
23
+ type = @type.class == Array ? "Array#{@type}" : @type
24
+ "have attribute #{@name} of type #{type}"
25
+ end
26
+
22
27
  def failure_message
23
- "expected #{@klass} to have attribute #{@name} of type #{@type}"
28
+ "expected #{@klass} to #{description}"
24
29
  end
25
30
  end
26
31
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Virtus
4
4
  module Matchers
5
- VERSION = '0.0.5'.freeze
5
+ VERSION = '0.0.6'.freeze
6
6
  end
7
7
  end
@@ -14,6 +14,11 @@ describe Virtus::Matchers::BeAValueObjectMatcher do
14
14
  it 'should match' do
15
15
  matcher.matches?(ExampleValueObject).should be_true
16
16
  end
17
+
18
+ it 'should have a description' do
19
+ matcher.matches?(ExampleValueObject)
20
+ matcher.description.should == 'be a value object'
21
+ end
17
22
  end
18
23
 
19
24
  context 'when Virtus::ValueObject is not included' do
@@ -21,9 +26,9 @@ describe Virtus::Matchers::BeAValueObjectMatcher do
21
26
  matcher.matches?(Example).should be_false
22
27
  end
23
28
 
24
- it 'should have a failure message that indicates the missing module' do
29
+ it 'should have a failure message' do
25
30
  matcher.matches?(Example)
26
- matcher.failure_message.should == "expected #{Example} to include module Virtus::ValueObject"
31
+ matcher.failure_message.should == "expected #{Example} to be a value object"
27
32
  end
28
33
  end
29
34
  end
@@ -14,6 +14,11 @@ describe Virtus::Matchers::HaveAttributeMatcher do
14
14
  it 'should match' do
15
15
  matcher.matches?(Example).should be_true
16
16
  end
17
+
18
+ it 'should have a description' do
19
+ matcher.matches?(Example)
20
+ matcher.description.should == 'have attribute foo of type String'
21
+ end
17
22
  end
18
23
 
19
24
  context 'when attribute is defined', 'with array type', 'and correct member type' do
@@ -22,6 +27,11 @@ describe Virtus::Matchers::HaveAttributeMatcher do
22
27
  it 'should match' do
23
28
  matcher.matches?(Example).should be_true
24
29
  end
30
+
31
+ it 'should have a description' do
32
+ matcher.matches?(Example)
33
+ matcher.description.should == 'have attribute bar of type Array[String]'
34
+ end
25
35
  end
26
36
 
27
37
  context 'when attribute is defined', 'with array type', 'but wrong member type' do
@@ -30,6 +40,11 @@ describe Virtus::Matchers::HaveAttributeMatcher do
30
40
  it 'should not match' do
31
41
  matcher.matches?(Example).should be_false
32
42
  end
43
+
44
+ it 'should have a failure message' do
45
+ matcher.matches?(Example)
46
+ matcher.failure_message.should == "expected #{Example} to have attribute bar of type Array[Integer]"
47
+ end
33
48
  end
34
49
 
35
50
  context 'when attribute is defined', 'with wrong type' do
@@ -39,17 +54,22 @@ describe Virtus::Matchers::HaveAttributeMatcher do
39
54
  matcher.matches?(Example).should be_false
40
55
  end
41
56
 
42
- it 'should have a failure message that indicates the missing attribute' do
57
+ it 'should have a failure message' do
43
58
  matcher.matches?(Example)
44
59
  matcher.failure_message.should == "expected #{Example} to have attribute foo of type Hash"
45
60
  end
46
61
  end
47
62
 
48
63
  context 'when attribute is not defined' do
49
- let(:matcher) { described_class.new(:bar, String) }
64
+ let(:matcher) { described_class.new(:baz, String) }
50
65
 
51
66
  it 'should not match' do
52
67
  matcher.matches?(Example).should be_false
53
68
  end
69
+
70
+ it 'should have a failure message' do
71
+ matcher.matches?(Example)
72
+ matcher.failure_message.should == "expected #{Example} to have attribute baz of type String"
73
+ end
54
74
  end
55
75
  end
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-27 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: virtus
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: 1260615358820155132
138
+ hash: 2186347188059220164
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: 1260615358820155132
147
+ hash: 2186347188059220164
148
148
  requirements: []
149
149
  rubyforge_project:
150
150
  rubygems_version: 1.8.24