Site#configure_theme: don't do anything if theme config is unset; TEST
This commit is contained in:
parent
4420c3b2af
commit
2b15b0b325
|
@ -423,11 +423,14 @@ module Jekyll
|
||||||
|
|
||||||
private
|
private
|
||||||
def configure_theme
|
def configure_theme
|
||||||
|
self.theme = nil
|
||||||
|
return if config["theme"].nil?
|
||||||
|
|
||||||
self.theme =
|
self.theme =
|
||||||
if config["theme"].is_a?(String)
|
if config["theme"].is_a?(String)
|
||||||
Jekyll::Theme.new(config["theme"])
|
Jekyll::Theme.new(config["theme"])
|
||||||
else
|
else
|
||||||
Jekyll.logger.warn "Theme:", "value of 'theme' in config should be "
|
Jekyll.logger.warn "Theme:", "value of 'theme' in config should be " \
|
||||||
"String to use gem-based themes, but got #{config["theme"].class}"
|
"String to use gem-based themes, but got #{config["theme"].class}"
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -489,6 +489,32 @@ 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