Class: XmlSpec::Matchers::IncludeXml

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) ⇒ IncludeXml

Returns a new instance of IncludeXml.



38
39
40
# File 'lib/xml_spec/matchers.rb', line 38

def initialize(expected_xml)
  @expected_xml = expected_xml
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



36
37
38
# File 'lib/xml_spec/matchers.rb', line 36

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



36
37
38
# File 'lib/xml_spec/matchers.rb', line 36

def expected
  @expected
end

Instance Method Details

#failure_message_for_shouldObject



47
48
49
# File 'lib/xml_spec/matchers.rb', line 47

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

#failure_message_for_should_notObject



51
52
53
# File 'lib/xml_spec/matchers.rb', line 51

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

#matches?(actual_xml) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/xml_spec/matchers.rb', line 42

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