Skip to content

Commit

Permalink
test: establish better baseline behavior for MS Word's html format
Browse files Browse the repository at this point in the history
because this is about to change in libxml 2.9.12
  • Loading branch information
flavorjones committed May 14, 2021
1 parent f9e8231 commit 3895984
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/xml/test_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1049,18 +1049,22 @@ def test_namespace_without_an_href_on_html_node
# describe how we handle microsoft word's HTML formatting.
# this test is descriptive, not prescriptive.
#
skip_unless_libxml2("Xerces handles this edge case completely differently")

xml = Nokogiri::HTML.parse(<<~EOF)
html = Nokogiri::HTML.parse(<<~EOF)
<div><o:p>foo</o:p></div>
EOF

node = xml.at("p")
node = html.at("div").children.first
assert_not_nil(node)

assert_equal(1, node.namespaces.keys.size)
assert(node.namespaces.has_key?('xmlns:o'))
assert_nil(node.namespaces['xmlns:o'])
if Nokogiri.uses_libxml?
assert_equal(1, node.namespaces.keys.size)
assert(node.namespaces.has_key?('xmlns:o'))
assert_nil(node.namespaces['xmlns:o'])
assert_equal("<p>foo</p>", node.to_html)
else
# Xerces does something completely different
assert_empty(node.namespaces.keys)
assert_equal("<o:p>foo</o:p>", node.to_html)
end
end

def test_xpath_results_have_document_and_are_decorated
Expand Down

0 comments on commit 3895984

Please sign in to comment.