Class: XmlSpec::Matchers::BeXmlEql

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/xml_spec/matchers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#parse_xml

Constructor Details

#initialize(expected_xml) ⇒ BeXmlEql

Returns a new instance of BeXmlEql.



15
16
17
# File 'lib/xml_spec/matchers.rb', line 15

def initialize(expected_xml)
  @expected_xml = expected_xml
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



9
10
11
# File 'lib/xml_spec/matchers.rb', line 9

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



9
10
11
# File 'lib/xml_spec/matchers.rb', line 9

def expected
  @expected
end

Instance Method Details

#diffable?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/xml_spec/matchers.rb', line 11

def diffable?
  true
end

#failure_message_for_shouldObject



24
25
26
# File 'lib/xml_spec/matchers.rb', line 24

def failure_message_for_should
  "the xml:\n#{@actual}\nshould exactly match xml:\n#{@expected}"
end

#failure_message_for_should_notObject



28
29
30
# File 'lib/xml_spec/matchers.rb', line 28

def failure_message_for_should_not
  "the xml:\n#{@actual}\nshould not exactly match xml:\n#{@expected}\nbut it does"
end

#matches?(actual_xml) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/xml_spec/matchers.rb', line 19

def matches?(actual_xml)
  @actual, @expected = parse_xml(actual_xml, @expected_xml)
  @actual.match?(@expected, true) && @expected.match?(@actual, true)
end