Skip to content

Commit 47b06e7

Browse files
committed
Added a linter for Gherkin and updated features.
1 parent ebfed47 commit 47b06e7

19 files changed

+73
-70
lines changed

.ahoy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ commands:
110110
lint:
111111
usage: Lint code.
112112
cmd: |
113-
ahoy cli "cp -Rf phpcs.xml phpstan.neon phpmd.xml build > /dev/null" \
113+
ahoy cli "cp -Rf phpcs.xml phpstan.neon phpmd.xml gherkinlint.json build > /dev/null" \
114114
&& ahoy cli "cd /app/build && ./vendor/bin/phpcs" \
115115
&& ahoy cli "cd /app/build && ./vendor/bin/phpmd ../src text phpmd.xml" \
116116
&& ahoy cli "cd /app/build && ./vendor/bin/phpmd ../tests/behat/bootstrap text phpmd.xml" \
117117
&& ahoy cli "cd /app/build && ./vendor/bin/phpstan" \
118-
&& ahoy cli "cd /app/build && ./vendor/bin/rector process ../src --clear-cache --dry-run || true"
118+
&& ahoy cli "cd /app/build && ./vendor/bin/rector process ../src --clear-cache --dry-run" \
119+
&& ahoy cli "cd /app/build && ./vendor/bin/gherkinlint lint ../tests/behat/features"
119120
120121
lint-fix:
121122
usage: Fix code.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"drupal/drupal-extension": "^5"
2525
},
2626
"require-dev": {
27+
"dantleech/gherkin-lint": "^0.2.3",
2728
"dealerdirect/phpcodesniffer-composer-installer": "^1",
2829
"drevops/behat-screenshot": "^1.5",
2930
"drupal/coder": "^8.3",

gherkinlint.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"rules": {
3+
"indentation": {
4+
"width": 2,
5+
"literalBlock": 3
6+
},
7+
"keyword-order": {
8+
"enabled": false
9+
},
10+
"no-background-with-single-scenario": {
11+
"enabled": false
12+
},
13+
"no-homogenous-tags": {
14+
"enabled": false
15+
},
16+
"scenario-size": {
17+
"enabled": false
18+
}
19+
}
20+
}
File renamed without changes.

tests/behat/features/behatcli.steps.feature renamed to tests/behat/features/behatcli_steps.feature

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
@behatcli
22
Feature: Behat CLI context additional steps
33

4-
@trait:PathTrait
5-
Scenario: Test fails with exception
6-
Given some behat configuration
7-
And scenario steps:
8-
"""
9-
Given I go to the homepage
10-
Then I throw test exception with message "Intentional error"
11-
And I should be in the "nonexisting" path
12-
"""
13-
When I run "behat --no-colors"
14-
Then it should fail with an exception:
15-
"""
16-
Intentional error
17-
"""
18-
194
@trait:PathTrait
205
Scenario: Test fails with exception
216
Given some behat configuration

tests/behat/features/eck.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
@api
21
Feature: Check that EckTrait works for or D9
32

43
Background:
5-
Given I am logged in as a user with the "administrator" role
6-
74
Given no test_bundle test_entity_type entities:
85
| title |
96
| [TEST] ECK Entity |
@@ -16,17 +13,19 @@ Feature: Check that EckTrait works for or D9
1613

1714
@api
1815
Scenario: Assert "When I edit :bundle :entity_type with title :label"
16+
Given I am logged in as a user with the "administrator" role
1917
When I edit test_bundle test_entity_type with title "[TEST] ECK test1"
2018
Then I should see "Edit test bundle [TEST] ECK test1"
2119
And I visit test_bundle test_entity_type with title "[TEST] ECK test1"
2220
And I should see "[TEST] ECK test1"
2321
And I should see "T2"
2422

25-
@trait:EckTrait
23+
@api @trait:EckTrait
2624
Scenario: Assert navigate to entity type with specified bundle and title.
2725
Given some behat configuration
2826
And scenario steps tagged with "@api":
2927
"""
28+
Given I am logged in as a user with the "administrator" role
3029
When I visit "test_bundle" "test_entity_type" with title "[Test] Entity Custom"
3130
"""
3231
When I run "behat --no-colors"
@@ -35,11 +34,12 @@ Feature: Check that EckTrait works for or D9
3534
Unable to find test_entity_type page "[Test] Entity Custom"
3635
"""
3736

38-
@trait:EckTrait
37+
@api @trait:EckTrait
3938
Scenario: Assert edit to entity type with specified bundle and title.
4039
Given some behat configuration
4140
And scenario steps tagged with "@api":
4241
"""
42+
Given I am logged in as a user with the "administrator" role
4343
When I edit "test_bundle" "test_entity_type" with title "[Test] Entity Custom"
4444
"""
4545
When I run "behat --no-colors"

tests/behat/features/element.feature

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Feature: Check that ElementTrait works
2222
"""
2323

