test/text_test.rb in asciidoctor-0.0.7 vs test/text_test.rb in asciidoctor-0.0.9

- old
+ new

@@ -1,20 +1,40 @@ require 'test_helper' context "Text" do + test "proper encoding to handle utf8 characters in document" do + assert_xpath "//p", example_document(:encoding).render, 1 + end + + test "proper encoding to handle utf8 characters in embedded document" do + assert_xpath "//p", example_document(:encoding).render(:header_footer => false), 1 + end + + # NOTE this test ensures we have the encoding line on block templates too + test "proper encoding to handle utf8 characters in arbitrary block" do + input = [] + input << "[verse]\n" + input.concat(File.readlines(sample_doc_path(:encoding))) + doc = Asciidoctor::Document.new + reader = Asciidoctor::Reader.new input + block = Asciidoctor::Lexer.next_block(reader, doc) + assert_xpath '//pre', block.render.gsub(/^\s*\n/, ''), 1 + end + test 'escaped text markup' do - pending "Not done yet" + assert_match(/All your &lt;em&gt;inline&lt;\/em&gt; markup belongs to &lt;strong&gt;us&lt;\/strong&gt;!/, + render_string('All your <em>inline</em> markup belongs to <strong>us</strong>!')) end test "line breaks" do assert_xpath "//br", render_string("Well this is +\njust fine and dandy, isn't it?"), 1 end test "single- and double-quoted text" do rendered = render_string("``Where?,'' she said, flipping through her copy of `The New Yorker.'") - assert_match /&ldquo;Where\?,&rdquo;/, rendered - assert_match /&lsquo;The New Yorker.&rsquo;/, rendered + assert_match(/&#8220;Where\?,&#8221;/, rendered) + assert_match(/&#8216;The New Yorker.&#8217;/, rendered) end test "separator" do # for some reason, the html enclosure breaks the xpath //*[@id='content']//hr assert_xpath "//*[@id='content']//hr", render_string("This is separated.\n\n'''\n\n...from this!"), 1 @@ -22,15 +42,19 @@ test "emphasized text" do assert_xpath "//em", render_string("An 'emphatic' no") end + test "emphasized text with single quote" do + assert_xpath "//em[text()=\"Johnny#{[8217].pack('U*')}s\"]", render_string("It's 'Johnny's' phone") + end + test "emphasized text with escaped single quote" do assert_xpath "//em[text()=\"Johnny's\"]", render_string("It's 'Johnny\\'s' phone") end - test "escaped single quote is restore as single quote" do + test "escaped single quote is restored as single quote" do assert_xpath "//p[contains(text(), \"Let's do it!\")]", render_string("Let\\'s do it!") end test "emphasized text at end of line" do assert_xpath "//em", render_string("This library is 'awesome'") @@ -43,14 +67,14 @@ test "emphasized text across line" do assert_xpath "//em", render_string("'check it'") end test "unquoted text" do - assert_no_match /#/, render_string("An #unquoted# word") + assert_no_match(/#/, render_string("An #unquoted# word")) end test "backtick-escaped text followed by single-quoted text" do - assert_match /<tt>foo<\/tt>/, render_string(%Q(run `foo` 'dog')) + assert_match(/<tt>foo<\/tt>/, render_string(%Q(run `foo` 'dog'))) end context "basic styling" do setup do @rendered = render_string("A *BOLD* word. An _italic_ word. A +mono+ word. ^superscript!^ and some ~subscript~.")