Created
February 22, 2010 20:33
-
-
Save yokolet/311468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_inspect_ns | |
xml = Nokogiri::XML(<<-eoxml) { |c| c.noblanks } | |
<root xmlns="http://tenderlovemaking.com/" xmlns:foo="bar"> | |
<awesome/> | |
</root> | |
eoxml | |
p xml.to_s | |
ins = xml.inspect | |
puts "ins: #{ins}" | |
xml.traverse do |node| | |
assert_match node.class.name, ins | |
puts "node.class.name: #{node.class.name}" | |
if node.respond_to? :attributes | |
node.attributes.each do |k,v| | |
assert_match k, ins | |
assert_match v, ins | |
puts "k: #{k}" | |
puts "v: #{v}" | |
end | |
end | |
if node.respond_to?(:namespace) && node.namespace | |
assert_match node.namespace.class.name, ins | |
assert_match node.namespace.href, ins | |
puts "node.namespace.class.name: #{node.namespace.class.name}" | |
puts "node.namespace.href: #{node.namespace.href}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment