Class: Plyushkin::Test::HoardedAttributeMatcher
- Inherits:
-
MatcherBase
- Object
- MatcherBase
- Plyushkin::Test::HoardedAttributeMatcher
show all
- Defined in:
- lib/plyushkin/test/hoarded_attribute_matcher.rb
Defined Under Namespace
Classes: CallbackMatcher, IgnoreUnchangedMatcher, OfTypeMatcher
Instance Method Summary
collapse
Methods inherited from MatcherBase
#description, #failure_message, #matchers, #negative_failure_message
Constructor Details
Returns a new instance of HoardedAttributeMatcher.
3
4
5
|
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 3
def initialize(attribute)
@attribute = attribute
end
|
Instance Method Details
#and_after_create_call(sym) ⇒ Object
17
18
19
20
|
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 17
def and_after_create_call(sym)
matchers << CallbackMatcher.new(@attribute, sym)
self
end
|
#and_ignore_unchanged_values ⇒ Object
12
13
14
15
|
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 12
def and_ignore_unchanged_values
matchers << IgnoreUnchangedMatcher.new(@attribute)
self
end
|
#matches?(subject) ⇒ Boolean
22
23
24
25
26
27
28
|
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 22
def matches?(subject)
unless subject.class.plyushkin_model.registered_types.keys.include?(@attribute)
@failure_message = "Plyushkin: does not hoard attribute #{@attribute}"
@negative_failure_message = "Plyushkin: hoards attribute #{@attribute}"
end
super
end
|
#of_type(type) ⇒ Object
7
8
9
10
|
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 7
def of_type(type)
matchers << OfTypeMatcher.new(@attribute, type)
self
end
|