testunitxml 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/README +1 -1
- data/docs/html/classes/REXML/DocType.src/M000005.html +7 -2
- data/docs/html/classes/REXML/DocType.src/M000006.html +7 -2
- data/docs/html/classes/REXML/DocType.src/M000007.html +1 -1
- data/docs/html/classes/REXML/DocType.src/M000008.html +1 -1
- data/docs/html/classes/Test.html +4 -0
- data/docs/html/classes/Test/Unit.html +4 -0
- data/docs/html/classes/Test/Unit/XML.html +26 -1
- data/docs/html/classes/Test/Unit/XML.src/M000009.html +1 -1
- data/docs/html/classes/Test/Unit/XML.src/M000010.html +23 -0
- data/docs/html/classes/Test/Unit/XML/Conditionals.html +173 -0
- data/docs/html/classes/Test/Unit/XML/Conditionals.src/M000011.html +19 -0
- data/docs/html/classes/Test/Unit/XML/Conditionals.src/M000012.html +42 -0
- data/docs/html/classes/Test/Unit/XML/NodeIterator.html +20 -20
- data/docs/html/classes/Test/Unit/XML/NodeIterator.src/M000013.html +13 -6
- data/docs/html/classes/Test/Unit/XML/NodeIterator.src/{M000011.html → M000014.html} +0 -0
- data/docs/html/classes/Test/Unit/XML/NodeIterator.src/{M000012.html → M000015.html} +0 -0
- data/docs/html/classes/Test/Unit/XML/NodeIterator.src/M000016.html +20 -0
- data/docs/html/classes/Test/Unit/XML/NodeIterator/NullNodeFilter.html +5 -5
- data/docs/html/classes/Test/Unit/XML/NodeIterator/NullNodeFilter.src/{M000014.html → M000017.html} +0 -0
- data/docs/html/classes/Test/Unit/XML/XmlEqualFilter.html +5 -5
- data/docs/html/classes/Test/Unit/XML/XmlEqualFilter.src/{M000015.html → M000018.html} +0 -0
- data/docs/html/created.rid +1 -1
- data/docs/html/files/CHANGES.html +10 -1
- data/docs/html/files/README.html +2 -2
- data/docs/html/files/lib/test/unit/xml/conditionals_rb.html +101 -0
- data/docs/html/files/lib/test/unit/xml/doctype_mixin_rb.html +8 -1
- data/docs/html/files/lib/test/unit/xml/xml_assertions_rb.html +2 -1
- data/docs/html/fr_class_index.html +1 -0
- data/docs/html/fr_file_index.html +1 -0
- data/docs/html/fr_method_index.html +11 -8
- data/lib/test/unit/xml/conditionals.rb +141 -0
- data/lib/test/unit/xml/doctype_mixin.rb +24 -2
- data/lib/test/unit/xml/xml_assertions.rb +22 -114
- data/test/tc_attributes_mixin.rb +37 -0
- data/test/tc_doctype_mixin.rb +71 -0
- data/test/tc_notationdecl_mixin.rb +39 -21
- data/test/tc_testunitxml.rb +21 -0
- metadata +16 -7
- data/docs/html/classes/Test/Unit/XML/NodeIterator.src/M000010.html +0 -27
@@ -5,16 +5,23 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>find_next_node (Test::Unit::XML::NodeIterator)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/test/unit/xml/nodeiterator.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-
|
15
|
-
<span class="ruby-identifier">
|
16
|
-
<span class="ruby-
|
17
|
-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/test/unit/xml/nodeiterator.rb, line 17</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">NodeIterator</span>.<span class="ruby-identifier">find_next_node</span>(<span class="ruby-identifier">node</span>, <span class="ruby-identifier">node_filter</span> = <span class="ruby-constant">NullNodeFilter</span>.<span class="ruby-identifier">new</span>)
|
15
|
+
<span class="ruby-identifier">next_node</span> = <span class="ruby-keyword kw">nil</span>
|
16
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">NodeIterator</span>.<span class="ruby-identifier">has_children?</span>(<span class="ruby-identifier">node</span>) <span class="ruby-keyword kw">then</span>
|
17
|
+
<span class="ruby-identifier">next_node</span> = <span class="ruby-identifier">node</span>[<span class="ruby-value">0</span>] <span class="ruby-comment cmt"># The index should be 1 according to the REXML docs
|
18
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">next_sibling_node</span>
|
19
|
+
<span class="ruby-identifier">next_node</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">next_sibling_node</span>
|
20
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">NodeIterator</span>.<span class="ruby-identifier">has_parent_with_sibling?</span>(<span class="ruby-identifier">node</span>)
|
21
|
+
<span class="ruby-identifier">next_node</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">next_sibling_node</span>
|
22
|
+
<span class="ruby-keyword kw">end</span>
|
23
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">next_node</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node_filter</span>.<span class="ruby-identifier">accept</span>(<span class="ruby-identifier">next_node</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">next_node</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
24
|
+
<span class="ruby-identifier">find_next_node</span>(<span class="ruby-identifier">next_node</span>, <span class="ruby-identifier">node_filter</span>)
|
18
25
|
<span class="ruby-keyword kw">end</span></pre>
|
19
26
|
</body>
|
20
27
|
</html>
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>next (Test::Unit::XML::NodeIterator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/test/unit/xml/nodeiterator.rb, line 40</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">next</span>
|
15
|
+
<span class="ruby-identifier">node</span> = <span class="ruby-ivar">@next_node</span>
|
16
|
+
<span class="ruby-ivar">@next_node</span> = <span class="ruby-constant">NodeIterator</span>.<span class="ruby-identifier">find_next_node</span>(<span class="ruby-identifier">node</span>, <span class="ruby-ivar">@node_filter</span>)
|
17
|
+
<span class="ruby-identifier">node</span>
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -86,7 +86,7 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
89
|
+
<a href="#M000017">accept</a>
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
@@ -108,12 +108,12 @@
|
|
108
108
|
<div id="methods">
|
109
109
|
<h3 class="section-bar">Public Instance methods</h3>
|
110
110
|
|
111
|
-
<div id="method-
|
112
|
-
<a name="
|
111
|
+
<div id="method-M000017" class="method-detail">
|
112
|
+
<a name="M000017"></a>
|
113
113
|
|
114
114
|
<div class="method-heading">
|
115
|
-
<a href="NullNodeFilter.src/
|
116
|
-
onclick="popupCode('NullNodeFilter.src/
|
115
|
+
<a href="NullNodeFilter.src/M000017.html" target="Code" class="method-signature"
|
116
|
+
onclick="popupCode('NullNodeFilter.src/M000017.html');return false;">
|
117
117
|
<span class="method-name">accept</span><span class="method-args">(node)</span>
|
118
118
|
</a>
|
119
119
|
</div>
|
data/docs/html/classes/Test/Unit/XML/NodeIterator/NullNodeFilter.src/{M000014.html → M000017.html}
RENAMED
File without changes
|
@@ -93,7 +93,7 @@ non-significant whitespace
|
|
93
93
|
<h3 class="section-bar">Methods</h3>
|
94
94
|
|
95
95
|
<div class="name-list">
|
96
|
-
<a href="#
|
96
|
+
<a href="#M000018">accept</a>
|
97
97
|
</div>
|
98
98
|
</div>
|
99
99
|
|
@@ -115,12 +115,12 @@ non-significant whitespace
|
|
115
115
|
<div id="methods">
|
116
116
|
<h3 class="section-bar">Public Instance methods</h3>
|
117
117
|
|
118
|
-
<div id="method-
|
119
|
-
<a name="
|
118
|
+
<div id="method-M000018" class="method-detail">
|
119
|
+
<a name="M000018"></a>
|
120
120
|
|
121
121
|
<div class="method-heading">
|
122
|
-
<a href="XmlEqualFilter.src/
|
123
|
-
onclick="popupCode('XmlEqualFilter.src/
|
122
|
+
<a href="XmlEqualFilter.src/M000018.html" target="Code" class="method-signature"
|
123
|
+
onclick="popupCode('XmlEqualFilter.src/M000018.html');return false;">
|
124
124
|
<span class="method-name">accept</span><span class="method-args">(node)</span>
|
125
125
|
</a>
|
126
126
|
</div>
|
File without changes
|
data/docs/html/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Tue Apr 18 23:35:55 CEST 2006
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Tue Apr 18 23:35:10 CEST 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,6 +70,15 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<h1>Changes</h1>
|
73
|
+
<h2>Version 0.1.5</h2>
|
74
|
+
<ul>
|
75
|
+
<li>Fixed a bug when comparing attributes containing entity references.
|
76
|
+
|
77
|
+
</li>
|
78
|
+
<li>Added an <tt>assert_xml_not_equal</tt> method.
|
79
|
+
|
80
|
+
</li>
|
81
|
+
</ul>
|
73
82
|
<h2>Version 0.1.4</h2>
|
74
83
|
<ul>
|
75
84
|
<li>Added support for Doctype comparisons in <tt>assert_xml_equal</tt>
|
data/docs/html/files/README.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Wed Jan 25 08:59:19 CET 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -72,7 +72,7 @@
|
|
72
72
|
<h1><a href="../classes/Test/Unit/XML.html">Test::Unit::XML</a></h1>
|
73
73
|
<h2>An XML <a href="../classes/Test.html">Test</a> Framework</h2>
|
74
74
|
<p>
|
75
|
-
Version: 0.1.
|
75
|
+
Version: 0.1.5
|
76
76
|
</p>
|
77
77
|
<p>
|
78
78
|
Author: Henrik M�rtensson
|
@@ -0,0 +1,101 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>File: conditionals.rb</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="fileHeader">
|
50
|
+
<h1>conditionals.rb</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>lib/test/unit/xml/conditionals.rb
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Tue Apr 18 23:00:00 CEST 2006</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
</div>
|
74
|
+
|
75
|
+
|
76
|
+
</div>
|
77
|
+
|
78
|
+
|
79
|
+
<!-- if includes -->
|
80
|
+
|
81
|
+
<div id="section">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<!-- if method_list -->
|
91
|
+
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
<div id="validator-badges">
|
97
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
</body>
|
101
|
+
</html>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Sat Jan 28 11:54:26 CET 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -69,6 +69,13 @@
|
|
69
69
|
<div id="contextContent">
|
70
70
|
|
71
71
|
|
72
|
+
<div id="requires-list">
|
73
|
+
<h3 class="section-bar">Required files</h3>
|
74
|
+
|
75
|
+
<div class="name-list">
|
76
|
+
test/unit/xml/notationdecl_mixin
|
77
|
+
</div>
|
78
|
+
</div>
|
72
79
|
|
73
80
|
</div>
|
74
81
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Tue Apr 18 23:15:02 CEST 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -78,6 +78,7 @@
|
|
78
78
|
test/unit/xml/doctype_mixin
|
79
79
|
test/unit/xml/notationdecl_mixin
|
80
80
|
test/unit
|
81
|
+
test/unit/xml/conditionals
|
81
82
|
test/unit/xml/xmlequalfilter
|
82
83
|
test/unit/xml/nodeiterator
|
83
84
|
</div>
|
@@ -28,6 +28,7 @@
|
|
28
28
|
<a href="classes/Test/Unit.html">Test::Unit</a><br />
|
29
29
|
<a href="classes/Test/Unit/TestCase.html">Test::Unit::TestCase</a><br />
|
30
30
|
<a href="classes/Test/Unit/XML.html">Test::Unit::XML</a><br />
|
31
|
+
<a href="classes/Test/Unit/XML/Conditionals.html">Test::Unit::XML::Conditionals</a><br />
|
31
32
|
<a href="classes/Test/Unit/XML/NodeIterator.html">Test::Unit::XML::NodeIterator</a><br />
|
32
33
|
<a href="classes/Test/Unit/XML/NodeIterator/NullNodeFilter.html">Test::Unit::XML::NodeIterator::NullNodeFilter</a><br />
|
33
34
|
<a href="classes/Test/Unit/XML/XmlEqualFilter.html">Test::Unit::XML::XmlEqualFilter</a><br />
|
@@ -25,6 +25,7 @@
|
|
25
25
|
<a href="files/README.html">README</a><br />
|
26
26
|
<a href="files/lib/test/unit/xml_rb.html">lib/test/unit/xml.rb</a><br />
|
27
27
|
<a href="files/lib/test/unit/xml/attributes_mixin_rb.html">lib/test/unit/xml/attributes_mixin.rb</a><br />
|
28
|
+
<a href="files/lib/test/unit/xml/conditionals_rb.html">lib/test/unit/xml/conditionals.rb</a><br />
|
28
29
|
<a href="files/lib/test/unit/xml/doctype_mixin_rb.html">lib/test/unit/xml/doctype_mixin.rb</a><br />
|
29
30
|
<a href="files/lib/test/unit/xml/nodeiterator_rb.html">lib/test/unit/xml/nodeiterator.rb</a><br />
|
30
31
|
<a href="files/lib/test/unit/xml/notationdecl_mixin_rb.html">lib/test/unit/xml/notationdecl_mixin.rb</a><br />
|
@@ -20,21 +20,24 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/Test/Unit/XML/XmlEqualFilter.html#
|
24
|
-
<a href="classes/Test/Unit/XML/NodeIterator/NullNodeFilter.html#
|
23
|
+
<a href="classes/Test/Unit/XML/XmlEqualFilter.html#M000018">accept (Test::Unit::XML::XmlEqualFilter)</a><br />
|
24
|
+
<a href="classes/Test/Unit/XML/NodeIterator/NullNodeFilter.html#M000017">accept (Test::Unit::XML::NodeIterator::NullNodeFilter)</a><br />
|
25
25
|
<a href="classes/Test/Unit/XML.html#M000009">assert_xml_equal (Test::Unit::XML)</a><br />
|
26
|
-
<a href="classes/Test/Unit/XML
|
26
|
+
<a href="classes/Test/Unit/XML.html#M000010">assert_xml_not_equal (Test::Unit::XML)</a><br />
|
27
|
+
<a href="classes/Test/Unit/XML/Conditionals.html#M000012">compare_xml_nodes (Test::Unit::XML::Conditionals)</a><br />
|
28
|
+
<a href="classes/Test/Unit/XML/Conditionals.html#M000011">create (Test::Unit::XML::Conditionals)</a><br />
|
29
|
+
<a href="classes/Test/Unit/XML/NodeIterator.html#M000013">find_next_node (Test::Unit::XML::NodeIterator)</a><br />
|
27
30
|
<a href="classes/REXML/Attributes.html#M000004">get_attribute_ns (REXML::Attributes)</a><br />
|
28
|
-
<a href="classes/Test/Unit/XML/NodeIterator.html#
|
31
|
+
<a href="classes/Test/Unit/XML/NodeIterator.html#M000015">has_next (Test::Unit::XML::NodeIterator)</a><br />
|
29
32
|
<a href="classes/REXML/NotationDecl.html#M000001">name (REXML::NotationDecl)</a><br />
|
30
|
-
<a href="classes/Test/Unit/XML/NodeIterator.html#
|
31
|
-
<a href="classes/Test/Unit/XML/NodeIterator.html#
|
33
|
+
<a href="classes/Test/Unit/XML/NodeIterator.html#M000014">new (Test::Unit::XML::NodeIterator)</a><br />
|
34
|
+
<a href="classes/Test/Unit/XML/NodeIterator.html#M000016">next (Test::Unit::XML::NodeIterator)</a><br />
|
32
35
|
<a href="classes/REXML/DocType.html#M000008">notation (REXML::DocType)</a><br />
|
33
36
|
<a href="classes/REXML/DocType.html#M000007">notations (REXML::DocType)</a><br />
|
34
|
-
<a href="classes/REXML/DocType.html#M000005">public (REXML::DocType)</a><br />
|
35
37
|
<a href="classes/REXML/NotationDecl.html#M000003">public (REXML::NotationDecl)</a><br />
|
36
|
-
<a href="classes/REXML/DocType.html#
|
38
|
+
<a href="classes/REXML/DocType.html#M000005">public (REXML::DocType)</a><br />
|
37
39
|
<a href="classes/REXML/NotationDecl.html#M000002">system (REXML::NotationDecl)</a><br />
|
40
|
+
<a href="classes/REXML/DocType.html#M000006">system (REXML::DocType)</a><br />
|
38
41
|
</div>
|
39
42
|
</div>
|
40
43
|
</body>
|
@@ -0,0 +1,141 @@
|
|
1
|
+
|
2
|
+
module Test
|
3
|
+
module Unit
|
4
|
+
module XML
|
5
|
+
|
6
|
+
# This singleton class compares all types of REXML nodes.
|
7
|
+
class Conditionals
|
8
|
+
|
9
|
+
private_class_method :new
|
10
|
+
@@conditionals = nil
|
11
|
+
|
12
|
+
# The +create+ method is used to create a singleton instance
|
13
|
+
# of the Conditionals class.
|
14
|
+
def Conditionals.create
|
15
|
+
@@conditionals = new unless @@conditionals
|
16
|
+
@@conditionals
|
17
|
+
end
|
18
|
+
|
19
|
+
# The method compares two REXML nodes representing an XML document,
|
20
|
+
# or part of a document. If the nodes are equal, the method returns
|
21
|
+
# +true+. If the nodes are not equal, the method returns +false+.
|
22
|
+
# If the nodes have child nodes, for example if the nodes are
|
23
|
+
# +Element+ nodes with content, they will _not_ be recursively compared.
|
24
|
+
def compare_xml_nodes(expected_node, actual_node)
|
25
|
+
return false unless actual_node.instance_of? expected_node.class
|
26
|
+
case actual_node
|
27
|
+
when REXML::Document
|
28
|
+
# TODO: Implement Document comparison
|
29
|
+
true
|
30
|
+
when REXML::DocType
|
31
|
+
compare_doctypes(expected_node, actual_node)
|
32
|
+
when REXML::Element :
|
33
|
+
compare_elements(expected_node, actual_node)
|
34
|
+
when REXML::CData
|
35
|
+
compare_texts(expected_node, actual_node)
|
36
|
+
when REXML::Text
|
37
|
+
compare_texts(expected_node, actual_node)
|
38
|
+
when REXML::Comment
|
39
|
+
compare_comments(expected_node, actual_node)
|
40
|
+
when REXML::Instruction
|
41
|
+
compare_pi(expected_node, actual_node)
|
42
|
+
when REXML::XMLDecl
|
43
|
+
compare_xml_declaration(expected_node, actual_node)
|
44
|
+
#when REXML::Entity
|
45
|
+
# compare_xml_entities(expected_node, actual_node)
|
46
|
+
else
|
47
|
+
puts "Unknown node type #{actual_node.class}"
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def compare_doctypes(expected_node, actual_node)
|
55
|
+
return compare_system_id(expected_node.system, actual_node.system) &&
|
56
|
+
expected_node.public == actual_node.public &&
|
57
|
+
compare_xml_internal_dtd_subset(expected_node, actual_node)
|
58
|
+
end
|
59
|
+
|
60
|
+
def compare_system_id(expected_id, actual_id)
|
61
|
+
is_expected_urn = expected_id =~ /^urn:/i
|
62
|
+
is_actual_urn = actual_id =~ /^urn:/i
|
63
|
+
if is_expected_urn || is_actual_urn
|
64
|
+
expected_id == actual_id
|
65
|
+
else
|
66
|
+
true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def compare_elements(expected_node, actual_node)
|
71
|
+
return expected_node.name == actual_node.name &&
|
72
|
+
expected_node.namespace() == actual_node.namespace() &&
|
73
|
+
compare_attributes(expected_node.attributes, actual_node.attributes)
|
74
|
+
end
|
75
|
+
|
76
|
+
def compare_attributes(expected_attributes, actual_attributes)
|
77
|
+
return false unless attribute_count(expected_attributes) == attribute_count(actual_attributes)
|
78
|
+
expected_attributes.each_attribute do |expected_attribute|
|
79
|
+
expected_prefix = expected_attribute.prefix()
|
80
|
+
unless expected_prefix == 'xmlns' then
|
81
|
+
expected_name = expected_attribute.name
|
82
|
+
expected_namespace = expected_attribute.namespace
|
83
|
+
actual_attribute = actual_attributes.get_attribute_ns(expected_namespace, expected_name)
|
84
|
+
return false unless actual_attribute
|
85
|
+
return false if expected_attribute.value() != actual_attribute.value()
|
86
|
+
end
|
87
|
+
end
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
def attribute_count(attributes)
|
92
|
+
# Do not count namespace declarations
|
93
|
+
attributes.size - attributes.prefixes.size
|
94
|
+
end
|
95
|
+
|
96
|
+
def compare_texts(expected_node, actual_node)
|
97
|
+
expected_node.value.eql?(actual_node.value)
|
98
|
+
end
|
99
|
+
|
100
|
+
def compare_comments(expected_node, actual_node)
|
101
|
+
expected_node == actual_node
|
102
|
+
end
|
103
|
+
|
104
|
+
def compare_pi(expected_pi, actual_pi)
|
105
|
+
return expected_pi.target == actual_pi.target &&
|
106
|
+
expected_pi.content == actual_pi.content
|
107
|
+
end
|
108
|
+
|
109
|
+
def compare_xml_declaration(expected_decl, actual_decl)
|
110
|
+
return expected_decl == actual_decl
|
111
|
+
end
|
112
|
+
|
113
|
+
def compare_xml_internal_dtd_subset(expected_node, actual_node)
|
114
|
+
expected_subset = expected_node.children()
|
115
|
+
actual_subset = actual_node.children()
|
116
|
+
return false unless expected_subset.length == actual_subset.length
|
117
|
+
expected_subset.inject(true) { |memo, expected_decl|
|
118
|
+
case expected_decl
|
119
|
+
when REXML::Entity
|
120
|
+
memo &&
|
121
|
+
expected_decl.value == actual_node.entities[expected_decl.name].value &&
|
122
|
+
expected_decl.ndata == actual_node.entities[expected_decl.name].ndata
|
123
|
+
when REXML::NotationDecl
|
124
|
+
actual_notation_decl = actual_node.notation(expected_decl.name)
|
125
|
+
memo &&
|
126
|
+
actual_notation_decl != nil &&
|
127
|
+
expected_decl.name == actual_notation_decl.name &&
|
128
|
+
expected_decl.public == actual_notation_decl.public &&
|
129
|
+
expected_decl.system == actual_notation_decl.system
|
130
|
+
when REXML::Comment
|
131
|
+
true
|
132
|
+
else
|
133
|
+
raise "Unexpected node type in internal DTD subset of expected document: " + expected_decl.inspect
|
134
|
+
end
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|