Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop DirectoryWatcher from watching the destination directory #862

Merged
merged 6 commits into from
Mar 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/site_configuration.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: Site configuration
I want to be able to configure jekyll I want to be able to configure jekyll
In order to make setting up a site easier In order to make setting up a site easier


Scenario: Change destination directory Scenario: Change source directory
Given I have a blank site in "_sourcedir" Given I have a blank site in "_sourcedir"
And I have an "_sourcedir/index.html" file that contains "Changing source directory" And I have an "_sourcedir/index.html" file that contains "Changing source directory"
And I have a configuration file with "source" set to "_sourcedir" And I have a configuration file with "source" set to "_sourcedir"
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/command.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command
def self.globs(source, destination) def self.globs(source, destination)
Dir.chdir(source) do Dir.chdir(source) do
dirs = Dir['*'].select { |x| File.directory?(x) } dirs = Dir['*'].select { |x| File.directory?(x) }
dirs -= [destination] dirs -= [destination, File.expand_path(destination), File.basename(destination)]
dirs = dirs.map { |x| "#{x}/**/*" } dirs = dirs.map { |x| "#{x}/**/*" }
dirs += ['*'] dirs += ['*']
end end
Expand Down
14 changes: 12 additions & 2 deletions test/helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,17 +28,27 @@ class Test::Unit::TestCase
include RR::Adapters::TestUnit include RR::Adapters::TestUnit


def dest_dir(*subdirs) def dest_dir(*subdirs)
File.join(File.dirname(__FILE__), 'dest', *subdirs) test_dir('dest', *subdirs)
end end


def source_dir(*subdirs) def source_dir(*subdirs)
File.join(File.dirname(__FILE__), 'source', *subdirs) test_dir('source', *subdirs)
end end


def clear_dest def clear_dest
FileUtils.rm_rf(dest_dir) FileUtils.rm_rf(dest_dir)
end end


def test_dir(*subdirs)
File.join(File.dirname(__FILE__), *subdirs)
end

def directory_with_contents(path)
FileUtils.rm_rf(path)
FileUtils.mkdir(path)
File.open("#{path}/index.html", "w"){ |f| f.write("I was previously generated.") }
end

def capture_stdout def capture_stdout
$old_stdout = $stdout $old_stdout = $stdout
$stdout = StringIO.new $stdout = StringIO.new
Expand Down
39 changes: 39 additions & 0 deletions test/test_command.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,39 @@
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
directory_with_contents(@dest)
@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
teardown do
clear_dest
end
end
context "when using default dest dir" do
setup do
@source = test_dir
@dest = test_dir('_site')
directory_with_contents(@dest)
@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