diff --git a/test/helper.rb b/test/helper.rb index e67d7d25..c7fe6264 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -10,12 +10,12 @@ include Jekyll class Test::Unit::TestCase include RR::Adapters::TestUnit - def dest_dir - File.join(File.dirname(__FILE__), 'dest') + def dest_dir(subdirs = []) + File.join(File.dirname(__FILE__), 'dest', *subdirs) end - def source_dir - File.join(File.dirname(__FILE__), 'source') + def source_dir(subdirs = []) + File.join(File.dirname(__FILE__), 'source', *subdirs) end def clear_dest diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 91c5edf2..da4b26b8 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -10,7 +10,7 @@ class TestGeneratedSite < Test::Unit::TestCase @site = Site.new(Jekyll.configuration) @site.process - @index = File.read(File.join(dest_dir, 'index.html')) + @index = File.read(dest_dir('index.html')) end should "insert site.posts into the index" do @@ -18,21 +18,21 @@ class TestGeneratedSite < Test::Unit::TestCase end should "render post.content" do - latest_post = Dir[File.join(source_dir, '_posts/*')].last + latest_post = Dir[source_dir('_posts/*')].last post = Post.new(@site, source_dir, '', File.basename(latest_post)) post.transform assert @index.include?(post.content) end should "hide unpublished posts" do - published = Dir[File.join(dest_dir, 'publish_test/2008/02/02/*.html')].map {|f| File.basename(f)} + published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)} assert_equal 1, published.size assert_equal "published.html", published.first end should "not copy _posts directory" do - assert !File.exist?(File.join(dest_dir, '_posts')) + assert !File.exist?(dest_dir('_posts')) end end end diff --git a/test/test_post.rb b/test/test_post.rb index 936ddad0..da8b465b 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/helper' class TestPost < Test::Unit::TestCase def setup_post(file) - Post.new(@site, File.join(File.dirname(__FILE__), 'source'), '', file) + Post.new(@site, source_dir, '', file) end def do_render(post) - layouts = {"default" => Layout.new(@site, File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")} + layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")} post.render(layouts, {"site" => {"posts" => []}}) end @@ -32,7 +32,7 @@ class TestPost < Test::Unit::TestCase @real_file = "2008-10-18-foo-bar.textile" @fake_file = "2008-10-19-foo-bar.textile" - @source = File.join(File.dirname(__FILE__), *%w[source _posts]) + @source = source_dir('_posts') end should "keep date, title, and markup type" do