Properly handle nil image path
This commit is contained in:
parent
ddff9d7cc1
commit
1d9396dbd9
|
@ -38,3 +38,13 @@ Feature: Jekyll responsive_image_block tag
|
|||
"""
|
||||
When I run Jekyll
|
||||
Then I should see "<img alt=\"Lorem ipsum\" src=\"/assets/test.png\"" in "_site/index.html"
|
||||
|
||||
Scenario: Handling a nil path
|
||||
Given I have a responsive_image configuration with "template" set to "_includes/responsive-image.html"
|
||||
And I have a file "index.html" with:
|
||||
"""
|
||||
{% responsive_image_block %}
|
||||
path: {{ path }}
|
||||
{% endresponsive_image_block %}
|
||||
"""
|
||||
Then Jekyll should throw a "SyntaxError"
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
include Test::Unit::Assertions
|
||||
|
||||
When /^I run Jekyll$/ do
|
||||
run_jekyll
|
||||
end
|
||||
|
||||
Then /^Jekyll should throw a "(.+)"$/ do |error_class|
|
||||
assert_raise(Object.const_get(error_class)) { run_jekyll }
|
||||
end
|
||||
|
||||
Given /^I have a responsive_image configuration with:$/ do |config|
|
||||
write_file('_config.yml', "responsive_image:\n#{config}")
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ module Jekyll
|
|||
include ResponsiveImage::Utils
|
||||
|
||||
def process(image_path, config)
|
||||
raise SyntaxError.new('Invalid image path specified') unless File.exists?(image_path)
|
||||
raise SyntaxError.new('Invalid image path specified') unless File.exists?(image_path.to_s)
|
||||
|
||||
resize_handler = ResizeHandler.new
|
||||
img = Magick::Image::read(image_path).first
|
||||
|
|
Loading…
Reference in New Issue