Permalink
Browse files

Add unit tests

  • Loading branch information...
goodtouch committed Apr 17, 2014
1 parent de5a9b1 commit c8bc63f096d4e3759d5115fd43b550cfdd04b2b8
Showing with 20 additions and 3 deletions.
  1. +7 −0 test/source/_posts/2013-05-28-classifications.md
  2. +1 −1 test/test_generated_site.rb
  3. +6 −1 test/test_post.rb
  4. +6 −1 test/test_site.rb
@@ -0,0 +1,7 @@
+---
+title: Some Tags
+projects:
+- bartender
+---
+
+Our most famous beverages
@@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
end
should "ensure post count is as expected" do
- assert_equal 42, @site.posts.size
+ assert_equal 43, @site.posts.size
end
should "insert site.posts into the index" do
View
@@ -15,7 +15,7 @@ def do_render(post)
context "A Post" do
setup do
clear_dest
- stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS }
+ stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS.merge({'classifications' => %w(projects)}) }
@site = Site.new(Jekyll.configuration)
end
@@ -531,6 +531,11 @@ def do_render(post)
assert_equal "Empty YAML.", post.content
end
+ should "recognize custom project classification in yaml" do
+ post = setup_post("2013-05-28-classifications.md")
+ assert post.classifications['projects'].include?('bartender')
+ end
+
context "rendering" do
setup do
clear_dest
View
@@ -45,7 +45,7 @@ class TestSite < Test::Unit::TestCase
context "creating sites" do
setup do
stub(Jekyll).configuration do
- Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
+ Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'classifications' => %w(projects)})
end
@site = Site.new(Jekyll.configuration)
@num_invalid_posts = 2
@@ -77,6 +77,7 @@ def generate(site)
before_layouts = @site.layouts.length
before_categories = @site.categories.length
before_tags = @site.tags.length
+ before_projects = @site.classifications['projects'].length
before_pages = @site.pages.length
before_static_files = @site.static_files.length
before_time = @site.time
@@ -86,6 +87,7 @@ def generate(site)
assert_equal before_layouts, @site.layouts.length
assert_equal before_categories, @site.categories.length
assert_equal before_tags, @site.tags.length
+ assert_equal before_projects, @site.classifications['projects'].length
assert_equal before_pages, @site.pages.length
assert_equal before_static_files, @site.static_files.length
assert before_time <= @site.time
@@ -213,10 +215,13 @@ def generate(site)
posts = Dir[source_dir("**", "_posts", "**", "*")]
posts.delete_if { |post| File.directory?(post) && !Post.valid?(post) }
categories = %w(2013 bar baz category foo z_category publish_test win).sort
+ projects = %w(bartender)
assert_equal posts.size - @num_invalid_posts, @site.posts.size
assert_equal categories, @site.categories.keys.sort
+ assert_equal projects, @site.classifications['projects'].keys.sort
assert_equal 5, @site.categories['foo'].size
+ assert_equal 1, @site.classifications['projects']['bartender'].size
end
context 'error handling' do

0 comments on commit c8bc63f

Please sign in to comment.