virtus-matchers 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/virtus/matchers/be_value_object_matcher.rb +21 -0
- data/lib/virtus/matchers/have_attribute_matcher.rb +1 -1
- data/lib/virtus/matchers/version.rb +1 -1
- data/lib/virtus/matchers.rb +1 -0
- data/spec/virtus/matchers/be_value_object_matcher_spec.rb +29 -0
- data/spec/{virtus_attribute_spec.rb → virtus/matchers/have_attribute_matcher_spec.rb} +0 -0
- metadata +8 -5
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Virtus
|
4
|
+
module Matchers
|
5
|
+
class BeAValueObjectMatcher
|
6
|
+
def matches?(klass)
|
7
|
+
@klass = klass
|
8
|
+
@klass.included_modules.include?(Virtus::ValueObject)
|
9
|
+
end
|
10
|
+
|
11
|
+
def failure_message
|
12
|
+
"expected #{@klass} to include module Virtus::ValueObject"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def be_value_object
|
17
|
+
BeAValueObjectMatcher.new
|
18
|
+
end
|
19
|
+
alias_method :be_a_value_object, :be_value_object
|
20
|
+
end
|
21
|
+
end
|
data/lib/virtus/matchers.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Virtus::Matchers::BeAValueObjectMatcher do
|
4
|
+
class Example
|
5
|
+
end
|
6
|
+
|
7
|
+
class ExampleValueObject
|
8
|
+
include Virtus::ValueObject
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:matcher) { described_class.new }
|
12
|
+
|
13
|
+
context 'when Virtus::ValueObject is included' do
|
14
|
+
it 'should match' do
|
15
|
+
matcher.matches?(ExampleValueObject).should be_true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when Virtus::ValueObject is not included' do
|
20
|
+
it 'should not match' do
|
21
|
+
matcher.matches?(Example).should be_false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have a failure message that indicates the missing module' do
|
25
|
+
matcher.matches?(Example)
|
26
|
+
matcher.failure_message.should == "expected #{Example} to include module Virtus::ValueObject"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -113,12 +113,14 @@ executables: []
|
|
113
113
|
extensions: []
|
114
114
|
extra_rdoc_files: []
|
115
115
|
files:
|
116
|
+
- lib/virtus/matchers/be_value_object_matcher.rb
|
116
117
|
- lib/virtus/matchers/have_attribute_matcher.rb
|
117
118
|
- lib/virtus/matchers/version.rb
|
118
119
|
- lib/virtus/matchers.rb
|
119
120
|
- lib/virtus-matchers.rb
|
120
121
|
- spec/spec_helper.rb
|
121
|
-
- spec/
|
122
|
+
- spec/virtus/matchers/be_value_object_matcher_spec.rb
|
123
|
+
- spec/virtus/matchers/have_attribute_matcher_spec.rb
|
122
124
|
homepage: https://github.com/tmattia/virtus-matchers
|
123
125
|
licenses: []
|
124
126
|
post_install_message:
|
@@ -133,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
135
|
version: '0'
|
134
136
|
segments:
|
135
137
|
- 0
|
136
|
-
hash:
|
138
|
+
hash: -3335781311402418033
|
137
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
140
|
none: false
|
139
141
|
requirements:
|
@@ -142,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
144
|
version: '0'
|
143
145
|
segments:
|
144
146
|
- 0
|
145
|
-
hash:
|
147
|
+
hash: -3335781311402418033
|
146
148
|
requirements: []
|
147
149
|
rubyforge_project:
|
148
150
|
rubygems_version: 1.8.24
|
@@ -151,4 +153,5 @@ specification_version: 3
|
|
151
153
|
summary: RSpec matchers for Virtus
|
152
154
|
test_files:
|
153
155
|
- spec/spec_helper.rb
|
154
|
-
- spec/
|
156
|
+
- spec/virtus/matchers/be_value_object_matcher_spec.rb
|
157
|
+
- spec/virtus/matchers/have_attribute_matcher_spec.rb
|