From 9b63c67d8c5ecba2258462fdd82a8d608cde839f Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Tue, 25 Sep 2012 23:57:35 -0600 Subject: [PATCH] Try to fix tests. --- test/test_gitcode.rb | 12 +----------- test/test_markup.rb | 45 ++++++++++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/test/test_gitcode.rb b/test/test_gitcode.rb index d0599d6d..72374ec8 100644 --- a/test/test_gitcode.rb +++ b/test/test_gitcode.rb @@ -25,17 +25,7 @@ context "gitcode" do end test 'that the rendered output is correctly fetched and rendered as html code' do - assert_equal %Q{

a

- -
-
<ol class="tree">
-  <li class="file"><a href="0">0</a></li>
-</ol>
-
-
- - -

b

}, @rendered + assert_equal %Q{

a

\n\n
 class=\"tree\">\n   class=\"file\"> href=\"0\">0\n\n
\n\n

b

}, @rendered end test 'contents' do diff --git a/test/test_markup.rb b/test/test_markup.rb index 5ac12435..fc34263d 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -1,14 +1,17 @@ # ~*~ encoding: utf-8 ~*~ -require File.expand_path( "../helper", __FILE__ ) -require File.expand_path( "../wiki_factory", __FILE__ ) +require File.expand_path(File.join(File.dirname(__FILE__), "helper")) context "Markup" do setup do - @wiki, @path, @teardown = WikiFactory.create 'examples/test.git' + @path = testpath("examples/test.git") + FileUtils.rm_rf(@path) + Grit::Repo.init_bare(@path) + Gollum::Wiki.default_options = {:universal_toc => false} + @wiki = Gollum::Wiki.new(@path) end teardown do - @teardown.call + FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w[examples test.git])) end test "formats page from Wiki#pages" do @@ -181,6 +184,22 @@ context "Markup" do assert_equal "

sed -i '' 's/[[:space:]]*$//'

", page.formatted_data end + test "regexp gsub! backref (#383)" do + # bug only triggers on "```" syntax + # not `code` + page = 'test_rgx' + @wiki.write_page(page, :markdown, + (<<-'DATA' + ``` + rot13='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\' + ``` + DATA + ), commit_details) + output = @wiki.page(page).formatted_data + expected = %Q{
      
rot13='tr '\\''A-Za-z'\\'' '\\''N-ZA-Mn-za-m'\\'\n
\n
}.strip # remove trailing \n + assert_equal expected, output + end + test "wiki link within code block" do @wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details) page = @wiki.page("Potato") @@ -393,9 +412,7 @@ context "Markup" do test "code blocks" do content = "a\n\n```ruby\nx = 1\n```\n\nb" - output = "

a

\n\n
\n
" +
-             "x = " +
-             "1\n
\n
\n\n\n

b

" + output = %Q{

a

\n\n
x = 1\n
\n\n

b

} index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) @@ -408,9 +425,7 @@ context "Markup" do test "code blocks with carriage returns" do content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb" - output = "

a

\n\n
\n
" +
-             "x = " +
-             "1\n
\n
\n\n\n

b

" + output = %Q{

a

\n\n
x = 1\n
\n\n

b

} index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) @@ -441,9 +456,7 @@ context "Markup" do test "code blocks with multibyte caracters indent" do content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb" - output = "

a

\n\n
\n
" +
-             "s = 'やくしまるえつこ'" +
-             "\n
\n
\n\n\n

b

" + output = %Q{

a

\n\n
s = 'やくしまるえつこ'\n
\n\n

b

} index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add alpha.jpg") @@ -503,7 +516,7 @@ np.array([[2,2],[1,3]],np.float) output_page = @wiki.page("page").formatted_data assert_equal %Q{

a b

}, output_script - assert_equal %Q{
\n
<p>a  b</p>\n
\n
\n}, output_page + assert_equal %Q{
<p>a  b</p>\n
}, output_page end test "embed code page absolute link" do @@ -512,7 +525,7 @@ np.array([[2,2],[1,3]],np.float) page = @wiki.page("a") output = page.formatted_data - assert_equal %Q{

a\n

\n
<p>a\n!base</p>\n
\n
\n\n}, output + assert_equal %Q{

a\n

<p>a\n!base</p>\n
\n}, output end test "embed code page relative link" do @@ -521,7 +534,7 @@ np.array([[2,2],[1,3]],np.float) page = @wiki.page("a") output = page.formatted_data - assert_equal %Q{

a\n

\n
<p>a\n!rel</p>\n
\n
\n\n}, output + assert_equal %Q{

a\n

<p>a\n!rel</p>\n
\n}, output end #########################################################################