Purpose
This gem provides Xml::C14n
which is a library that uses Nokogiri
to pretty-print and provide a canonicalized form of XML
(W3C Canonicalized XML) suitable
for signing and comparison.
This gem also provides the RSpec matcher be_analogous_with
for comparing XML
content. The matcher used is from the
compare-xml
gem.
Usage
In RSpecs:
# In spec/spec_helper.rb
require 'xml/c14n'
# In spec/*_spec.rb
it "canonicalizes #{File.basename(f)}" do
input = Xml::C14n.format(File.read(xml_raw))
output = Xml::C14n.format(File.read(xml_c14n))
expect(output).to eq(input)
end
it "checks if analogous with #{File.basename(f)}" do
input = Xml::C14n.format(File.read(xml_raw))
output = Xml::C14n.format(File.read(xml_c14n))
expect(output).to be_analogous_with(input)
end
License
Copyright Ribose.