test/test_helper.rb in asciidoctor-0.0.5 vs test/test_helper.rb in asciidoctor-0.0.6
- old
+ new
@@ -48,26 +48,27 @@
assert_equal(before[i] + difference, e.call, error)
end
end
def assert_xpath(xpath, html, count = nil)
- results = Nokogiri::HTML::DocumentFragment.parse(html).xpath(".#{xpath}")
+ doc = (html =~ /\s*<!DOCTYPE/) ? Nokogiri::HTML::Document.parse(html) : Nokogiri::HTML::DocumentFragment.parse(html)
+ results = doc.xpath("#{xpath.sub('/', './')}")
if (count && results.length != count)
flunk "XPath #{xpath} yielded #{results.length} elements rather than #{count} for:\n#{html}"
elsif (count.nil? && results.empty?)
flunk "XPath #{xpath} not found in:\n#{html}"
else
assert true
end
end
- def document_from_string(src)
- Asciidoctor::Document.new(src.split("\n"))
+ def document_from_string(src, opts = {})
+ Asciidoctor::Document.new(src.lines.entries, opts)
end
- def render_string(src)
- document_from_string(src).render
+ def render_string(src, opts = {})
+ document_from_string(src, opts).render
end
end
###
#