forked from ruby/rexml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_xpath_parser.rb
More file actions
36 lines (32 loc) · 956 Bytes
/
Copy pathtest_xpath_parser.rb
File metadata and controls
36 lines (32 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true
module REXMLTests
class TestXPathParser < Test::Unit::TestCase
def setup
@root_element = make_service_element(["urn:type1", "urn:type2"], ["http://uri"])
@element = @root_element.children[0]
@parser = REXML::XPathParser.new
end
def make_service_element(types, uris)
root_element = REXML::Element.new
element = root_element.add_element("Service")
types.each do |type_text|
element.add_element("Type").text = type_text
end
uris.each do |uri_text|
element.add_element("URI").text = uri_text
end
root_element
end
def test_found
res = @parser.parse("/Service", @root_element)
assert_equal([@element],
res)
end
def test_not_found
@parser = REXML::XPathParser.new
res = @parser.parse("/nonexistent", @root_element)
assert_equal([],
res)
end
end
end