From 275a1f4d5dc90cfa9f0a1894cdff11bc4ed580b6 Mon Sep 17 00:00:00 2001 From: ashmaroli Date: Sat, 17 Feb 2018 19:25:05 +0530 Subject: [PATCH] Add a cucumber feature to test link tag (#6777) Merge pull request 6777 --- features/link_tag.feature | 78 ++++++++++++++++++++++++++++++++++++ features/step_definitions.rb | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 features/link_tag.feature diff --git a/features/link_tag.feature b/features/link_tag.feature new file mode 100644 index 00000000..a94b8676 --- /dev/null +++ b/features/link_tag.feature @@ -0,0 +1,78 @@ +Feature: Link Tag + As a hacker who likes to write a variety of content + I want to be able to link to pages and documents + And render them without much hassle + + Scenario: Basic site with two pages + Given I have an "index.md" page that contains "[About my projects]({% link about.md %})" + And I have an "about.md" page that contains "[Home]({% link index.md %})" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "

About my projects

" in "_site/index.html" + And I should see "

Home

" in "_site/about.html" + + Scenario: Basic site with custom page-permalinks + Given I have an "index.md" page that contains "[About my projects]({% link about.md %})" + And I have an "about.md" page with permalink "/about/" that contains "[Home]({% link index.md %})" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "

About my projects

" in "_site/index.html" + And I should see "

Home

" in "_site/about/index.html" + + Scenario: Basic site with custom site-wide-permalinks + Given I have an "index.md" page that contains "[About my projects]({% link about.md %})" + And I have an "about.md" page that contains "[Home]({% link index.md %})" + And I have a configuration file with "permalink" set to "pretty" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "

About my projects

" in "_site/index.html" + And I should see "

Home

" in "_site/about/index.html" + + Scenario: Basic site with two pages and custom baseurl + Given I have an "index.md" page that contains "[About my projects]({% link about.md %})" + And I have an "about.md" page that contains "[Home]({% link index.md %})" + And I have a configuration file with "baseurl" set to "/blog" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "

About my projects

" in "_site/index.html" + And I should see "

Home

" in "_site/about.html" + + Scenario: Basic site with two pages and custom baseurl and permalinks + Given I have an "index.md" page that contains "[About my projects]({% link about.md %})" + And I have an "about.md" page that contains "[Home]({% link index.md %})" + And I have a "_config.yml" file with content: + """ + baseurl: /blog + permalink: pretty + """ + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "

About my projects

" in "_site/index.html" + And I should see "

Home

" in "_site/about/index.html" + + Scenario: Linking to a ghost file + Given I have an "index.md" page that contains "[About my projects]({% link about.md %})" + And I have an "about.md" page that contains "[Contact]({% link contact.md %})" + When I run jekyll build + Then I should get a non-zero exit status + And the _site directory should not exist + And I should see "Could not find document 'contact.md' in tag 'link'" in the build output + + Scenario: Complex site with a variety of files + Given I have an "index.md" page that contains "[About my projects]({% link about.md %})" + And I have an "about.md" page that contains "[Latest Hack]({% link _posts/2018-02-15-metaprogramming.md %})" + And I have a _posts directory + And I have an "_posts/2018-02-15-metaprogramming.md" page that contains "[Download This]({% link script.txt %})" + And I have a "script.txt" file that contains "Static Alert!" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "

About my projects

" in "_site/index.html" + And I should see "

Latest Hack

" in "_site/about.html" + And I should see "

Download This

" in "_site/2018/02/15/metaprogramming.html" + And I should see "Static Alert!" in "_site/script.txt" diff --git a/features/step_definitions.rb b/features/step_definitions.rb index 4bd023df..97b9ffaa 100644 --- a/features/step_definitions.rb +++ b/features/step_definitions.rb @@ -36,7 +36,7 @@ end Given(%r!^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$!) do |file, key, value, text| File.write(file, Jekyll::Utils.strip_heredoc(<<-DATA)) --- - #{key || "layout"}: #{value || "nil"} + #{key || "layout"}: #{value || "none"} --- #{text}