From 749b5a5ff85ee514e2d917b0cd7977f668b1e4dc Mon Sep 17 00:00:00 2001 From: Henrik Date: Tue, 4 Sep 2012 22:25:16 +0200 Subject: [PATCH 1/9] Adding functionality for fetching code from github hack for 1.8.7 Don't miss test_markup's relative require need some food now --- .gitignore | 1 + README.md | 21 ++++++++++++++++ lib/gollum/gitcode.rb | 46 +++++++++++++++++++++++++++++++++++ lib/gollum/markup.rb | 16 +++++++++++++ templates/helper_wiki.rb | 9 +++++++ test/test_gitcode.rb | 52 ++++++++++++++++++++++++++++++++++++++++ test/test_markup.rb | 11 ++++----- test/wiki_factory.rb | 10 ++++++++ 8 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 lib/gollum/gitcode.rb create mode 100644 templates/helper_wiki.rb create mode 100644 test/test_gitcode.rb create mode 100644 test/wiki_factory.rb diff --git a/.gitignore b/.gitignore index 033ec934..62e405fe 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ pkg .bundle Gemfile.lock *.gem +*.swp diff --git a/README.md b/README.md index 47023643..c41348dd 100644 --- a/README.md +++ b/README.md @@ -334,6 +334,27 @@ then that whitespace will be ignored (this makes the blocks easier to read in pl The block must end with three backticks indented at the same level than the opening backticks. +### GITHUB SYNTAX HIGHLIGHTING + +As an extra feature, you can syntax highlight a file from your repository, allowing +you keep some of your sample code in the main repository. The code-snippet is +updated when the wiki is rebuilt. You include github code like this: + + ```html:github/gollum/master/test/file_view/1_file.txt``` + +This will make the builder look at the **github user**, in the **gollum project**, +in the **master branch**, at path **test/file_view/1_file.txt**. It will be +rewritten to: + + ```html +
    +
  1. 0
  2. +
+ ``` + +Which will be parsed as HTML code during the Pygments run, and thereby coloured +appropriately. + ## MATHEMATICAL EQUATIONS diff --git a/lib/gollum/gitcode.rb b/lib/gollum/gitcode.rb new file mode 100644 index 00000000..9c2576d3 --- /dev/null +++ b/lib/gollum/gitcode.rb @@ -0,0 +1,46 @@ +require 'net/http' +require 'uri' +require 'open-uri' + +module Gollum + class Gitcode + def initialize path + raise(ArgumentError, 'path is nil or empty') if path.nil? or path.empty? + @uri = URI::HTTP.build({ + :path => self.unchomp(path), + :host => 'raw.github.com', + :scheme => 'https', + :port => 443 }) + end + + def contents + @contents ||= self.req @uri + #req @uri + end + + def unchomp p + p[0] == '/' ? p : ('/' + p) + end + + def req uri, cut = 1 + #puts uri.to_s + return "Too many redirects or retries" if cut >= 10 + http = Net::HTTP.new uri.host, uri.port + http.use_ssl = true + resp = http.get uri.path, { + 'Accept' => 'text/plain', + 'Cache-Control' => 'no-cache', + 'Connection' => 'keep-alive', + 'Host' => uri.host, + 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0' + } + code = resp.code.to_i + return resp.body if code == 200 + return "Not Found" if code == 404 + return "Unhandled Response Code #{code}" unless code == 304 or not resp.header['location'].nil? + loc = URI.parse resp.header['location'] + uri2 = loc.relative?() ? (uri + loc) : loc # overloads (+) + return req uri2, (cut + 1) + end + end +end diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index e1970338..07df6df6 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -2,6 +2,7 @@ require 'digest/sha1' require 'cgi' require 'pygments' require 'base64' +require File.expand_path( '../gitcode', __FILE__ ) # initialize Pygments Pygments.start @@ -50,6 +51,7 @@ module Gollum data = @data.dup data = extract_metadata(data) + data = extract_gitcode(data) data = extract_code(data) data = extract_tex(data) data = extract_wsd(data) @@ -449,6 +451,20 @@ module Gollum end end + ######################################################################### + # + # Gitcode - fetch code from github search path and replace the contents + # to a code-block that gets run the next parse. + # + ######################################################################### + + def extract_gitcode data + data.gsub /^[ \t]*``` ?(\w+):(.+)```$/ do + gc = Gollum::Gitcode.new $2 + "```#{$1}\n#{gc.contents}\n```" + end + end + ######################################################################### # # Code diff --git a/templates/helper_wiki.rb b/templates/helper_wiki.rb new file mode 100644 index 00000000..16c17cba --- /dev/null +++ b/templates/helper_wiki.rb @@ -0,0 +1,9 @@ +class WikiFactory + def self.create p + path = testpath "examples/test.git" + Grit::Repo.init_bare(@path) + Gollum::Wiki.default_options = {:universal_toc => false} + cleanup = lambda { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) } + Gollum::Wiki.new(@path), @path, cleanup + end +end diff --git a/test/test_gitcode.rb b/test/test_gitcode.rb new file mode 100644 index 00000000..14546c06 --- /dev/null +++ b/test/test_gitcode.rb @@ -0,0 +1,52 @@ +# ~*~ encoding: utf-8 ~*~ +require File.expand_path( '../helper', __FILE__ ) +require File.expand_path( '../wiki_factory', __FILE__ ) + +context "gitcode" do + + def page_with_content c + index = @wiki.repo.index + index.add 'Sample-Html.md', c + index.commit 'adding file html sample' + + page = @wiki.page 'Sample Html' + page + end + + setup do + # context + @wiki, @path, @cleanup = WikiFactory.create 'examples/test.git' + + # given + p = page_with_content "a\n\n```html:github/gollum/master/test/file_view/1_file.txt```\n\nb" + + # when rendering the page + @rendered = Gollum::Markup.new(p).render + 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 + end + + test 'contents' do + g = Gollum::Gitcode.new 'github/gollum/master/test/file_view/1_file.txt' + + assert_equal g.contents, %{
    +
  1. 0
  2. +
} + end + + teardown do + @cleanup.() + end +end diff --git a/test/test_markup.rb b/test/test_markup.rb index c62ffd09..6e7b6a0d 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -1,17 +1,14 @@ # ~*~ encoding: utf-8 ~*~ -require File.expand_path(File.join(File.dirname(__FILE__), "helper")) +require File.expand_path( "../helper", __FILE__ ) +require File.expand_path( "../wiki_factory", __FILE__ ) context "Markup" do setup do - @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) + @wiki, @path, @teardown = WikiFactory.create 'examples/test.git' end teardown do - FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w[examples test.git])) + @teardown.() end test "formats page from Wiki#pages" do diff --git a/test/wiki_factory.rb b/test/wiki_factory.rb new file mode 100644 index 00000000..aade4432 --- /dev/null +++ b/test/wiki_factory.rb @@ -0,0 +1,10 @@ +class WikiFactory + def self.create p + path = testpath "examples/test.git" + Grit::Repo.init_bare(path) + Gollum::Wiki.default_options = {:universal_toc => false} + cleanup = lambda { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) } + wiki = Gollum::Wiki.new(path) + return wiki, path, cleanup + end +end From d406472882e1a64dd11565273e86ac7279dc437f Mon Sep 17 00:00:00 2001 From: Henrik Date: Wed, 5 Sep 2012 00:51:28 +0200 Subject: [PATCH 2/9] 1.8.7 fixes --- lib/gollum/gitcode.rb | 1 + test/test_gitcode.rb | 2 +- test/test_markup.rb | 2 +- test/wiki_factory.rb | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/gollum/gitcode.rb b/lib/gollum/gitcode.rb index 9c2576d3..550e388c 100644 --- a/lib/gollum/gitcode.rb +++ b/lib/gollum/gitcode.rb @@ -1,4 +1,5 @@ require 'net/http' +require 'net/https' # ruby 1.8.7 fix, remove at upgrade require 'uri' require 'open-uri' diff --git a/test/test_gitcode.rb b/test/test_gitcode.rb index 14546c06..d0599d6d 100644 --- a/test/test_gitcode.rb +++ b/test/test_gitcode.rb @@ -47,6 +47,6 @@ context "gitcode" do end teardown do - @cleanup.() + @cleanup.call end end diff --git a/test/test_markup.rb b/test/test_markup.rb index 6e7b6a0d..411fef34 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -8,7 +8,7 @@ context "Markup" do end teardown do - @teardown.() + @teardown.call end test "formats page from Wiki#pages" do diff --git a/test/wiki_factory.rb b/test/wiki_factory.rb index aade4432..e6536f28 100644 --- a/test/wiki_factory.rb +++ b/test/wiki_factory.rb @@ -3,7 +3,7 @@ class WikiFactory path = testpath "examples/test.git" Grit::Repo.init_bare(path) Gollum::Wiki.default_options = {:universal_toc => false} - cleanup = lambda { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) } + cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) } wiki = Gollum::Wiki.new(path) return wiki, path, cleanup end From f9a6187fab40a63cac59cff347bfb06a0db3ce0f Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 10 Sep 2012 20:45:39 -0600 Subject: [PATCH 3/9] Fix undefined method `[]' for nil:NilClass --- lib/gollum/gitcode.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gollum/gitcode.rb b/lib/gollum/gitcode.rb index 550e388c..52b3beac 100644 --- a/lib/gollum/gitcode.rb +++ b/lib/gollum/gitcode.rb @@ -20,6 +20,7 @@ module Gollum end def unchomp p + return p if p.nil? p[0] == '/' ? p : ('/' + p) end From 424b4d3f4e34fd60d77cb778d1476e16da10221e Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 10 Sep 2012 20:46:44 -0600 Subject: [PATCH 4/9] Remove debug statements. --- lib/gollum/gitcode.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/gollum/gitcode.rb b/lib/gollum/gitcode.rb index 52b3beac..63f5d9e0 100644 --- a/lib/gollum/gitcode.rb +++ b/lib/gollum/gitcode.rb @@ -16,7 +16,6 @@ module Gollum def contents @contents ||= self.req @uri - #req @uri end def unchomp p @@ -25,7 +24,6 @@ module Gollum end def req uri, cut = 1 - #puts uri.to_s return "Too many redirects or retries" if cut >= 10 http = Net::HTTP.new uri.host, uri.port http.use_ssl = true From 05c4bf33741a88b261ff15dac421e45d226a0a89 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 10 Sep 2012 21:37:47 -0600 Subject: [PATCH 5/9] Add local file support. Example of absolute path to local file. ```html:/home``` Example of relative path to local file. ```html:home``` 1.8.7 string fix. 's'[0..0] instead of 's'[0] Fix regex. Add absolute and relative tests. --- lib/gollum/frontend/app.rb | 6 ------ lib/gollum/frontend/helpers.rb | 6 ++++++ lib/gollum/gitcode.rb | 1 + lib/gollum/markup.rb | 26 ++++++++++++++++++++++---- test/test_markup.rb | 29 +++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 05468abe..dbc98212 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -89,12 +89,6 @@ module Precious redirect File.join(settings.wiki_options[:base_path].to_s, 'Home') end - # Removes all slashes from the start of string. - def clean_url url - return url if url.nil? - url.gsub('%2F','/').gsub(/^\/+/,'') - end - # path is set to name if path is nil. # if path is 'a/b' and a and b are dirs, then # path must have a trailing slash 'a/b/' or diff --git a/lib/gollum/frontend/helpers.rb b/lib/gollum/frontend/helpers.rb index 845a0c7a..b8ec4afb 100644 --- a/lib/gollum/frontend/helpers.rb +++ b/lib/gollum/frontend/helpers.rb @@ -17,5 +17,11 @@ module Precious def sanitize_empty_params(param) [nil,''].include?(param) ? nil : CGI.unescape(param) end + + # Remove all slashes from the start of string. + def clean_url url + return url if url.nil? + url.gsub('%2F','/').gsub(/^\/+/,'') + end end end diff --git a/lib/gollum/gitcode.rb b/lib/gollum/gitcode.rb index 63f5d9e0..a4a8c064 100644 --- a/lib/gollum/gitcode.rb +++ b/lib/gollum/gitcode.rb @@ -7,6 +7,7 @@ module Gollum class Gitcode def initialize path raise(ArgumentError, 'path is nil or empty') if path.nil? or path.empty? + @uri = URI::HTTP.build({ :path => self.unchomp(path), :host => 'raw.github.com', diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 07df6df6..9351376d 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -2,7 +2,9 @@ require 'digest/sha1' require 'cgi' require 'pygments' require 'base64' -require File.expand_path( '../gitcode', __FILE__ ) + +require File.expand_path '../frontend/helpers', __FILE__ +require File.expand_path '../gitcode', __FILE__ # initialize Pygments Pygments.start @@ -10,6 +12,8 @@ Pygments.start module Gollum class Markup + include Precious::Helpers + attr_accessor :toc attr_reader :metadata @@ -459,9 +463,23 @@ module Gollum ######################################################################### def extract_gitcode data - data.gsub /^[ \t]*``` ?(\w+):(.+)```$/ do - gc = Gollum::Gitcode.new $2 - "```#{$1}\n#{gc.contents}\n```" + data.gsub /^[ \t]*``` ?([^:\n\r]+):([^`\n\r]+)```/ do + contents = '' + # Use empty string if $2 is nil. + uri = $2 || '' + # Detect local file. + if uri[0..6] != 'github/' + if uri[0..0] != '/' # relative file + contents = @wiki.page(uri).formatted_data + else # use full path + contents = @wiki.paged( extract_name( clean_url( uri ) ), + '/' + clean_url( extract_path( uri ) ) ).formatted_data + end + else + contents = Gollum::Gitcode.new(uri).contents + end + + "```#{$1}\n#{contents}\n```\n" end end diff --git a/test/test_markup.rb b/test/test_markup.rb index 411fef34..5ac12435 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -495,6 +495,35 @@ np.array([[2,2],[1,3]],np.float) assert_match /\(\[\[/, rendered, "#{markup_class} parses out wiki links\n#{rendered}" end + test "embed code is escaped" do + @wiki.write_page("script", :markdown, "a b", commit_details) + @wiki.write_page("page", :markdown, "```html:script```", commit_details) + + output_script = @wiki.page("script").formatted_data + 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 + end + + test "embed code page absolute link" do + @wiki.write_page("base", :markdown, "a\n!base\b", commit_details) + @wiki.write_page("a", :markdown, "a\n```html:/base```\b", commit_details) + + page = @wiki.page("a") + output = page.formatted_data + assert_equal %Q{

