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.
6
7
8
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 6
def initialize(attr_name)
@attr_name = attr_name.to_sym
end
|
Instance Attribute Details
#attr_name ⇒ Object
Returns the value of attribute attr_name.
4
5
6
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 4
def attr_name
@attr_name
end
|
Instance Method Details
#description ⇒ Object
16
17
18
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 16
def description
"have attribute #{description_of(attr_name)}"
end
|
#failure_message ⇒ Object
20
21
22
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 20
def failure_message
"expected #{model_name} to #{description}"
end
|
#failure_message_when_negated ⇒ Object
24
25
26
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 24
def failure_message_when_negated
"expected #{model_name} to not #{description}"
end
|
#matches?(model_or_instance) ⇒ Boolean
10
11
12
13
14
|
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 10
def matches?(model_or_instance)
@model_or_instance = model_or_instance
attributes.any? {|actual| values_match?(attr_name, actual) }
end
|