File: data.feature

package info (click to toggle)
jekyll 3.9.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,604 kB
  • sloc: ruby: 15,325; javascript: 1,455; sh: 214; xml: 29; makefile: 7
file content (133 lines) | stat: -rw-r--r-- 4,928 bytes parent folder | download | duplicates (4)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Feature: Data
  In order to use well-formatted data in my blog
  As a blog's user
  I want to use _data directory in my site

  Scenario: autoload *.yaml files in _data directory
    Given I have a _data directory
    And I have a "_data/products.yaml" file with content:
      """
      - name: sugar
        price: 5.3
      - name: salt
        price: 2.5
      """
    And I have an "index.html" page that contains "{% for product in site.data.products %}{{product.name}}{% endfor %}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "sugar" in "_site/index.html"
    And I should see "salt" in "_site/index.html"

  Scenario: autoload *.yml files in _data directory
    Given I have a _data directory
    And I have a "_data/members.yml" file with content:
      """
      - name: Jack
        age: 28
      - name: Leon
        age: 34
      """
    And I have an "index.html" page that contains "{% for member in site.data.members %}{{member.name}}{% endfor %}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Jack" in "_site/index.html"
    And I should see "Leon" in "_site/index.html"

  Scenario: autoload *.json files in _data directory
    Given I have a _data directory
    And I have a "_data/members.json" file with content:
      """
      [{"name": "Jack", "age": 28},{"name": "Leon", "age": 34}]
      """
    And I have an "index.html" page that contains "{% for member in site.data.members %}{{member.name}}{% endfor %}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Jack" in "_site/index.html"
    And I should see "Leon" in "_site/index.html"

  Scenario: autoload *.csv files in _data directory
    Given I have a _data directory
    And I have a "_data/members.csv" file with content:
      """
      name,age
      Jack,28
      Leon,34
      """
    And I have an "index.html" page that contains "{% for member in site.data.members %}{{member.name}}{% endfor %}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Jack" in "_site/index.html"
    And I should see "Leon" in "_site/index.html"

  Scenario: autoload *.tsv files in _data directory
    Given I have a _data directory
    And I have a "_data/members.tsv" file with content:
      """
      name	age
      Jack	28
      Leon	34
      """
    And I have an "index.html" page that contains "{% for member in site.data.members %}{{member.name}}{% endfor %}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Jack" in "_site/index.html"
    And I should see "Leon" in "_site/index.html"

  Scenario: autoload *.yml files in _data directory with space in file name
    Given I have a _data directory
    And I have a "_data/team members.yml" file with content:
      """
      - name: Jack
        age: 28
      - name: Leon
        age: 34
      """
    And I have an "index.html" page that contains "{% for member in site.data.team_members %}{{member.name}}{% endfor %}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Jack" in "_site/index.html"
    And I should see "Leon" in "_site/index.html"

  Scenario: autoload *.yaml files in subdirectories in _data directory
    Given I have a _data directory
    And I have a _data/categories directory
    And I have a "_data/categories/dairy.yaml" file with content:
      """
      name: Dairy Products
      """
    And I have an "index.html" page that contains "{{ site.data.categories.dairy.name }}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Dairy Products" in "_site/index.html"

  Scenario: folders should have precedence over files with the same name
    Given I have a _data directory
    And I have a _data/categories directory
    And I have a "_data/categories/dairy.yaml" file with content:
      """
      name: Dairy Products
      """
    And I have a "_data/categories.yaml" file with content:
      """
      dairy:
        name: Should not display this
      """
    And I have an "index.html" page that contains "{{ site.data.categories.dairy.name }}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Dairy Products" in "_site/index.html"

  Scenario: should be backward compatible with site.data in _config.yml
    Given I have a "_config.yml" file with content:
      """
      data:
        - name: Jack
          age: 28
        - name: Leon
          age: 34
      """
    And I have an "index.html" page that contains "{% for member in site.data %}{{member.name}}{% endfor %}"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "Jack" in "_site/index.html"
    And I should see "Leon" in "_site/index.html"