module TestXml::MatcherMethods

This module implements the actual matchers with their conditions.

Public Class Methods

xml_contain(subject, pattern) click to toggle source
# File lib/test_xml/matcher_methods.rb, line 4
def self.xml_contain(subject, pattern)
  actual, expected = parse_xml(subject, pattern)
  actual.match?(expected, true)
end
xml_equal(subject, pattern) click to toggle source
# File lib/test_xml/matcher_methods.rb, line 9
def self.xml_equal(subject, pattern)
  actual, expected = parse_xml(subject, pattern)
  actual.match?(expected, true) && expected.match?(actual, true)
end
xml_structure_contain(subject, pattern) click to toggle source
# File lib/test_xml/matcher_methods.rb, line 14
def self.xml_structure_contain(subject, pattern)
  actual, expected = parse_xml(subject, pattern)
  actual.match?(expected)
end
xml_structure_equal(subject, pattern) click to toggle source
# File lib/test_xml/matcher_methods.rb, line 19
def self.xml_structure_equal(subject, pattern)
  actual, expected = parse_xml(subject, pattern)
  actual.match?(expected) && expected.match?(actual)
end

Private Class Methods

parse_xml(subject, pattern) click to toggle source
# File lib/test_xml/matcher_methods.rb, line 25
def self.parse_xml(subject, pattern)
  [Nokogiri::XML.parse(subject).root, Nokogiri::XML.parse(pattern).root]
end