class Matchers::XML::DocumentContainsXPath

Public Class Methods

new(xpath_expr_s, occurrences = 1) click to toggle source

@param xpath_expr_s [String] - the XPath expression @param optional occurences [Integer] - the number of occurences expected in document

# File lib/matchers/xml/document_contains_xpath.rb, line 22
def initialize(xpath_expr_s, occurrences = 1)
  @xpath_expr_s = xpath_expr_s
  @occurrences = occurrences
end

Public Instance Methods

matches?(document_s) click to toggle source

@param document_s [String] - the document given as String

# File lib/matchers/xml/document_contains_xpath.rb, line 28
def matches?(document_s)
  xml_doc = REXML::Document.new(document_s)
  nodes = REXML::XPath.match(xml_doc, @xpath_expr_s)
  nodes.count >= @occurrences
end