Stringify configuration overrides before first use

This makes sure that overrides for Jekyll.configuration
all have string keys before their first use, particularly
also the "config" and "skip_config_files" options.
This commit is contained in:
Marcus Stollsteimer 2016-07-06 14:30:30 +02:00
parent f6dc749332
commit 1c0f21230d
2 changed files with 13 additions and 0 deletions

View File

@ -101,6 +101,7 @@ module Jekyll
# Returns the final configuration Hash.
def configuration(override = {})
config = Configuration.new
override = Configuration[override].stringify_keys
unless override.delete("skip_config_files")
config = config.read_config_files(config.config_files(override))
end

View File

@ -334,6 +334,18 @@ class TestConfiguration < JekyllUnitTest
Jekyll.configuration(test_config.merge({ "config" => @paths[:other] }))
end
should "load different config if specified with symbol key" do
allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({})
allow(SafeYAML)
.to receive(:load_file)
.with(@paths[:other])
.and_return({ "baseurl" => "http://example.com" })
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}")
assert_equal \
site_configuration({ "baseurl" => "http://example.com" }),
Jekyll.configuration(test_config.merge({ :config => @paths[:other] }))
end
should "load default config if path passed is empty" do
allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({})
allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}")