xqsr3 0.30.3 → 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +57 -41
- data/lib/xqsr3/internal_/test_unit_version_.rb +114 -0
- data/lib/xqsr3/version.rb +1 -1
- data/test/scratch/test_assert_raise_with_message.rb +31 -0
- data/test/unit/array_utilities/tc_join_with_or.rb +0 -0
- data/test/unit/extensions/enumerable/tc_detect_map.rb +0 -0
- data/test/unit/extensions/kernel/tc_integer.rb +0 -0
- data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +5 -0
- data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +0 -0
- data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +0 -0
- data/test/unit/hash_utilities/tc_has_match.rb +0 -0
- data/test/unit/hash_utilities/tc_match.rb +0 -0
- metadata +5 -9
- data/lib/xqsr3/xml/utilities/compare.rb +0 -544
- data/lib/xqsr3/xml/utilities/navigation.rb +0 -108
- data/test/unit/xml/ts_all.rb +0 -12
- data/test/unit/xml/utilities/tc_compare.rb +0 -256
- data/test/unit/xml/utilities/tc_navigation.rb +0 -55
- data/test/unit/xml/utilities/ts_all.rb +0 -12
@@ -1,256 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
|
4
|
-
|
5
|
-
require 'xqsr3/xml/utilities/compare'
|
6
|
-
|
7
|
-
require 'xqsr3/extensions/test/unit'
|
8
|
-
require 'test/unit'
|
9
|
-
|
10
|
-
class Test_Xqsr3_XML_Utilities_Compare < Test::Unit::TestCase
|
11
|
-
|
12
|
-
include ::Xqsr3::XML::Utilities::Compare
|
13
|
-
|
14
|
-
def test_compare_nil
|
15
|
-
|
16
|
-
assert xml_compare(nil, nil).same?
|
17
|
-
|
18
|
-
assert_false xml_compare('', nil).same?
|
19
|
-
assert_false xml_compare(nil, '').same?
|
20
|
-
|
21
|
-
assert xml_compare('', nil, equate_nil_and_empty: true).same?
|
22
|
-
assert xml_compare(nil, '', equate_nil_and_empty: true).same?
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_compare_empty
|
26
|
-
|
27
|
-
assert xml_compare('', '').same?
|
28
|
-
|
29
|
-
assert_false xml_compare('<abc/>', '').same?
|
30
|
-
assert_false xml_compare('', '<abc/>').same?
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_compare_one_level_1
|
34
|
-
|
35
|
-
assert xml_compare('<abc/>', '<abc/>').same?
|
36
|
-
assert xml_compare('<abc/>', '<abc></abc>').same?
|
37
|
-
assert_false xml_compare('<abc/>', '<def/>').same?
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_compare_two_level_1
|
41
|
-
|
42
|
-
assert xml_compare('<parent><child1></child1></parent>', '<parent><child1></child1></parent>').same?
|
43
|
-
assert xml_compare('<parent><child1/></parent>', '<parent><child1></child1></parent>').same?
|
44
|
-
|
45
|
-
r = xml_compare('<parent><child1/></parent>', '<parent><child2/></parent>')
|
46
|
-
|
47
|
-
assert_false r.same?
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_compare_attributes_1
|
51
|
-
|
52
|
-
lhs = <<END_OF_lhs
|
53
|
-
<node name="John Smith" age="21" />
|
54
|
-
END_OF_lhs
|
55
|
-
|
56
|
-
rhs_same = <<END_OF_lhs
|
57
|
-
<node age="21" name="John Smith" />
|
58
|
-
END_OF_lhs
|
59
|
-
|
60
|
-
rhs_diff = <<END_OF_lhs
|
61
|
-
<node name="John Smith" age="22" />
|
62
|
-
END_OF_lhs
|
63
|
-
|
64
|
-
r = xml_compare lhs, rhs_same, ignore_attribute_order: false
|
65
|
-
|
66
|
-
assert r.different?, r.details
|
67
|
-
assert_equal :different_attribute_order, r.reason
|
68
|
-
|
69
|
-
r = xml_compare lhs, rhs_same, ignore_attribute_order: true
|
70
|
-
|
71
|
-
assert r.same?
|
72
|
-
|
73
|
-
r = xml_compare lhs, rhs_same, element_order: false
|
74
|
-
|
75
|
-
assert r.same?
|
76
|
-
|
77
|
-
r = xml_compare lhs, rhs_diff
|
78
|
-
|
79
|
-
assert r.different?
|
80
|
-
assert_equal :different_attributes, r.reason
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_compare_two_level_2
|
84
|
-
|
85
|
-
lhs = <<END_OF_lhs
|
86
|
-
<parent>
|
87
|
-
<child1/>
|
88
|
-
</parent>
|
89
|
-
END_OF_lhs
|
90
|
-
rhs = <<END_OF_rhs
|
91
|
-
<parent>
|
92
|
-
<child1>
|
93
|
-
</child1>
|
94
|
-
</parent>
|
95
|
-
END_OF_rhs
|
96
|
-
|
97
|
-
r = xml_compare lhs, rhs, normalize_whitespace: false
|
98
|
-
|
99
|
-
assert r.different?, "#{r.details}"
|
100
|
-
assert_equal :different_node_contents, r.reason
|
101
|
-
|
102
|
-
r = xml_compare(lhs, rhs, normalize_whitespace: true)
|
103
|
-
|
104
|
-
assert r.same?, "#{r.details}"
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_compare_two_level_3
|
108
|
-
|
109
|
-
lhs = <<END_OF_lhs
|
110
|
-
<parent>
|
111
|
-
<child1/>
|
112
|
-
<child2>
|
113
|
-
<grandchild2a/>
|
114
|
-
</child2>
|
115
|
-
</parent>
|
116
|
-
END_OF_lhs
|
117
|
-
rhs = <<END_OF_rhs
|
118
|
-
<parent>
|
119
|
-
<child2><grandchild2a/></child2>
|
120
|
-
<child1>
|
121
|
-
</child1>
|
122
|
-
</parent>
|
123
|
-
END_OF_rhs
|
124
|
-
|
125
|
-
r = xml_compare lhs, rhs, normalize_whitespace: true
|
126
|
-
|
127
|
-
assert r.same?, "#{r.details}"
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_different_declarations_and_dont_ignore
|
131
|
-
|
132
|
-
lhs_str = <<END_OF_lhs_doc
|
133
|
-
<?xml version="1.0"?>
|
134
|
-
<outer>
|
135
|
-
<mid>
|
136
|
-
<inner>some text</inner>
|
137
|
-
</mid>
|
138
|
-
</outer>
|
139
|
-
END_OF_lhs_doc
|
140
|
-
|
141
|
-
rhs_str = <<END_OF_rhs_doc
|
142
|
-
<?xml version="1.0"?>
|
143
|
-
<mid>
|
144
|
-
<inner>some text</inner>
|
145
|
-
</mid>
|
146
|
-
END_OF_rhs_doc
|
147
|
-
|
148
|
-
lhs_doc = Nokogiri::XML lhs_str
|
149
|
-
rhs_doc = Nokogiri::XML rhs_str
|
150
|
-
|
151
|
-
expected = rhs_doc
|
152
|
-
actual = lhs_doc.at_xpath('/outer/mid')
|
153
|
-
|
154
|
-
r = xml_compare expected, actual, normalise_whitespace: true, ignore_xml_declarations: false
|
155
|
-
|
156
|
-
assert !r.same?
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_different_declarations_and_do_ignore
|
160
|
-
|
161
|
-
lhs_str = <<END_OF_lhs_doc
|
162
|
-
<?xml version="1.0"?>
|
163
|
-
<outer>
|
164
|
-
<mid>
|
165
|
-
<inner>some text</inner>
|
166
|
-
</mid>
|
167
|
-
</outer>
|
168
|
-
END_OF_lhs_doc
|
169
|
-
|
170
|
-
rhs_str = <<END_OF_rhs_doc
|
171
|
-
<?xml version="1.0"?>
|
172
|
-
<mid>
|
173
|
-
<inner>some text</inner>
|
174
|
-
</mid>
|
175
|
-
END_OF_rhs_doc
|
176
|
-
|
177
|
-
lhs_doc = Nokogiri::XML lhs_str
|
178
|
-
rhs_doc = Nokogiri::XML rhs_str
|
179
|
-
|
180
|
-
expected = rhs_doc
|
181
|
-
actual = lhs_doc.at_xpath('/outer/mid')
|
182
|
-
|
183
|
-
r = xml_compare expected, actual, normalise_whitespace: true, ignore_xml_declarations: true
|
184
|
-
|
185
|
-
assert r.same?, "#{r.details}"
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_different_node_contents_by_child_node_order
|
189
|
-
|
190
|
-
lhs_str = <<END_OF_lhs_doc
|
191
|
-
<?xml version="1.0"?>
|
192
|
-
<outer>
|
193
|
-
<mid_1>
|
194
|
-
<inner>some text</inner>
|
195
|
-
</mid_1>
|
196
|
-
<mid_2>
|
197
|
-
<inner>some more text</inner>
|
198
|
-
</mid_2>
|
199
|
-
</outer>
|
200
|
-
END_OF_lhs_doc
|
201
|
-
|
202
|
-
rhs_str = <<END_OF_rhs_doc
|
203
|
-
<?xml version="1.0"?>
|
204
|
-
<outer>
|
205
|
-
<mid_2>
|
206
|
-
<inner>some more text</inner>
|
207
|
-
</mid_2>
|
208
|
-
<mid_1>
|
209
|
-
<inner>some text</inner>
|
210
|
-
</mid_1>
|
211
|
-
</outer>
|
212
|
-
END_OF_rhs_doc
|
213
|
-
|
214
|
-
lhs_doc = Nokogiri::XML lhs_str
|
215
|
-
rhs_doc = Nokogiri::XML rhs_str
|
216
|
-
|
217
|
-
expected = rhs_doc
|
218
|
-
actual = lhs_doc
|
219
|
-
|
220
|
-
r = xml_compare expected, actual, ignore_child_node_order: true, normalise_whitespace: true, ignore_xml_declarations: true
|
221
|
-
|
222
|
-
assert r.same?, "#{r.details}"
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_different_node_contents_by_child_node_order_and_whitespace
|
226
|
-
|
227
|
-
lhs_str = <<END_OF_lhs_doc
|
228
|
-
<?xml version="1.0"?>
|
229
|
-
<outer><mid_1><inner>some text</inner></mid_1><mid_2><inner>some more text</inner></mid_2></outer>
|
230
|
-
END_OF_lhs_doc
|
231
|
-
|
232
|
-
rhs_str = <<END_OF_rhs_doc
|
233
|
-
<?xml version="1.0"?>
|
234
|
-
<outer>
|
235
|
-
<mid_2>
|
236
|
-
<inner>some more text</inner>
|
237
|
-
</mid_2>
|
238
|
-
<mid_1>
|
239
|
-
<inner>some text</inner>
|
240
|
-
</mid_1>
|
241
|
-
</outer>
|
242
|
-
END_OF_rhs_doc
|
243
|
-
|
244
|
-
lhs_doc = Nokogiri::XML lhs_str
|
245
|
-
rhs_doc = Nokogiri::XML rhs_str
|
246
|
-
|
247
|
-
expected = rhs_doc
|
248
|
-
actual = lhs_doc
|
249
|
-
|
250
|
-
r = xml_compare expected, actual, ignore_child_node_order: true, normalise_whitespace: true, ignore_xml_declarations: true
|
251
|
-
|
252
|
-
assert r.same?, "#{r.details}"
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
|
@@ -1,55 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
|
4
|
-
|
5
|
-
require 'xqsr3/xml/utilities/navigation'
|
6
|
-
|
7
|
-
require 'xqsr3/extensions/test/unit'
|
8
|
-
require 'test/unit'
|
9
|
-
|
10
|
-
require 'nokogiri'
|
11
|
-
|
12
|
-
class Test_Xqsr3_XML_Utilities_Navigation < Test::Unit::TestCase
|
13
|
-
|
14
|
-
include ::Xqsr3::XML::Utilities::Navigation
|
15
|
-
|
16
|
-
def test_get_descendants_1
|
17
|
-
|
18
|
-
xml_s = <<END_OF_rhs_doc
|
19
|
-
<?xml version="1.0"?>
|
20
|
-
<document>
|
21
|
-
<outer>
|
22
|
-
<mid_2>
|
23
|
-
<inner>some more text</inner>
|
24
|
-
</mid_2>
|
25
|
-
<mid_1>
|
26
|
-
<inner>some text</inner>
|
27
|
-
</mid_1>
|
28
|
-
</outer>
|
29
|
-
</document>
|
30
|
-
END_OF_rhs_doc
|
31
|
-
|
32
|
-
xml = ::Nokogiri.XML(xml_s)
|
33
|
-
doc = xml.children.first
|
34
|
-
|
35
|
-
descs = self.class.get_descendants xml.children.first
|
36
|
-
|
37
|
-
assert_not_nil descs
|
38
|
-
assert_kind_of ::Array, descs
|
39
|
-
|
40
|
-
assert_operator 7, :<=, descs.size
|
41
|
-
%w{ outer mid_1 mid_2 }.each do |name|
|
42
|
-
|
43
|
-
assert(descs.find { |el| name == el.name }, "did not find an element named '#{name}' in the collection #{descs}")
|
44
|
-
end
|
45
|
-
|
46
|
-
texts = descs.select { |el| el.text? }
|
47
|
-
|
48
|
-
[ 'some text', 'some more text' ].each do |text|
|
49
|
-
|
50
|
-
assert(texts.find { |el| text == el.text }, "did not find an element with the text '#{text}' in the collection #{texts}")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# executes all other tests
|
4
|
-
|
5
|
-
this_dir = File.expand_path(File.dirname(__FILE__))
|
6
|
-
|
7
|
-
# all tc_*rb in current directory
|
8
|
-
Dir[File.join(this_dir, 'tc_*rb')].each { |file| require file }
|
9
|
-
|
10
|
-
# all ts_*rb in immediate sub-directories
|
11
|
-
Dir[File.join(this_dir, '*', 'ts_*rb')].each { |file| require file }
|
12
|
-
|