Skip to content

Commit 5f88802

Browse files
committed
Element#namespace test add
1 parent de6f40e commit 5f88802

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

test/test_core.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,18 +653,23 @@ def test_namespace
653653
assert_equal "<sean:blah>Some text</sean:blah>", out
654654
end
655655

656-
657656
def test_add_namespace
658657
e = Element.new 'a'
658+
assert_equal "", e.namespace
659+
assert_equal nil, e.namespace('foo')
659660
e.add_namespace 'someuri'
660661
e.add_namespace 'foo', 'otheruri'
661662
e.add_namespace 'xmlns:bar', 'thirduri'
663+
assert_equal "someuri", e.namespace
664+
assert_equal "otheruri", e.namespace('foo')
665+
assert_equal "otheruri", e.namespace('xmlns:foo')
666+
assert_equal "thirduri", e.namespace('bar')
667+
assert_equal "thirduri", e.namespace('xmlns:bar')
662668
assert_equal 'someuri', e.attributes['xmlns']
663669
assert_equal 'otheruri', e.attributes['xmlns:foo']
664670
assert_equal 'thirduri', e.attributes['xmlns:bar']
665671
end
666672

667-
668673
def test_big_documentation
669674
d = File.open(fixture_path("documentation.xml")) {|f| Document.new f }
670675
assert_equal "Sean Russell", d.elements["documentation/head/author"].text.tr("\n\t", " ").squeeze(" ")
@@ -764,9 +769,15 @@ def test_attributes_each
764769

765770
def test_delete_namespace
766771
doc = Document.new "<a xmlns='1' xmlns:x='2'/>"
772+
assert_equal "1", doc.root.namespace
773+
assert_equal "2", doc.root.namespace('x')
774+
assert_equal "2", doc.root.namespace('xmlns:x')
767775
doc.root.delete_namespace
768776
doc.root.delete_namespace 'x'
769777
assert_equal "<a/>", doc.to_s
778+
assert_equal "", doc.root.namespace
779+
assert_equal nil, doc.root.namespace('x')
780+
assert_equal nil, doc.root.namespace('xmlns:x')
770781
end
771782

772783
def test_each_element_with_attribute

0 commit comments

Comments
 (0)