Skip to content

Instantly share code, notes, and snippets.

@jmstone617
jmstone617 / have_xml.rb
Last active August 29, 2015 14:06 — forked from faun/have_xml.rb
RSpec::Matchers.define :have_xml do |xpath, text|
match do |body|
doc = Nokogiri::XML::Document.parse(body)
nodes = doc.xpath(xpath)
expect(nodes.empty?)to be_false
if text
nodes.each do |node|
node.content.should == text
end
end