require File.dirname(__FILE__) + '/helper' class TestSite < Test::Unit::TestCase context "creating sites" do setup do stub(Jekyll).configuration do Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir}) end @site = Site.new(Jekyll.configuration) end should "reset data before processing" do clear_dest @site.process before_posts = @site.posts.length before_layouts = @site.layouts.length before_categories = @site.categories.length @site.process assert_equal before_posts, @site.posts.length assert_equal before_layouts, @site.layouts.length assert_equal before_categories, @site.categories.length end should "read layouts" do @site.read_layouts assert_equal ["default", "simple"].sort, @site.layouts.keys.sort end should "read posts" do @site.read_posts('') posts = Dir[source_dir('_posts', '*')] assert_equal posts.size - 1, @site.posts.size end should "deploy payload" do clear_dest @site.process posts = Dir[source_dir("**", "_posts", "*")] categories = %w(bar baz category foo z_category publish_test).sort assert_equal posts.size - 1, @site.posts.size assert_equal categories, @site.categories.keys.sort assert_equal 4, @site.categories['foo'].size end should "filter entries" do ent1 = %w[foo.markdown bar.markdown baz.markdown #baz.markdown# .baz.markdow foo.markdown~] ent2 = %w[.htaccess _posts bla.bla] assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1) assert_equal ent2, @site.filter_entries(ent2) end end end