Created
October 21, 2009 13:07
-
-
Save ashmoran/215089 to your computer and use it in GitHub Desktop.
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 'rexml/document' | |
require 'rexml/formatters/transitive' | |
require 'rexml/formatters/pretty' | |
Spec::Matchers.define :be_equivalent_xml_to do |expected_xml| | |
match do |target_xml| | |
@expected_xml = expected_xml | |
formatter = REXML::Formatters::Pretty.new | |
formatted_target_xml, formatted_expected_xml = "", "" | |
formatter.write(REXML::Document.new(target_xml), formatted_target_xml) | |
formatter.write(REXML::Document.new(@expected_xml), formatted_expected_xml) | |
formatted_target_xml.strip! | |
formatted_expected_xml.strip! | |
formatted_target_xml == formatted_expected_xml | |
end | |
failure_message_for_should do |target_xml| | |
"Expected the XML\n" + | |
"=====\n" + | |
target_xml + "\n" + | |
"=====\n" + | |
"to be equivalent to\n" + | |
"=====\n" + | |
@expected_xml + "\n" + | |
"=====\n" + | |
"but it wasn't." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment