# File tests/cimi/spec_helper.rb, line 117 def assert_serialize_to(exp, act, opts) raise "missing format; use :fmt => [:xml || :json]" if opts[:fmt].nil? exp, act = [exp, act].map { |x| convert(x, opts[:fmt]) } m = HashCmp.new(exp, act) assert m.match?, "#{opts[:fmt].to_s.upcase} documents do not match\n" + m.errors end
# File tests/cimi/spec_helper.rb, line 124 def convert(x, fmt) if fmt == :json x = x.to_json if x.is_a?(CIMI::Model::Base) x = JSON.parse(x) if x.is_a?(String) elsif fmt == :xml x = x.to_xml if x.is_a?(CIMI::Model::Base) x = parse_xml(x) if x.is_a?(String) else raise "Invalid format #{fmt}" end x end