test/test_generated_site.rb in jekyll-0.4.1 vs test/test_generated_site.rb in jekyll-0.5.1
- old
+ new
@@ -1,22 +1,38 @@
require File.dirname(__FILE__) + '/helper'
class TestGeneratedSite < Test::Unit::TestCase
- def setup
- clear_dest
- source = File.join(File.dirname(__FILE__), *%w[source])
- @s = Site.new(source, dest_dir)
- @s.process
- @index = File.read(File.join(dest_dir, 'index.html'))
- end
-
- def test_site_posts_in_index
- # confirm that {{ site.posts }} is working
- puts @s.posts.size
- assert @index.include?("#{@s.posts.size} Posts")
- end
+ context "generated sites" do
+ setup do
+ clear_dest
+ stub(Jekyll).configuration do
+ Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
+ end
- def test_post_content_in_index
- # confirm that the {{ post.content }} is rendered OK
- assert @index.include?('<p>This <em>is</em> cool</p>')
+ @site = Site.new(Jekyll.configuration)
+ @site.process
+ @index = File.read(dest_dir('index.html'))
+ end
+
+ should "insert site.posts into the index" do
+ assert @index.include?("#{@site.posts.size} Posts")
+ end
+
+ should "render post.content" do
+ latest_post = Dir[source_dir('_posts', '*')].sort.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[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?(dest_dir('_posts'))
+ end
end
end