Skip to content

Commit

Permalink
Add tests for Namespace support
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffgarside committed May 18, 2010
1 parent 69fe4ee commit c695a7e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/demolisher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,26 @@ class DemolisherTest < Test::Unit::TestCase
assert_equal 'Geoff', @demolisher.hi.there
end
end
context "Demolished XML file with Namespaces" do
setup do
@id_and_name = ''
@namespaces = {'soap' => "http://schemas.xmlsoap.org/soap/envelope/",
'ns0' => "http://services.somewhere.com",
'ns1' => "http://domain.somewhere.com" }
Demolisher.demolish(File.dirname(__FILE__) +'/ns.xml', @namespaces) do |xml|
xml.soap :Envelope do
xml.soap :Body do
xml.ns0 :getManufacturerNamesResponse do
xml.ns0 :IDAndNameList do
@id_and_name = xml.ns1(:IdAndName).strip
end
end
end
end
end
end
should "get '14-Demolisher' from XML file" do
assert_equal '14-Demolisher', @id_and_name
end
end
end
11 changes: 11 additions & 0 deletions test/ns.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getManufacturerNamesResponse xmlns="http://services.somewhere.com">
<IDAndNameList xmlns="http://services.somewhere.com">
<ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
14-Demolisher
</ns1:IdAndName>
</IDAndNameList>
</getManufacturerNamesResponse>
</soap:Body>
</soap:Envelope>

0 comments on commit c695a7e

Please sign in to comment.