Class: Test::Unit::XML::Conditionals
- Inherits:
-
Object
- Object
- Test::Unit::XML::Conditionals
- Defined in:
- lib/test/unit/xml/conditionals.rb
Overview
This singleton class compares all types of REXML nodes.
Constant Summary collapse
- @@conditionals =
nil
Class Method Summary collapse
-
.create ⇒ Object
The
create
method is used to create a singleton instance of the Conditionals class.
Instance Method Summary collapse
-
#compare_xml_nodes(expected_node, actual_node) ⇒ Object
The method compares two REXML nodes representing an XML document, or part of a document.
Class Method Details
.create ⇒ Object
The create
method is used to create a singleton instance of the Conditionals class.
14 15 16 17 |
# File 'lib/test/unit/xml/conditionals.rb', line 14 def Conditionals.create @@conditionals = new unless @@conditionals @@conditionals end |
Instance Method Details
#compare_xml_nodes(expected_node, actual_node) ⇒ Object
The method compares two REXML nodes representing an XML document, or part of a document. If the nodes are equal, the method returns true
. If the nodes are not equal, the method returns false
. If the nodes have child nodes, for example if the nodes are Element
nodes with content, they will not be recursively compared.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/test/unit/xml/conditionals.rb', line 24 def compare_xml_nodes(expected_node, actual_node) #puts "Conditionals, Expected: #{expected_node.class} : #{expected_node.name}" #puts "Conditionals, Expected: #{actual_node.class} : #{actual_node.name}" return false unless actual_node.instance_of? expected_node.class return false if expected_node == nil && actual_node != nil return false if expected_node != nil && actual_node == nil #puts "actual_node is nil" unless actual_node #puts "expected_node is nil" unless expected_node case actual_node when REXML::Document # TODO: Implement Document comparison true when REXML::DocType compare_doctypes(expected_node, actual_node) when REXML::Element compare_elements(expected_node, actual_node) when REXML::CData compare_texts(expected_node, actual_node) when REXML::Text compare_texts(expected_node, actual_node) when REXML::Comment compare_comments(expected_node, actual_node) when REXML::Instruction compare_pi(expected_node, actual_node) when REXML::XMLDecl compare_xml_declaration(expected_node, actual_node) #when REXML::Entity # compare_xml_entities(expected_node, actual_node) else puts "Unknown node type #{actual_node.class}" false end end |