Class: HaveAttributesMatcher::HaveAttributes
- Inherits:
-
Object
- Object
- HaveAttributesMatcher::HaveAttributes
show all
- Defined in:
- lib/have_attributes.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of HaveAttributes.
4
5
6
|
# File 'lib/have_attributes.rb', line 4
def initialize(expected)
@expected = expected
end
|
Instance Method Details
#differ ⇒ Object
8
9
10
|
# File 'lib/have_attributes.rb', line 8
def differ
@differ ||= Differ.new(:diff_all => false)
end
|
#failure_message ⇒ Object
22
23
24
|
# File 'lib/have_attributes.rb', line 22
def failure_message
@error
end
|
#matches?(target) ⇒ Boolean
12
13
14
15
16
17
18
19
20
|
# File 'lib/have_attributes.rb', line 12
def matches?(target)
@target = target
if diff = differ.diff(@expected, target)
@error = differ.diff_to_message_lines(diff).join("\n")
false
else
true
end
end
|