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