virtus-matchers 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,9 +9,14 @@ module Virtus
9
9
  end
10
10
 
11
11
  def matches?(klass)
12
- attribute = klass.attribute_set.find { |attr| attr.name == @name }
12
+ @klass = klass
13
+ attribute = @klass.attribute_set.find { |attr| attr.name == @name }
13
14
  attribute and attribute.options[:primitive] == @type
14
15
  end
16
+
17
+ def failure_message
18
+ "expected #{@klass} to have attribute #{@name} of type #{@type}"
19
+ end
15
20
  end
16
21
 
17
22
  def have_attribute(name, type)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Virtus
4
4
  module Matchers
5
- VERSION = '0.0.2'.freeze
5
+ VERSION = '0.0.3'.freeze
6
6
  end
7
7
  end
@@ -21,6 +21,11 @@ describe Virtus::Matchers::HaveAttributeMatcher do
21
21
  it 'should not match' do
22
22
  matcher.matches?(Example).should be_false
23
23
  end
24
+
25
+ it 'should have a failure message that indicates the missing attribute' do
26
+ matcher.matches?(Example)
27
+ matcher.failure_message.should == "expected #{Example} to have attribute foo of type Hash"
28
+ end
24
29
  end
25
30
 
26
31
  context 'when attribute is not defined' do
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.2
4
+ version: 0.0.3
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: 2012-11-16 00:00:00.000000000 Z
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: virtus
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: 2016058407999256774
136
+ hash: 3571745744909800015
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: 2016058407999256774
145
+ hash: 3571745744909800015
146
146
  requirements: []
147
147
  rubyforge_project:
148
148
  rubygems_version: 1.8.24