Skip to content

Commit

Permalink
sparklemotion#865 - Tests and fix for duplicated attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbklein committed Mar 19, 2013
1 parent 582e18f commit ba70ae0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/nokogiri/xml/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def create_element name, *args, &block
if key =~ NCNAME_RE
ns_name = key.split(":", 2)[1]
elm.add_namespace_definition ns_name, v
else
elm[k.to_s] = v.to_s
end
elm[k.to_s] = v.to_s
}
else
elm.content = arg
Expand Down
6 changes: 6 additions & 0 deletions test/namespaces/test_namespaces_in_builder_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def test_builder_buried_default_ns
def test_builder_buried_decl_ns
assert_equal 'ns:veg', check_namespace(@doc.root.elements[3].elements[1])
end
def test_builder_namespace_count
n = @doc.root.clone
n.children.each &:remove
ns_attrs = n.to_xml.scan(/\bxmlns(?::.+?)?=/)
assert_equal 3, ns_attrs.length
end
end
end
end
6 changes: 6 additions & 0 deletions test/namespaces/test_namespaces_in_created_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def test_created_buried_default_ns
def test_created_buried_decl_ns
assert_equal 'ns:veg', check_namespace(@doc.root.elements[3].elements[1])
end
def test_created_namespace_count
n = @doc.root.clone
n.children.each &:remove
ns_attrs = n.to_xml.scan(/\bxmlns(?::.+?)?=/)
assert_equal 3, ns_attrs.length
end
end
end
end
6 changes: 6 additions & 0 deletions test/namespaces/test_namespaces_in_parsed_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def test_parsed_buried_default_ns
def test_parsed_buried_decl_ns
assert_equal 'ns:veg', check_namespace(@doc.root.elements[3].elements[1])
end
def test_parsed_namespace_count
n = @doc.root.clone
n.children.each &:remove
ns_attrs = n.to_xml.scan(/\bxmlns(?::.+?)?=/)
assert_equal 3, ns_attrs.length
end
end
end
end

0 comments on commit ba70ae0

Please sign in to comment.