a\n

\n
<p>a\n!base</p>\n
\n
\n\n}, output + end + + test "embed code page relative link" do + @wiki.write_page("base", :markdown, "a\n!rel\b", commit_details) + @wiki.write_page("a", :markdown, "a\n```html:base```\b", commit_details) + + page = @wiki.page("a") + output = page.formatted_data + assert_equal %Q{

a\n

\n
<p>a\n!rel</p>\n
\n
\n\n}, output + end + ######################################################################### # # Web Sequence Diagrams From 9b63c67d8c5ecba2258462fdd82a8d608cde839f Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Tue, 25 Sep 2012 23:57:35 -0600 Subject: [PATCH 6/9] 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 ######################################################################### From d02b63a43488898f36b91d8b836658348494ae32 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Wed, 26 Sep 2012 00:08:11 -0600 Subject: [PATCH 7/9] Fix test. --- test/test_gitcode.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_gitcode.rb b/test/test_gitcode.rb index 72374ec8..0a7890e9 100644 --- a/test/test_gitcode.rb +++ b/test/test_gitcode.rb @@ -25,7 +25,7 @@ context "gitcode" do end test 'that the rendered output is correctly fetched and rendered as html code' do - assert_equal %Q{

a

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

b

}, @rendered + assert_equal %Q{

a

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

b

}, @rendered end test 'contents' do From 3c1c588953b8b8c6ba5fe0d0bc3c394ef9f1d95d Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 1 Oct 2012 23:23:40 -0600 Subject: [PATCH 8/9] Restore wiki_factory. --- test/test_markup.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/test_markup.rb b/test/test_markup.rb index fc34263d..2828f309 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -1,17 +1,14 @@ # ~*~ encoding: utf-8 ~*~ -require File.expand_path(File.join(File.dirname(__FILE__), "helper")) +require File.expand_path( "../helper", __FILE__ ) +require File.expand_path( "../wiki_factory", __FILE__ ) context "Markup" do setup do - @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) + @wiki, @path, @teardown = WikiFactory.create 'examples/test.git' end teardown do - FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w[examples test.git])) + @teardown.() end test "formats page from Wiki#pages" do From 7142e284fa7e3056ea335b4f01df0ee3c3ea8998 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 1 Oct 2012 23:29:15 -0600 Subject: [PATCH 9/9] .call instead of .() for 1.8.7 --- test/test_markup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_markup.rb b/test/test_markup.rb index 2828f309..3424e92a 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -8,7 +8,7 @@ context "Markup" do end teardown do - @teardown.() + @teardown.call end test "formats page from Wiki#pages" do