Sha256: a849cc4383994d590df4b0c4208589bb669d0e5d1973c9ea0d8e7f30301c1fdb

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

module TestXml
  # This module implements the actual matchers with their conditions.
  module MatcherMethods
    def self.xml_contain(subject, pattern)
      actual, expected = parse_xml(subject, pattern)
      actual.match?(expected, true)
    end
    
    def self.xml_equal(subject, pattern)
      actual, expected = parse_xml(subject, pattern)
      actual.match?(expected, true) && expected.match?(actual, true)
    end
    
    def self.xml_structure_contain(subject, pattern)
      actual, expected = parse_xml(subject, pattern)
      actual.match?(expected)
    end
    
    def self.xml_structure_equal(subject, pattern)
      actual, expected = parse_xml(subject, pattern)
      actual.match?(expected) && expected.match?(actual)
    end
    
  private
    def self.parse_xml(subject, pattern)
      [Nokogiri::XML.parse(subject), Nokogiri::XML.parse(pattern)]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
test_xml-0.1.1 lib/test_xml/matcher_methods.rb
test_xml-0.1.0 lib/test_xml/matcher_methods.rb