Class: Warp::ModelMatchers::AttributeMatcher
- Inherits:
-
Matcher
show all
- Defined in:
- lib/warp/model_matchers/attribute_matcher.rb
Instance Attribute Summary collapse
Attributes inherited from Matcher
#model_or_instance
Instance Method Summary
collapse
#description_of, #failure_message_for_should, #failure_message_for_should_not, #values_match?
Constructor Details
Returns a new instance of AttributeMatcher.
8
9
10
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 8
def initialize(attr_name)
@attr_name = attr_name.to_sym
end
|
Instance Attribute Details
#attr_name ⇒ Object
Returns the value of attribute attr_name.
6
7
8
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 6
def attr_name
@attr_name
end
|
Instance Method Details
#description ⇒ Object
18
19
20
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 18
def description
"have attribute #{description_of(attr_name)}"
end
|
#failure_message ⇒ Object
22
23
24
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 22
def failure_message
"expected #{model_name} to #{description}"
end
|
#failure_message_when_negated ⇒ Object
26
27
28
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 26
def failure_message_when_negated
"expected #{model_name} to not #{description}"
end
|
#matches?(model_or_instance) ⇒ Boolean
12
13
14
15
16
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 12
def matches?(model_or_instance)
@model_or_instance = model_or_instance
attributes.any? {|actual| values_match?(attr_name, actual) }
end
|