Rspec custom matchers for xml using Nokogiri XPath selector and optional content to match within selection. See matcher_spec.rb for usage.
Place have_xml.rb in your {Rails.root}/spec/support/matchers directory
Adapted from: Testing XML with rspec, xpath and libxml
I've made updates here