File: theme_data_reader.feature

package info (click to toggle)
ruby-jekyll-data 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 420 kB
  • sloc: ruby: 909; sh: 95; makefile: 10
file content (114 lines) | stat: -rw-r--r-- 4,079 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Feature: Reading Data files in Gem-based Themes
  As a hacker who likes to share my expertise
  I want to be able to include data files in my gemified theme
  In order to supplement the templates with default text-strings

  Scenario: A site not using a gem-based theme
    Given I have a configuration file with:
      | key           | value                           |
      | exclude       | [Gemfile, Gemfile.lock]         |
    And I have a Gemfile with plugin:
      | name          | path                            |
      | test-plugin   | ../../test/fixtures/test-plugin |
    When I run bundle exec jekyll build
    Then I should get a zero exit status
    And the _site directory should exist
    And the "_site/test-feed.xml" file should exist

  Scenario: Theme-gem has a data file to support i18n
    Given I have a configuration file with:
      | key           | value                           |
      | lang          | fr                              |
      | theme         | test-theme                      |
      | gems          | [jekyll-data]                   |
      | exclude       | [Gemfile, Gemfile.lock]         |
    And I have a "locales.md" file with content:
      """
      ---
      ---

      {% assign ui = site.data.locales[site.lang] %}
      {% assign user = "John Smith" %}

      {{ ui.greeting }} {{ user }}

      {{ ui.prev }}

      {{ ui.next }}
      """
    And I have a valid Gemfile
    When I run bundle exec jekyll build
    Then I should get a zero exit status
    And the _site directory should exist
    And I should see "Bonjour, Bienvenue! John Smith" in "_site/locales.html"
    And I should see "précédent" in "_site/locales.html"
    And I should see "prochain" in "_site/locales.html"

  Scenario: Overriding a data file within theme-gem - Method I
    Given I have a configuration file with:
      | key           | value                           |
      | lang          | fr                              |
      | theme         | test-theme                      |
      | gems          | [jekyll-data]                   |
      | exclude       | [Gemfile, Gemfile.lock]         |
    And I have a "locales.md" file with content:
      """
      ---
      ---

      {% assign ui = site.data.locales[site.lang] %}
      {% assign user = "John Smith" %}

      {{ ui.greeting }} {{ user }}!

      {{ ui.prev }}

      {{ ui.next }}
      """
    And I have a _data directory
    And I have a "_data/locales.yml" file with content:
      """
      fr:
        greeting: "Bonjour! Bienvenue"
      """
    And I have a valid Gemfile
    When I run bundle exec jekyll build
    Then I should get a zero exit status
    And the _site directory should exist
    And I should see "Bonjour! Bienvenue John Smith!" in "_site/locales.html"
    And I should see "précédent" in "_site/locales.html"
    And I should see "prochain" in "_site/locales.html"

  Scenario: Overriding a data file within theme-gem - Method II
    Given I have a configuration file with:
      | key           | value                           |
      | lang          | fr                              |
      | theme         | test-theme                      |
      | gems          | [jekyll-data]                   |
      | exclude       | [Gemfile, Gemfile.lock]         |
    And I have a "locales.md" file with content:
      """
      ---
      ---

      {% assign ui = site.data.locales[site.lang] %}
      {% assign user = "John Smith" %}

      {{ ui.greeting }} {{ user }}!

      {{ ui.prev }}

      {{ ui.next }}
      """
    And I have a _data/locales directory
    And I have a "_data/locales/fr.yml" file with content:
      """
      greeting: "Bonjour! Bienvenue"
      """
    And I have a valid Gemfile
    When I run bundle exec jekyll build
    Then I should get a zero exit status
    And the _site directory should exist
    And I should see "Bonjour! Bienvenue John Smith!" in "_site/locales.html"
    And I should see "précédent" in "_site/locales.html"
    And I should see "prochain" in "_site/locales.html"