diff --git a/test/test_filters.rb b/test/test_filters.rb index e6700191..e0893f03 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -1,41 +1,41 @@ require File.dirname(__FILE__) + '/helper' class TestFilters < Test::Unit::TestCase - class JekyllFilter include Jekyll::Filters end - - def setup - @filter = JekyllFilter.new - end - def test_textilize_with_simple_string - assert_equal "
something really simple
", @filter.textilize("something *really* simple") - end + context "filters" do + setup do + @filter = JekyllFilter.new + end - def test_array_to_sentence_string_with_no_args - assert_equal "", @filter.array_to_sentence_string([]) - end + should "textilize with simple string" do + assert_equal "something really simple
", @filter.textilize("something *really* simple") + end - def test_array_to_sentence_string_with_one_arg - assert_equal "1", @filter.array_to_sentence_string([1]) - assert_equal "chunky", @filter.array_to_sentence_string(["chunky"]) + should "convert array to sentence string with no args" do + assert_equal "", @filter.array_to_sentence_string([]) + end + + should "convert array to sentence string with one arg" do + assert_equal "1", @filter.array_to_sentence_string([1]) + assert_equal "chunky", @filter.array_to_sentence_string(["chunky"]) + end + + should "convert array to sentence string with two args" do + assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2]) + assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"]) + end + + should "convert array to sentence string with multiple args" do + assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4]) + assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"]) + end + + should "escape xml with ampersands" do + assert_equal "AT&T", @filter.xml_escape("AT&T") + assert_equal "<code>command <filename></code>", @filter.xml_escape("command <filename>
")
+ end
end
-
- def test_array_to_sentence_string_with_two_args
- assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2])
- assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"])
- end
-
- def test_array_to_sentence_string_with_multiple_args
- assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4])
- assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
- end
-
- def test_xml_escape_with_ampersands
- assert_equal "AT&T", @filter.xml_escape("AT&T")
- assert_equal "<code>command <filename></code>", @filter.xml_escape("command <filename>
")
- end
-
end
diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb
index 0762d299..a24584b7 100644
--- a/test/test_generated_site.rb
+++ b/test/test_generated_site.rb
@@ -1,32 +1,33 @@
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
- assert @index.include?("#{@s.posts.size} Posts")
- end
+ context "generated sites" do
+ setup do
+ 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_post_content_in_index
- # confirm that the {{ post.content }} is rendered OK
- latest_post = Dir[File.join(@source, '_posts/*')].last
- post = Post.new(@source, '', File.basename(latest_post))
- Jekyll.content_type = post.determine_content_type
- post.transform
- assert @index.include?(post.content)
- end
+ should "insert site.posts into the index" do
+ assert @index.include?("#{@s.posts.size} Posts")
+ end
+
+ should "render post.content" do
+ latest_post = Dir[File.join(@source, '_posts/*')].last
+ post = Post.new(@source, '', File.basename(latest_post))
+ Jekyll.content_type = post.determine_content_type
+ 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)}
+
+ assert_equal 1, published.size
+ assert_equal "published.html", published.first
+ end
- def test_unpublished_posts_are_hidden
- published = Dir[File.join(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
end
diff --git a/test/test_jekyll.rb b/test/test_jekyll.rb
deleted file mode 100644
index e69de29b..00000000
diff --git a/test/test_site.rb b/test/test_site.rb
index e19eefcd..8f32379c 100644
--- a/test/test_site.rb
+++ b/test/test_site.rb
@@ -1,36 +1,33 @@
require File.dirname(__FILE__) + '/helper'
class TestSite < Test::Unit::TestCase
- def setup
- @source = File.join(File.dirname(__FILE__), *%w[source])
- @s = Site.new(@source, dest_dir)
- end
-
- def test_site_init
-
- end
-
- def test_read_layouts
- @s.read_layouts
-
- assert_equal ["default", "simple"].sort, @s.layouts.keys.sort
- end
-
- def test_read_posts
- @s.read_posts('')
- posts = Dir[File.join(@source, '_posts/*')]
- assert_equal posts.size - 1, @s.posts.size
- end
-
- def test_site_payload
- clear_dest
- @s.process
-
- posts = Dir[File.join(@source, "**", "_posts/*")]
- categories = %w(bar baz category foo z_category publish_test).sort
+ context "creating sites" do
+ setup do
+ @source = File.join(File.dirname(__FILE__), 'source')
+ @s = Site.new(@source, dest_dir)
+ end
- assert_equal posts.size - 1, @s.posts.size
- assert_equal categories, @s.categories.keys.sort
- assert_equal 3, @s.categories['foo'].size
+ should "read layouts" do
+ @s.read_layouts
+ assert_equal ["default", "simple"].sort, @s.layouts.keys.sort
+ end
+
+ should "read posts" do
+ @s.read_posts('')
+ posts = Dir[File.join(@source, '_posts/*')]
+ assert_equal posts.size - 1, @s.posts.size
+ end
+
+ should "deploy payload" do
+ clear_dest
+ @s.process
+
+ posts = Dir[File.join(@source, "**", "_posts/*")]
+ categories = %w(bar baz category foo z_category publish_test).sort
+
+ assert_equal posts.size - 1, @s.posts.size
+ assert_equal categories, @s.categories.keys.sort
+ assert_equal 3, @s.categories['foo'].size
+ end
end
end
diff --git a/test/test_tags.rb b/test/test_tags.rb
index 4e6ad795..e400b469 100644
--- a/test/test_tags.rb
+++ b/test/test_tags.rb
@@ -1,9 +1,9 @@
require File.dirname(__FILE__) + '/helper'
class TestTags < Test::Unit::TestCase
-
- def setup
- @content = <