2424
@trait:ElementTrait
25-
Scenario: Assert that an element with selector and attribute with a value exists.
25+
Scenario: Negative assertion for "Then I should see the :selector element with the :attribute attribute set to :value" fails as expected when the attribute is not found
2626
Given some behat configuration
2727
And scenario steps:
2828
"""
@@ -37,7 +37,7 @@ Feature: Check that ElementTrait works
3737
"""
3838

3939
@trait:ElementTrait
40-
Scenario: Assert that an element with selector and attribute with a value exists.
40+
Scenario: Negative assertion for "Then I should see the :selector element with the :attribute attribute set to :value" fails as expected when the attribute value does not match
4141
Given some behat configuration
4242
And scenario steps:
4343
"""
@@ -51,18 +51,18 @@ Feature: Check that ElementTrait works
5151
The "dir" attribute was found on the element "html", but does not contain a value "not-match-value".
5252
"""
5353

54-
Scenario: Assert step definition "I( should) see the :selector element with a(n) :attribute attribute containing :value" works as expected
54+
Scenario: Assert step definition "I( should) see the :selector element with a(n) :attribute attribute containing :value" works as expected with a specific value
5555
Given I am an anonymous user
5656
When I visit "/"
5757
Then I should see the "html" element with a "dir" attribute containing "ltr"
5858

59-
Scenario: Assert step definition "I( should) see the :selector element with a(n) :attribute attribute containing :value" works as expected
59+
Scenario: Assert step definition "I( should) see the :selector element with a(n) :attribute attribute containing :value" works as expected with a wildcard
6060
Given I am an anonymous user
6161
When I visit "/"
6262
Then I should see the "html" element with a "dir" attribute containing "lt*"
6363

6464
@trait:ElementTrait
65-
Scenario: Assert that an element with selector and attribute with a value exists.
65+
Scenario: Negative assertion for "Then I should see the :selector element with a(n) :attribute attribute containing :value" fails as expected when the attribute is not found
6666
Given some behat configuration
6767
And scenario steps:
6868
"""
@@ -77,7 +77,7 @@ Feature: Check that ElementTrait works
7777
"""
7878

7979
@trait:ElementTrait
80-
Scenario: Assert that an element with selector and attribute with a value exists.
80+
Scenario: Negative assertion for "Then I should see the :selector element with a(n) :attribute attribute containing :value" fails as expected when the attribute value does not match
8181
Given some behat configuration
8282
And scenario steps:
8383
"""
@@ -92,7 +92,7 @@ Feature: Check that ElementTrait works
9292
"""
9393

9494
@trait:ElementTrait
95-
Scenario: Assert that an element with selector and attribute with a value exists.
95+
Scenario: Negative assertion for "Then I should see the :selector element with a(n) :attribute attribute containing :value" fails as expected when the attribute value does not match; alternative step definition
9696
Given some behat configuration
9797
And scenario steps:
9898
"""
@@ -106,18 +106,18 @@ Feature: Check that ElementTrait works
106106
No element with "dir" attribute matching the pattern "not-match-value" found.
107107
"""
108108

109-
Scenario: Assert that an element with selector contains text.
109+
Scenario: Assert that an element with selector contains text using css.
110110
Given I am an anonymous user
111111
When I visit "/"
112112
Then I should see an element ".site-branding__name" using "css" contains "Drush Site-Install" text
113113

114-
Scenario: Assert that an element with selector contains text.
114+
Scenario: Assert that an element with selector contains text using xpath.
115115
Given I am an anonymous user
116116
When I visit "/"
117117
Then I should see an element "//div[@class='site-branding__name']" using "xpath" contains "Drush Site-Install" text
118118

119119
@trait:ElementTrait
120-
Scenario: Assert that an element with selector contains text.
120+
Scenario: Negative assertion for "Then I should see an element :selector using :selector_type contains :text text" fails as expected when the selector type is invalid
121121
Given some behat configuration
122122
And scenario steps:
123123
"""
@@ -132,7 +132,7 @@ Feature: Check that ElementTrait works
132132
"""
133133

134134
@trait:ElementTrait
135-
Scenario: Assert that an element with selector contains text.
135+
Scenario: Negative assertion for "Then I should see an element :selector using :selector_type contains :text text" fails as expected when the selector is not found
136136
Given some behat configuration
137137
And scenario steps:
138138
"""
@@ -147,7 +147,7 @@ Feature: Check that ElementTrait works
147147
"""
148148

