Raise when theme root directory is not available (#6455)
Merge pull request 6455
This commit is contained in:
parent
df6608e11d
commit
8dbe5de66b
|
@ -16,7 +16,8 @@ module Jekyll
|
|||
# Otherwise, Jekyll.sanitized path with prepend the unresolved root
|
||||
@root ||= File.realpath(gemspec.full_gem_path)
|
||||
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
|
||||
nil
|
||||
raise "Path #{gemspec.full_gem_path} does not exist, is not accessible "\
|
||||
"or includes a symbolic link loop"
|
||||
end
|
||||
|
||||
def includes_path
|
||||
|
|
|
@ -64,6 +64,27 @@ class TestTheme < JekyllUnitTest
|
|||
end
|
||||
end
|
||||
|
||||
context "invalid theme" do
|
||||
context "initializing" do
|
||||
setup do
|
||||
stub_gemspec = Object.new
|
||||
|
||||
# the directory for this theme should not exist
|
||||
allow(stub_gemspec).to receive(:full_gem_path)
|
||||
.and_return(File.expand_path("test/fixtures/test-non-existent-theme", __dir__))
|
||||
|
||||
allow(Gem::Specification).to receive(:find_by_name)
|
||||
.with("test-non-existent-theme")
|
||||
.and_return(stub_gemspec)
|
||||
end
|
||||
|
||||
should "raise when getting theme root" do
|
||||
error = assert_raises(RuntimeError) { Theme.new("test-non-existent-theme") }
|
||||
assert_match(%r!fixtures\/test-non-existent-theme does not exist!, error.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
should "retrieve the gemspec" do
|
||||
assert_equal "test-theme-0.1.0", @theme.send(:gemspec).full_name
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue