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:
parent
f6dc749332
commit
1c0f21230d
|
@ -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
|
||||
|
|
|
@ -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]}")
|
||||
|
|
Loading…
Reference in New Issue