Skip to content

Instantly share code, notes, and snippets.

@yokolet
Created February 22, 2010 20:33
Show Gist options
  • Save yokolet/311468 to your computer and use it in GitHub Desktop.
Save yokolet/311468 to your computer and use it in GitHub Desktop.
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