Sha256: 66e1af07447c1307f2e99c0e15aa3dbc6c44ba1ea3b7364aff1e7d57383e808d
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require File.join(File.dirname(__FILE__), '..', 'test_helper') class TestXMLNamespaces < Test::Unit::TestCase def setup @book = BookWithContributions.parse(fixture(:book_with_default_namespace)) end def test_default_namespace_doesnt_interfere_with_normal_operation assert_equal("Programming Ruby - 2nd Edition", @book.title) end def test_default_namespace_is_applied_to_in_element expected_authors = ["David Thomas","Andrew Hunt","Chad Fowler"] assert !@book.contributions.empty? @book.contributions.each do |contributor| assert expected_authors.include?(contributor.name) end end def test_that_rexml_follows_nameless_default_namespace xml = REXML::Document.new( '<container xmlns="http://fakenamespace.org"><node>Yeah, content</node></container>') assert_equal "Yeah, content", xml.root.get_elements('node').first.text end def test_default_namespace_on_root_node_should_be_found require 'libxml' xml = LibXML::XML::Parser.string( '<container xmlns="http://defaultnamespace.org"><node>Yeah, content</node><node><subnode>Another</subnode></node></container>').parse assert_equal nil, xml.find_first('container') assert_equal "Yeah, content", xml.find_first('container:node', 'container:http://defaultnamespace.org').content assert_equal "Another", xml.find_first('container:node/container:subnode', 'container:http://defaultnamespace.org').content end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
Empact-roxml-2.0 | test/unit/xml_namespace_test.rb |
Empact-roxml-2.1 | test/unit/xml_namespace_test.rb |