summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2014-02-23 23:29:34 +0000
committerDan Allen <dan.j.allen@gmail.com>2014-03-03 01:32:56 -0700
commitf2225b2fa97a8879b06dcef6648aa384493b07c7 (patch)
tree90462c663943cdc657b28148416d3bd331793dd0 /test
parent9a849e4fd295e2024b5a7e463b5cbf004e4f89ae (diff)
add xmlns attribute for xhtml output with test
Diffstat (limited to 'test')
-rw-r--r--test/document_test.rb9
-rw-r--r--test/test_helper.rb10
2 files changed, 13 insertions, 6 deletions
diff --git a/test/document_test.rb b/test/document_test.rb
index cf887f0b..481f78f7 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -1296,6 +1296,15 @@ two
#assert_match(/iframe [^>]+allowfullscreen="allowfullscreen"/i, result)
end
+ test 'xhtml backend should emit elements in proper namespace' do
+ input = <<-EOS
+content
+ EOS
+ result = render_string input, :safe => :safe, :backend => :xhtml, :keep_namespaces => true
+ doc = xmldoc_from_string(result)
+ assert_xpath '//*[not(namespace-uri() = "http://www.w3.org/1999/xhtml")]', result, 0
+ end
+
test 'docbook45 backend doctype article' do
input = <<-EOS
= Title
diff --git a/test/test_helper.rb b/test/test_helper.rb
index c49d9673..32e22384 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -134,12 +134,10 @@ class Test::Unit::TestCase
def xmldoc_from_string(content)
doctype_match = content.match(/\s*<!DOCTYPE (.*)/)
- if !doctype_match
- if content.match(RE_XMLNS_ATTRIBUTE)
- doc = Nokogiri::XML::Document.parse(content)
- else
- doc = Nokogiri::HTML::DocumentFragment.parse(content)
- end
+ if content.match(RE_XMLNS_ATTRIBUTE)
+ doc = Nokogiri::XML::Document.parse(content)
+ elsif !doctype_match
+ doc = Nokogiri::HTML::DocumentFragment.parse(content)
elsif doctype_match[1].start_with? 'html'
doc = Nokogiri::HTML::Document.parse(content)
else