149149
@trait:ElementTrait
150-
Scenario: Assert that an element with selector contains text.
150+
Scenario: Negative assertion for "Then I should see an element :selector using :selector_type contains :text text" fails as expected when the text is not found
151151
Given some behat configuration
152152
And scenario steps:
153153
"""

tests/behat/features/email.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ Feature: Check that email assertions work for or D9
6363
And an email is sent to "[email protected]"
6464
And no emails were sent to "[email protected]"
6565
And an email header "Content-Type" contains:
66-
"""
67-
text/plain
68-
"""
66+
"""
67+
text/plain
68+
"""
6969
And an email header "X-Mailer" contains:
70-
"""
71-
Drupal
72-
"""
70+
"""
71+
Drupal
72+
"""
7373

7474
@api @email
7575
Scenario: As a developer, I want to know that test email system is activated

tests/behat/features/field.feature

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ Feature: Check that FieldTrait works
6060
Then color field "#edit-color-input" value is "#ffffff"
6161

6262
@api @javascript
63-
Scenario: Assert fills in form color field with specified id|name|label|value.
63+
Scenario: Assert fills in form color field with specified id|name|label|value using an alternate step definition.
6464
Given I visit "/sites/default/files/relative.html"
6565
Then color field "#edit-color-input" value is "#000000"
6666
And I fill color in "#ffffff" for "#edit-color-input"
6767
Then color field "#edit-color-input" value is "#ffffff"
6868

6969
@trait:FieldTrait
70-
Scenario: Assert that field exists on the page using id,name,label or value.
70+
Scenario: Assert that negative assertion for "I see field :field" fails with an error
7171
Given some behat configuration
7272
And scenario steps:
7373
"""
@@ -81,7 +81,7 @@ Feature: Check that FieldTrait works
8181
"""
8282

8383
@trait:FieldTrait
84-
Scenario: Assert that field does not exist on the page using id,name,label or value.
84+
Scenario: Assert that negative assertion for "I don't see field :field" fails with an error
8585
Given some behat configuration
8686
And scenario steps:
8787
"""
@@ -95,7 +95,7 @@ Feature: Check that FieldTrait works
9595
"""
9696

9797
@trait:FieldTrait
98-
Scenario: Assert that field does not exist on the page using id,name,label or value.
98+
Scenario: Assert that field does not exist on the page using id, name, label or value.
9999
Given some behat configuration
100100
And scenario steps:
101101
"""
@@ -123,7 +123,7 @@ Feature: Check that FieldTrait works
123123
"""
124124

125125
@trait:FieldTrait
126-
Scenario: Assert whether the field has a state.
126+
Scenario: Assert that negative assertion for "field :field1 is :state on the page" fails with an error
127127
Given some behat configuration
128128
And scenario steps:
129129
"""
@@ -137,7 +137,7 @@ Feature: Check that FieldTrait works
137137
"""
138138

139139
@trait:FieldTrait
140-
Scenario: Assert whether the field exists on the page and has a state.
140+
Scenario: Assert that negative assertion for "field :field should be :presence on the page and have state :state" fails with an error for existing field
141141
Given some behat configuration
142142
And scenario steps:
143143
"""
@@ -151,7 +151,7 @@ Feature: Check that FieldTrait works
151151
"""
152152

153153
@trait:FieldTrait
154-
Scenario: Assert whether the field exists on the page and has a state.
154+
Scenario: Assert that negative assertion for "field :field should be :presence on the page and have state :state" fails with an error for non-existing field
155155
Given some behat configuration
156156
And scenario steps:
157157
"""

tests/behat/features/file.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Feature: Check that FileTrait works for or D9
140140
"""
141141

142142
@trait:FileTrait
143-
Scenario: Assert that negative assertions fail with an error
143+
Scenario: Assert that negative assertion for "Given unmanaged file :uri does not exist" fails with an error
144144
Given some behat configuration
145145
And scenario steps:
146146
"""
@@ -154,7 +154,7 @@ Feature: Check that FileTrait works for or D9
154154
"""
155155

156156
@trait:FileTrait
157-
Scenario: Assert that negative assertions fail with an error
157+
Scenario: Assert that negative assertion for "Given unmanaged file :uri has content :content" fails with an error
158158
Given some behat configuration
159159
And scenario steps:
160160
"""
@@ -169,7 +169,7 @@ Feature: Check that FileTrait works for or D9
169169
"""
170170

171171
@trait:FileTrait
172-
Scenario: Assert that negative assertions fail with an error
172+
Scenario: Assert that negative assertion for "Given unmanaged file :uri does not have content :content" fails with an error
173173
Given some behat configuration
174174
And scenario steps:
175175
"""

0 commit comments

Comments
 (0)