From d93faac3b8a250391c33aa8becae07572e3f3cb5 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 16 Mar 2013 13:59:59 +0100 Subject: [PATCH] Rudimentary tests for Jekyll::Command --- test/test_command.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/test_command.rb diff --git a/test/test_command.rb b/test/test_command.rb new file mode 100644 index 00000000..ad7d6db1 --- /dev/null +++ b/test/test_command.rb @@ -0,0 +1,36 @@ +require 'helper' + +class TestCommand < Test::Unit::TestCase + context "when calling .globs" do + context "when non-default dest & source dirs" do + setup do + @source = source_dir + @dest = dest_dir + @globs = Command.globs(@source, @dest) + end + should "return an array without the destination dir" do + assert @globs.is_a?(Array) + assert !@globs.include?(@dest) + end + end + context "when using default dest dir" do + setup do + @source = test_dir + @dest = test_dir('_site') + FileUtils.mkdir(@dest) + File.open("#{@dest}/index.html", "w"){ |f| f.write("I was previously generated.") } + @globs = Command.globs(@source, @dest) + end + should "return an array without the destination dir" do + assert @globs.is_a?(Array) + assert !@globs.include?(@dest) + @globs.each do |glob| + assert !glob.include?(File.basename(@dest)) + end + end + teardown do + FileUtils.rm_r(@dest) + end + end + end +end