Class: Xml::C14n::RSpecMatchers::AnalogousMatcher
- Inherits:
-
Object
- Object
- Xml::C14n::RSpecMatchers::AnalogousMatcher
- Defined in:
- lib/xml/c14n/rspec_matchers.rb
Instance Method Summary collapse
- #diffable ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected) ⇒ AnalogousMatcher
constructor
A new instance of AnalogousMatcher.
- #matches?(target) ⇒ Boolean
Constructor Details
#initialize(expected) ⇒ AnalogousMatcher
Returns a new instance of AnalogousMatcher.
15 16 17 18 |
# File 'lib/xml/c14n/rspec_matchers.rb', line 15 def initialize(expected) @expected = expected @result = nil end |
Instance Method Details
#diffable ⇒ Object
50 51 52 |
# File 'lib/xml/c14n/rspec_matchers.rb', line 50 def diffable true end |
#failure_message ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xml/c14n/rspec_matchers.rb', line 34 def index = 0 @result.map do |hash| index += 1 "DIFF #{index}: expected node: #{hash[:node1]}\n" \ " actual node : #{hash[:node2]}\n" \ " diff from : #{hash[:diff1]}\n" \ " diff to : #{hash[:diff2]}\n" end.join("\n") end |
#failure_message_when_negated ⇒ Object
45 46 47 48 |
# File 'lib/xml/c14n/rspec_matchers.rb', line 45 def ["expected:", @target.to_s, "not be analogous with:", @expected.to_s].join("\n") end |
#matches?(target) ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/xml/c14n/rspec_matchers.rb', line 20 def matches?(target) @target = target @result = CompareXML.equivalent?( Nokogiri::XML(@target), Nokogiri::XML(@expected), { collapse_whitespace: true, ignore_attr_order: true, verbose: true }, ) @result.empty? end |