Sha256: dc9e790af7bad1bed5b55d11fa3d9a2f6b5065e2ffb1860b2b081ec582aedf39
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
require 'equivalent-xml' begin require 'rspec-expectations' rescue LoadError end module EquivalentXml::RSpecMatchers if defined?(::RSpec) rspec_namespace = ::RSpec::Matchers elsif defined?(::Spec) rspec_namespace = ::Spec::Matchers else raise NameError, "Cannot find Spec (rspec 1.x) or RSpec (rspec 2.x)" end # Determine if the receiver is equivalent to the argument as defined # in {file:README.rdoc README.rdoc} and {EquivalentXml.equivalent? EquivalentXml.equivalent?}. # node.should be_equivalent_to(other_node) # node.should_not be_equivalent_to(other_node) # node.should be_equivalent_to(other_node).respecting_element_order # node.should be_equivalent_to(other_node).with_whitespace_intact # node.should be_equivalent_to(other_node).respecting_element_order.with_whitespace_intact def be_equivalent_to(expected) # Placeholder method for documentation purposes; the actual # method is defined using RSpec's matcher DSL. end rspec_namespace.define :be_equivalent_to do |expected| @opts = {} match do |actual| EquivalentXml.equivalent?(actual,expected,@opts) end chain :respecting_element_order do @opts[:element_order] = true end chain :with_whitespace_intact do @opts[:normalize_whitespace] = false end failure_message_for_should do |actual| [ 'expected:', expected.to_s, 'got:', actual.to_s ].join("\n") end failure_message_for_should_not do |actual| [ 'expected:', actual.to_s, 'not to be equivalent to:', expected.to_s ].join("\n") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
equivalent-xml-0.2.9 | lib/equivalent-xml/rspec_matchers.rb |