Usability: Don't raise an exception when config is missing or invalid
This commit is contained in:
parent
b76e2d3365
commit
c559bcced3
|
@ -0,0 +1,12 @@
|
|||
Feature: General plugin usage
|
||||
Scenario: No config at all
|
||||
Given I have no configuration
|
||||
When I run Jekyll
|
||||
Then there should be no errors
|
||||
|
||||
Scenario: Config with empty responsive_image block
|
||||
Given I have a responsive_image configuration with:
|
||||
"""
|
||||
"""
|
||||
When I run Jekyll
|
||||
Then there should be no errors
|
|
@ -6,6 +6,10 @@ Then /^Jekyll should throw a "(.+)"$/ do |error_class|
|
|||
assert_raise(Object.const_get(error_class)) { run_jekyll }
|
||||
end
|
||||
|
||||
Then /^there should be no errors$/ do
|
||||
# Implicit pass
|
||||
end
|
||||
|
||||
Given /^I have copied my site to "(.+)"$/ do |path|
|
||||
new_site_dir = File.join(TEST_DIR, path)
|
||||
|
||||
|
@ -16,6 +20,10 @@ Given /^I have copied my site to "(.+)"$/ do |path|
|
|||
.each { |f| FileUtils.mv(f, new_site_dir) }
|
||||
end
|
||||
|
||||
Given /^I have no configuration$/ do
|
||||
write_file('_config.yml', '')
|
||||
end
|
||||
|
||||
Given /^I have a configuration with:$/ do |config|
|
||||
write_file('_config.yml', config)
|
||||
end
|
||||
|
|
|
@ -17,8 +17,19 @@ module Jekyll
|
|||
@site = site
|
||||
end
|
||||
|
||||
def valid_config(config)
|
||||
config.has_key?('responsive_image') && config['responsive_image'].is_a?(Hash)
|
||||
end
|
||||
|
||||
def to_h
|
||||
DEFAULTS.merge(@site.config['responsive_image'])
|
||||
config = {}
|
||||
|
||||
if valid_config(@site.config)
|
||||
config = @site.config['responsive_image']
|
||||
end
|
||||
|
||||
|
||||
DEFAULTS.merge(config)
|
||||
.merge(site_source: @site.source, site_dest: @site.dest)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module Jekyll
|
||||
module ResponsiveImage
|
||||
VERSION = '1.5.1'.freeze
|
||||
VERSION = '1.5.2'.freeze
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue