diff --git a/features/plugin.feature b/features/plugin.feature new file mode 100644 index 0000000..7b7b925 --- /dev/null +++ b/features/plugin.feature @@ -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 diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 0780605..2ae0de4 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -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 diff --git a/lib/jekyll-responsive-image/config.rb b/lib/jekyll-responsive-image/config.rb index 3880abd..aefcc2a 100644 --- a/lib/jekyll-responsive-image/config.rb +++ b/lib/jekyll-responsive-image/config.rb @@ -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 diff --git a/lib/jekyll-responsive-image/version.rb b/lib/jekyll-responsive-image/version.rb index 86c693c..b71d6b2 100644 --- a/lib/jekyll-responsive-image/version.rb +++ b/lib/jekyll-responsive-image/version.rb @@ -1,5 +1,5 @@ module Jekyll module ResponsiveImage - VERSION = '1.5.1'.freeze + VERSION = '1.5.2'.freeze end end