require File.join(File.dirname(__FILE__), *%w[helper]) context "Site" do setup do path = testpath("examples/test_site.git") @site = Gollum::Site.new(path,{ :output_path => testpath("examples/site"), :version => "master" }) @site.generate() end test "generate static site" do diff = Dir[@site.output_path + "/**/*"]. map { |f| f.sub(@site.output_path, "") } - ["/Home.html", "/Page-One.html", "/Page1.html", "/Page2.html", "/page.html", "/static", "/static/static.jpg", "/static/static.txt"] assert_equal([], diff) end test "render page with layout and link" do home_path = File.join(@site.output_path, "Home.html") assert_equal(["
Site test\n", "Page1#test\n", "Page with anchor
\n"], File.open(home_path).readlines) end test "render page with layout from parent dir" do page_path = File.join(@site.output_path, "Page1.html") assert_equal(["Site test
\n"], File.open(page_path).readlines) end test "render page with layout from sub dir" do page_path = File.join(@site.output_path, "Page2.html") assert_equal(["Site test
\n"], File.open(page_path).readlines) end test "page.path is available on template" do page_path = File.join(@site.output_path, "page.html") assert_equal(["Hello World\nHello World
", data) end test "one item can be updated" do File.open(@path + '/Foo.md', 'w') { |f| f.write("Baz") } @site.update_working_item('Foo.md') data = IO.read(::File.join(@site.output_path, "Foo.html")) assert_equal("Baz
", data) end teardown do # Remove untracked file FileUtils.rm(@path + '/Foo.md') # Reset tracked file File.open(@path + '/Home.md', 'w') { |f| f.write("Hello World\n") } FileUtils.rm_r(@site.output_path) end end