Add tests for determining source dir
This commit is contained in:
parent
47babef79a
commit
1a879a04ab
|
|
@ -45,7 +45,7 @@ module Jekyll
|
||||||
def layout_directory_in_cwd
|
def layout_directory_in_cwd
|
||||||
# TODO: Fix on Windows
|
# TODO: Fix on Windows
|
||||||
dir = File.join(Dir.pwd, File.expand_path(site.config['layouts'], '/'))
|
dir = File.join(Dir.pwd, File.expand_path(site.config['layouts'], '/'))
|
||||||
if Directory.exists?(dir)
|
if File.directory?(dir)
|
||||||
dir
|
dir
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,22 @@ class TestLayoutReader < Test::Unit::TestCase
|
||||||
layouts = LayoutReader.new(@site).read
|
layouts = LayoutReader.new(@site).read
|
||||||
assert_equal ["default", "simple", "post/simple"].sort, layouts.keys.sort
|
assert_equal ["default", "simple", "post/simple"].sort, layouts.keys.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when no _layouts directory exists in CWD" do
|
||||||
|
should "know to use the layout directory relative to the site source" do
|
||||||
|
assert_equal LayoutReader.new(@site).send(:layout_directory), source_dir("_layouts")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when a _layouts directory exists in CWD" do
|
||||||
|
setup do
|
||||||
|
stub(File).directory? { true }
|
||||||
|
stub(Dir).pwd { source_dir("blah") }
|
||||||
|
end
|
||||||
|
|
||||||
|
should "know to use the layout directory relative to CWD" do
|
||||||
|
assert_equal LayoutReader.new(@site).send(:layout_directory), source_dir("blah/_layouts")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue