This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
RSpec::Matchers.define :have_xml do |xpath, text| | |
match do |body| | |
doc = Nokogiri::XML::Document.parse(body) | |
nodes = doc.xpath(xpath) | |
expect(nodes).to_not be_empty | |
if text | |
nodes.each do |node| | |
cdata = node.children.find { |e| e.cdata? } | |
value_to_check = node.text |
OlderNewer