Merge pull request #5189 from jekyll/skip-theme-if-not-string
Merge pull request 5189
This commit is contained in:
commit
6a34966f20
|
@ -424,7 +424,16 @@ module Jekyll
|
||||||
private
|
private
|
||||||
def configure_theme
|
def configure_theme
|
||||||
self.theme = nil
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -489,6 +489,34 @@ class TestSite < JekyllUnitTest
|
||||||
end
|
end
|
||||||
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
|
context "with liquid profiling" do
|
||||||
setup do
|
setup do
|
||||||
@site = Site.new(site_configuration("profile" => true))
|
@site = Site.new(site_configuration("profile" => true))
|
||||||
|
|
Loading…
Reference in New Issue