jekyll-responsive-image/features/responsive-image-block.feature

67 lines
2.5 KiB
Gherkin
Raw Normal View History

2014-12-08 00:06:28 +11:00
Feature: Jekyll responsive_image_block tag
As a Jekyll template developer
I want to include Liquid variables when rendering my responsive images
In order to dynamically generate my responsive images
Scenario: Simple image tag
2014-12-08 00:14:40 +11:00
Given I have a responsive_image configuration with "template" set to "_includes/responsive-image.html"
2014-12-08 00:06:28 +11:00
And I have a file "index.html" with:
"""
{% assign path = 'assets/everybody-loves-jalapeño-pineapple-cornbread.png' %}
2014-12-08 00:06:28 +11:00
{% assign alt = 'Lorem ipsum' %}
{% responsive_image_block %}
path: {{ path }}
title: Magic rainbow adventure!
alt: {{ alt }}
{% endresponsive_image_block %}
"""
When I run Jekyll
Then I should see "<img alt=\"Lorem ipsum\" src=\"/assets/everybody-loves-jalapeño-pineapple-cornbread.png\" title=\"Magic rainbow adventure!\"" in "_site/index.html"
2014-12-08 00:06:28 +11:00
2015-11-05 20:18:53 +11:00
Scenario: Global variables available in templates
Given I have a file "index.html" with:
"""
{% responsive_image_block %}
path: assets/everybody-loves-jalapeño-pineapple-cornbread.png
2015-11-05 20:18:53 +11:00
{% endresponsive_image_block %}
"""
And I have a configuration with:
"""
baseurl: https://wildlyinaccurate.com
responsive_image:
template: _includes/base-url.html
"""
When I run Jekyll
Then I should see "<img src=\"https://wildlyinaccurate.com/assets/everybody-loves-jalapeño-pineapple-cornbread.png\">" in "_site/index.html"
2015-11-05 20:18:53 +11:00
2014-12-08 00:06:28 +11:00
Scenario: More complex logic in the block tag
2014-12-08 00:14:40 +11:00
Given I have a responsive_image configuration with "template" set to "_includes/responsive-image.html"
2014-12-08 00:06:28 +11:00
And I have a file "index.html" with:
"""
{% assign path = 'assets/everybody-loves-jalapeño-pineapple-cornbread.png' %}
2014-12-08 00:06:28 +11:00
{% assign alt = 'Lorem ipsum' %}
{% responsive_image_block %}
path: {{ path }}
{% if another_alt %}
alt: {{ another_alt }}
{% else %}
alt: {{ alt }}
{% endif %}
{% endresponsive_image_block %}
"""
When I run Jekyll
Then I should see "<img alt=\"Lorem ipsum\" src=\"/assets/everybody-loves-jalapeño-pineapple-cornbread.png\"" in "_site/index.html"
2014-12-08 09:33:14 +11:00
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"