Merge pull request #5189 from jekyll/skip-theme-if-not-string

Merge pull request 5189
This commit is contained in:
jekyllbot 2016-08-30 14:54:47 -07:00 committed by GitHub
commit 6a34966f20
2 changed files with 38 additions and 1 deletions

View File

@ -424,7 +424,16 @@ module Jekyll
private
def configure_theme
self.theme = nil
self.theme = Jekyll::Theme.new(config["theme"]) if config["theme"]
return if config["theme"].nil?
self.theme =
if config["theme"].is_a?(String)
Jekyll::Theme.new(config["theme"])
else
Jekyll.logger.warn "Theme:", "value of 'theme' in config should be " \
"String to use gem-based themes, but got #{config["theme"].class}"
nil
end
end
private

View File

@ -489,6 +489,34 @@ class TestSite < JekyllUnitTest
end
end
context "when setting theme" do
should "set no theme if config is not set" do
expect($stderr).not_to receive(:puts)
expect($stdout).not_to receive(:puts)
site = fixture_site({ "theme" => nil })
assert_nil site.theme
end
should "set no theme if config is a hash" do
output = capture_output do
site = fixture_site({ "theme" => {} })
assert_nil site.theme
end
expected_msg = "Theme: value of 'theme' in config should be String " \
"to use gem-based themes, but got Hash\n"
assert output.end_with?(expected_msg),
"Expected #{output.inspect} to end with #{expected_msg.inspect}"
end
should "set a theme if the config is a string" do
expect($stderr).not_to receive(:puts)
expect($stdout).not_to receive(:puts)
site = fixture_site({ "theme" => "test-theme" })
assert_instance_of Jekyll::Theme, site.theme
assert_equal "test-theme", site.theme.name
end
end
context "with liquid profiling" do
setup do
@site = Site.new(site_configuration("profile" => true))