gherkin_lint 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -0
- data/.travis.yml +4 -0
- data/Gemfile +9 -0
- data/Guardfile +3 -0
- data/LICENSE +22 -0
- data/README.md +644 -0
- data/Rakefile +40 -0
- data/bin/gherkin_lint +1 -1
- data/features/avoid_outline_for_single_example.feature +56 -0
- data/features/avoid_period.feature +49 -0
- data/features/background_does_more_than_setup.feature +46 -0
- data/features/background_requires_scenario.feature +57 -0
- data/features/bad_scenario_name.feature +53 -0
- data/features/file_name_differs_feature_name.feature +47 -0
- data/features/invalid_file_name.feature +51 -0
- data/features/invalid_step_flow.feature +85 -0
- data/features/missing_example_name.feature +63 -0
- data/features/missing_feature_description.feature +44 -0
- data/features/missing_feature_name.feature +41 -0
- data/features/missing_scenario_name.feature +57 -0
- data/features/missing_test_action.feature +48 -0
- data/features/missing_verification.feature +48 -0
- data/features/same_tag_for_all_scenarios.feature +77 -0
- data/features/support/env.rb +5 -0
- data/features/too_clumsy.feature +57 -0
- data/features/too_long_step.feature +47 -0
- data/features/too_many_different_tags.feature +63 -0
- data/features/too_many_steps.feature +57 -0
- data/features/too_many_tags.feature +47 -0
- data/features/unique_scenario_names.feature +46 -0
- data/features/unknown_variable.feature +102 -0
- data/features/unused_variable.feature +102 -0
- data/features/use_background.feature +109 -0
- data/features/use_outline.feature +62 -0
- data/gherkin_lint.gemspec +15 -0
- data/lib/gherkin_lint.rb +98 -742
- data/lib/gherkin_lint/issue.rb +22 -0
- data/lib/gherkin_lint/linter.rb +117 -0
- data/lib/gherkin_lint/linter/avoid_outline_for_single_example.rb +19 -0
- data/lib/gherkin_lint/linter/avoid_period.rb +17 -0
- data/lib/gherkin_lint/linter/background_does_more_than_setup.rb +16 -0
- data/lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb +16 -0
- data/lib/gherkin_lint/linter/bad_scenario_name.rb +18 -0
- data/lib/gherkin_lint/linter/file_name_differs_feature_name.rb +21 -0
- data/lib/gherkin_lint/linter/invalid_file_name.rb +15 -0
- data/lib/gherkin_lint/linter/invalid_step_flow.rb +38 -0
- data/lib/gherkin_lint/linter/missing_example_name.rb +18 -0
- data/lib/gherkin_lint/linter/missing_feature_description.rb +15 -0
- data/lib/gherkin_lint/linter/missing_feature_name.rb +15 -0
- data/lib/gherkin_lint/linter/missing_scenario_name.rb +15 -0
- data/lib/gherkin_lint/linter/missing_test_action.rb +15 -0
- data/lib/gherkin_lint/linter/missing_verification.rb +15 -0
- data/lib/gherkin_lint/linter/same_tag_for_all_scenarios.rb +32 -0
- data/lib/gherkin_lint/linter/too_clumsy.rb +15 -0
- data/lib/gherkin_lint/linter/too_long_step.rb +14 -0
- data/lib/gherkin_lint/linter/too_many_different_tags.rb +38 -0
- data/lib/gherkin_lint/linter/too_many_steps.rb +14 -0
- data/lib/gherkin_lint/linter/too_many_tags.rb +15 -0
- data/lib/gherkin_lint/linter/unique_scenario_names.rb +19 -0
- data/lib/gherkin_lint/linter/unknown_variable.rb +42 -0
- data/lib/gherkin_lint/linter/unused_variable.rb +42 -0
- data/lib/gherkin_lint/linter/use_background.rb +70 -0
- data/lib/gherkin_lint/linter/use_outline.rb +47 -0
- metadata +63 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e189dc06dc67de9babbb162719f6a6076e7fdca
|
|
4
|
+
data.tar.gz: 67b05bc5a362173d4224a851a2bf9e4fb7dd0717
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c26e21bf005148159ce63c68f66528bd4778727cc78fad916ff05af61229fba638b108ddaa0c88f5c2fab7313e25f262ea95d04a7b01d15f138977d0707b91b8
|
|
7
|
+
data.tar.gz: e995a0d94ee6ad6199ea24461c89f53c4f2dea05b640bc2da542a227c949f8fce361cd743bcf07045ffd06834d0f786dafcec82bd65ad48e5bc248513edd0487
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
|
2
|
+
# on 2015-07-05 00:19:49 +0200 using RuboCop version 0.31.0.
|
|
3
|
+
# The point is for the user to remove these configuration records
|
|
4
|
+
# one by one as the offenses are removed from the code base.
|
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
7
|
+
|
|
8
|
+
# Offense count: 16
|
|
9
|
+
# Configuration parameters: AllowURI, URISchemes.
|
|
10
|
+
Metrics/LineLength:
|
|
11
|
+
Max: 118
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Funkwerk AG
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
# Lint Gherkin Files
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/funkwerk/gherkin_lint)
|
|
4
|
+
|
|
5
|
+
This tool lints gherkin files.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
run `gherkin_lint` on a list of files
|
|
10
|
+
|
|
11
|
+
gherkin_lint FEATURE_FILES
|
|
12
|
+
|
|
13
|
+
## Checks
|
|
14
|
+
|
|
15
|
+
### Feature Avoid colon (features/avoid_colon.feature)
|
|
16
|
+
As a Business Analyst
|
|
17
|
+
I do not want colons at the end of my user stories
|
|
18
|
+
#### Background:
|
|
19
|
+
Given a file named "lint.rb" with:
|
|
20
|
+
"""
|
|
21
|
+
$LOAD_PATH << '../../lib'
|
|
22
|
+
require 'gherkin_lint'
|
|
23
|
+
linter = GherkinLint.new
|
|
24
|
+
linter.enable %w(AvoidColon)
|
|
25
|
+
linter.analyze 'lint.feature'
|
|
26
|
+
exit linter.report
|
|
27
|
+
"""
|
|
28
|
+
#### Scenario: Warns for colon
|
|
29
|
+
Given a file named "lint.feature" with:
|
|
30
|
+
"""
|
|
31
|
+
Feature: Test
|
|
32
|
+
Scenario: A
|
|
33
|
+
Given setup
|
|
34
|
+
When test
|
|
35
|
+
Then verification.
|
|
36
|
+
"""
|
|
37
|
+
When I run `ruby lint.rb`
|
|
38
|
+
Then it should fail with exactly:
|
|
39
|
+
"""
|
|
40
|
+
AvoidColon
|
|
41
|
+
lint.feature (5): Test.A step: verification.
|
|
42
|
+
"""
|
|
43
|
+
#### Scenario: Passes for Test
|
|
44
|
+
Given a file named "lint.feature" with:
|
|
45
|
+
"""
|
|
46
|
+
Feature: Test
|
|
47
|
+
Scenario: A
|
|
48
|
+
Given setup
|
|
49
|
+
When test
|
|
50
|
+
Then verification
|
|
51
|
+
"""
|
|
52
|
+
When I run `ruby lint.rb`
|
|
53
|
+
Then it should pass with exactly:
|
|
54
|
+
"""
|
|
55
|
+
"""
|
|
56
|
+
### Feature Background does more than setup (features/background_does_more_than_setup.feature)
|
|
57
|
+
As a Business Analyst
|
|
58
|
+
I want to be warned if there is more than setup in background
|
|
59
|
+
so that tests stay understandable
|
|
60
|
+
#### Background:
|
|
61
|
+
Given a file named "lint.rb" with:
|
|
62
|
+
"""
|
|
63
|
+
$LOAD_PATH << '../../lib'
|
|
64
|
+
require 'gherkin_lint'
|
|
65
|
+
linter = GherkinLint.new
|
|
66
|
+
linter.enable %w(BackgroundDoesMoreThanSetup)
|
|
67
|
+
linter.analyze 'lint.feature'
|
|
68
|
+
exit linter.report
|
|
69
|
+
"""
|
|
70
|
+
#### Scenario: Warns for missing verification
|
|
71
|
+
Given a file named "lint.feature" with:
|
|
72
|
+
"""
|
|
73
|
+
Feature: Test
|
|
74
|
+
Background: Preparation
|
|
75
|
+
Given setup
|
|
76
|
+
When test
|
|
77
|
+
"""
|
|
78
|
+
When I run `ruby lint.rb`
|
|
79
|
+
Then it should fail with exactly:
|
|
80
|
+
"""
|
|
81
|
+
BackgroundDoesMoreThanSetup - Just Given Steps allowed
|
|
82
|
+
lint.feature (4): Test.Preparation step: test
|
|
83
|
+
"""
|
|
84
|
+
#### Scenario: Passes for valid feature
|
|
85
|
+
Given a file named "lint.feature" with:
|
|
86
|
+
"""
|
|
87
|
+
Feature: Test
|
|
88
|
+
Background: Preparation
|
|
89
|
+
Given setup
|
|
90
|
+
"""
|
|
91
|
+
When I run `ruby lint.rb`
|
|
92
|
+
Then it should pass with exactly:
|
|
93
|
+
"""
|
|
94
|
+
"""
|
|
95
|
+
### Feature Invalid File Name (features/invalid_file_name.feature)
|
|
96
|
+
As a Business Analyst
|
|
97
|
+
I want to be warned about invalid file named
|
|
98
|
+
so that I name all features consistently
|
|
99
|
+
#### Background:
|
|
100
|
+
Given a file named "lint.rb" with:
|
|
101
|
+
"""
|
|
102
|
+
$LOAD_PATH << '../../lib'
|
|
103
|
+
require 'gherkin_lint'
|
|
104
|
+
require 'optparse'
|
|
105
|
+
options = {}
|
|
106
|
+
OptionParser.new { |opts| }.parse!
|
|
107
|
+
linter = GherkinLint.new
|
|
108
|
+
linter.enable %w(InvalidFileName)
|
|
109
|
+
ARGV.each { |file| linter.analyze file }
|
|
110
|
+
exit linter.report
|
|
111
|
+
"""
|
|
112
|
+
#### Scenario Outline: Warns for "verification" within scenario name
|
|
113
|
+
Given a file named "<invalid name>.feature" with:
|
|
114
|
+
"""
|
|
115
|
+
Feature: Test
|
|
116
|
+
"""
|
|
117
|
+
When I run `ruby lint.rb <invalid name>.feature`
|
|
118
|
+
Then it should fail with exactly:
|
|
119
|
+
"""
|
|
120
|
+
InvalidFileName - Feature files should be snake_cased
|
|
121
|
+
<invalid name>.feature
|
|
122
|
+
"""
|
|
123
|
+
##### Examples: Invalid Names
|
|
124
|
+
| invalid name |
|
|
125
|
+
| Lint |
|
|
126
|
+
| lintMe |
|
|
127
|
+
#### Scenario: Passes for unique scenario names
|
|
128
|
+
Given a file named "lint.feature" with:
|
|
129
|
+
"""
|
|
130
|
+
Feature: Test
|
|
131
|
+
"""
|
|
132
|
+
When I run `ruby lint.rb lint.feature`
|
|
133
|
+
Then it should pass with exactly:
|
|
134
|
+
"""
|
|
135
|
+
"""
|
|
136
|
+
### Feature Invalid Scenario Name (features/invalid_scenario_name.feature)
|
|
137
|
+
As a Business Analyst
|
|
138
|
+
I want to be warned about invalid scenario names
|
|
139
|
+
so that I am able to look for better naming
|
|
140
|
+
#### Background:
|
|
141
|
+
Given a file named "lint.rb" with:
|
|
142
|
+
"""
|
|
143
|
+
$LOAD_PATH << '../../lib'
|
|
144
|
+
require 'gherkin_lint'
|
|
145
|
+
linter = GherkinLint.new
|
|
146
|
+
linter.enable %w(InvalidScenarioName)
|
|
147
|
+
linter.analyze 'lint.feature'
|
|
148
|
+
exit linter.report
|
|
149
|
+
"""
|
|
150
|
+
#### Scenario Outline: Warns for "verification" within scenario name
|
|
151
|
+
Given a file named "lint.feature" with:
|
|
152
|
+
"""
|
|
153
|
+
Feature: Test
|
|
154
|
+
Scenario: <bad word> something
|
|
155
|
+
"""
|
|
156
|
+
When I run `ruby lint.rb`
|
|
157
|
+
Then it should fail with exactly:
|
|
158
|
+
"""
|
|
159
|
+
InvalidScenarioName - Prefer to rely just on Given and When steps when name your scenario to keep it stable
|
|
160
|
+
lint.feature (2): Test.<bad word> something
|
|
161
|
+
"""
|
|
162
|
+
##### Examples: bad words
|
|
163
|
+
| bad word |
|
|
164
|
+
| Verifies |
|
|
165
|
+
| Verification |
|
|
166
|
+
| Verify |
|
|
167
|
+
| Checks |
|
|
168
|
+
| Check |
|
|
169
|
+
| Tests |
|
|
170
|
+
| Test |
|
|
171
|
+
#### Scenario: Passes for unique scenario names
|
|
172
|
+
Given a file named "lint.feature" with:
|
|
173
|
+
"""
|
|
174
|
+
Feature: Unique Scenario Names
|
|
175
|
+
Scenario: A
|
|
176
|
+
"""
|
|
177
|
+
When I run `ruby lint.rb`
|
|
178
|
+
Then it should pass with exactly:
|
|
179
|
+
"""
|
|
180
|
+
"""
|
|
181
|
+
### Feature Invalid Step Flow (features/invalid_step_flow.feature)
|
|
182
|
+
As a Business Analyst
|
|
183
|
+
I want to be warned about invalid step flow
|
|
184
|
+
so that all my tests make sense
|
|
185
|
+
#### Background:
|
|
186
|
+
Given a file named "lint.rb" with:
|
|
187
|
+
"""
|
|
188
|
+
$LOAD_PATH << '../../lib'
|
|
189
|
+
require 'gherkin_lint'
|
|
190
|
+
linter = GherkinLint.new
|
|
191
|
+
linter.enable %w(InvalidStepFlow)
|
|
192
|
+
linter.analyze 'lint.feature'
|
|
193
|
+
exit linter.report
|
|
194
|
+
"""
|
|
195
|
+
#### Scenario: Verification before Action
|
|
196
|
+
Given a file named "lint.feature" with:
|
|
197
|
+
"""
|
|
198
|
+
Feature: Test
|
|
199
|
+
Scenario: A
|
|
200
|
+
Given setup
|
|
201
|
+
Then verify
|
|
202
|
+
"""
|
|
203
|
+
When I run `ruby lint.rb`
|
|
204
|
+
Then it should fail with exactly:
|
|
205
|
+
"""
|
|
206
|
+
InvalidStepFlow - Verification before action
|
|
207
|
+
lint.feature (4): Test.A step: verify
|
|
208
|
+
"""
|
|
209
|
+
#### Scenario: Setup after Action
|
|
210
|
+
Given a file named "lint.feature" with:
|
|
211
|
+
"""
|
|
212
|
+
Feature: Test
|
|
213
|
+
Scenario: A
|
|
214
|
+
When test
|
|
215
|
+
Given setup
|
|
216
|
+
Then verify
|
|
217
|
+
"""
|
|
218
|
+
When I run `ruby lint.rb`
|
|
219
|
+
Then it should fail with exactly:
|
|
220
|
+
"""
|
|
221
|
+
InvalidStepFlow - Given after Action or Verification
|
|
222
|
+
lint.feature (4): Test.A step: setup
|
|
223
|
+
"""
|
|
224
|
+
#### Scenario: Action as last step
|
|
225
|
+
Given a file named "lint.feature" with:
|
|
226
|
+
"""
|
|
227
|
+
Feature: Test
|
|
228
|
+
Scenario: A
|
|
229
|
+
Given setup
|
|
230
|
+
When test
|
|
231
|
+
Then verify
|
|
232
|
+
When test
|
|
233
|
+
"""
|
|
234
|
+
When I run `ruby lint.rb`
|
|
235
|
+
Then it should fail with exactly:
|
|
236
|
+
"""
|
|
237
|
+
InvalidStepFlow - Last step is an action
|
|
238
|
+
lint.feature (6): Test.A step: test
|
|
239
|
+
"""
|
|
240
|
+
#### Scenario: Passes for Test
|
|
241
|
+
Given a file named "lint.feature" with:
|
|
242
|
+
"""
|
|
243
|
+
Feature: Test
|
|
244
|
+
Scenario: A
|
|
245
|
+
Given setup
|
|
246
|
+
When test
|
|
247
|
+
Then verification
|
|
248
|
+
When test
|
|
249
|
+
Then verification
|
|
250
|
+
"""
|
|
251
|
+
When I run `ruby lint.rb`
|
|
252
|
+
Then it should pass with exactly:
|
|
253
|
+
"""
|
|
254
|
+
"""
|
|
255
|
+
### Feature Missing Example Name (features/missing_example_name.feature)
|
|
256
|
+
As a Customer
|
|
257
|
+
I want examples to be named
|
|
258
|
+
so that I'm able to understand why this example exists
|
|
259
|
+
#### Background:
|
|
260
|
+
Given a file named "lint.rb" with:
|
|
261
|
+
"""
|
|
262
|
+
$LOAD_PATH << '../../lib'
|
|
263
|
+
require 'gherkin_lint'
|
|
264
|
+
linter = GherkinLint.new
|
|
265
|
+
linter.enable %w(MissingExampleName)
|
|
266
|
+
linter.analyze 'lint.feature'
|
|
267
|
+
exit linter.report
|
|
268
|
+
"""
|
|
269
|
+
#### Scenario: Warns for missing example name
|
|
270
|
+
Given a file named "lint.feature" with:
|
|
271
|
+
"""
|
|
272
|
+
Feature: Test
|
|
273
|
+
Scenario Outline: A
|
|
274
|
+
When test
|
|
275
|
+
Then <value>
|
|
276
|
+
Examples:
|
|
277
|
+
| value |
|
|
278
|
+
| test |
|
|
279
|
+
"""
|
|
280
|
+
When I run `ruby lint.rb`
|
|
281
|
+
Then it should fail with exactly:
|
|
282
|
+
"""
|
|
283
|
+
MissingExampleName - No Example Name
|
|
284
|
+
lint.feature (2): Test.A
|
|
285
|
+
"""
|
|
286
|
+
#### Scenario: Passes for valid feature
|
|
287
|
+
Given a file named "lint.feature" with:
|
|
288
|
+
"""
|
|
289
|
+
Feature: Test
|
|
290
|
+
Scenario Outline: A
|
|
291
|
+
When test
|
|
292
|
+
Then <value>
|
|
293
|
+
Examples: Table
|
|
294
|
+
| value |
|
|
295
|
+
| test |
|
|
296
|
+
"""
|
|
297
|
+
When I run `ruby lint.rb`
|
|
298
|
+
Then it should pass with exactly:
|
|
299
|
+
"""
|
|
300
|
+
"""
|
|
301
|
+
### Feature Missing Feature Description (features/missing_feature_description.feature)
|
|
302
|
+
As a Customer
|
|
303
|
+
I want feature descriptions
|
|
304
|
+
so that I know why the features exist
|
|
305
|
+
#### Background:
|
|
306
|
+
Given a file named "lint.rb" with:
|
|
307
|
+
"""
|
|
308
|
+
$LOAD_PATH << '../../lib'
|
|
309
|
+
require 'gherkin_lint'
|
|
310
|
+
linter = GherkinLint.new
|
|
311
|
+
linter.enable %w(MissingFeatureDescription)
|
|
312
|
+
linter.analyze 'lint.feature'
|
|
313
|
+
exit linter.report
|
|
314
|
+
"""
|
|
315
|
+
#### Scenario: Warns for missing feature name
|
|
316
|
+
Given a file named "lint.feature" with:
|
|
317
|
+
"""
|
|
318
|
+
Feature: Test
|
|
319
|
+
"""
|
|
320
|
+
When I run `ruby lint.rb`
|
|
321
|
+
Then it should fail with exactly:
|
|
322
|
+
"""
|
|
323
|
+
MissingFeatureDescription - Favor a user story as description
|
|
324
|
+
lint.feature (1): Test
|
|
325
|
+
"""
|
|
326
|
+
#### Scenario: Passes for valid feature
|
|
327
|
+
Given a file named "lint.feature" with:
|
|
328
|
+
"""
|
|
329
|
+
Feature: Test
|
|
330
|
+
As a feature
|
|
331
|
+
I want to have a description,
|
|
332
|
+
so that everybody know why I exist
|
|
333
|
+
"""
|
|
334
|
+
When I run `ruby lint.rb`
|
|
335
|
+
Then it should pass with exactly:
|
|
336
|
+
"""
|
|
337
|
+
"""
|
|
338
|
+
### Feature Missing Feature Name (features/missing_feature_name.feature)
|
|
339
|
+
As a Customer
|
|
340
|
+
I want named features
|
|
341
|
+
so that I know what the feature is about just by reading the name
|
|
342
|
+
#### Background:
|
|
343
|
+
Given a file named "lint.rb" with:
|
|
344
|
+
"""
|
|
345
|
+
$LOAD_PATH << '../../lib'
|
|
346
|
+
require 'gherkin_lint'
|
|
347
|
+
linter = GherkinLint.new
|
|
348
|
+
linter.enable %w(MissingFeatureName)
|
|
349
|
+
linter.analyze 'lint.feature'
|
|
350
|
+
exit linter.report
|
|
351
|
+
"""
|
|
352
|
+
#### Scenario: Warns for missing feature name
|
|
353
|
+
Given a file named "lint.feature" with:
|
|
354
|
+
"""
|
|
355
|
+
Feature:
|
|
356
|
+
"""
|
|
357
|
+
When I run `ruby lint.rb`
|
|
358
|
+
Then it should fail with exactly:
|
|
359
|
+
"""
|
|
360
|
+
MissingFeatureName - No Feature Name
|
|
361
|
+
lint.feature
|
|
362
|
+
"""
|
|
363
|
+
#### Scenario: Passes for valid feature
|
|
364
|
+
Given a file named "lint.feature" with:
|
|
365
|
+
"""
|
|
366
|
+
Feature: Test
|
|
367
|
+
"""
|
|
368
|
+
When I run `ruby lint.rb`
|
|
369
|
+
Then it should pass with exactly:
|
|
370
|
+
"""
|
|
371
|
+
"""
|
|
372
|
+
### Feature Missing Scenario Name (features/missing_scenario_name.feature)
|
|
373
|
+
As a Customer
|
|
374
|
+
I want named scenarios
|
|
375
|
+
so that I know what this scenario is about without reading it
|
|
376
|
+
#### Background:
|
|
377
|
+
Given a file named "lint.rb" with:
|
|
378
|
+
"""
|
|
379
|
+
$LOAD_PATH << '../../lib'
|
|
380
|
+
require 'gherkin_lint'
|
|
381
|
+
linter = GherkinLint.new
|
|
382
|
+
linter.enable %w(MissingScenarioName)
|
|
383
|
+
linter.analyze 'lint.feature'
|
|
384
|
+
exit linter.report
|
|
385
|
+
"""
|
|
386
|
+
#### Scenario: Warns for missing scenario name
|
|
387
|
+
Given a file named "lint.feature" with:
|
|
388
|
+
"""
|
|
389
|
+
Feature: Test
|
|
390
|
+
Scenario:
|
|
391
|
+
"""
|
|
392
|
+
When I run `ruby lint.rb`
|
|
393
|
+
Then it should fail with exactly:
|
|
394
|
+
"""
|
|
395
|
+
MissingScenarioName - No Scenario Name
|
|
396
|
+
lint.feature (2): Test
|
|
397
|
+
"""
|
|
398
|
+
#### Scenario: Warns for missing scenario outline name
|
|
399
|
+
Given a file named "lint.feature" with:
|
|
400
|
+
"""
|
|
401
|
+
Feature: Test
|
|
402
|
+
Scenario Outline:
|
|
403
|
+
"""
|
|
404
|
+
When I run `ruby lint.rb`
|
|
405
|
+
Then it should fail with exactly:
|
|
406
|
+
"""
|
|
407
|
+
MissingScenarioName - No Scenario Name
|
|
408
|
+
lint.feature (2): Test
|
|
409
|
+
"""
|
|
410
|
+
#### Scenario: Passes for valid feature
|
|
411
|
+
Given a file named "lint.feature" with:
|
|
412
|
+
"""
|
|
413
|
+
Feature: Test
|
|
414
|
+
Scenario: A
|
|
415
|
+
"""
|
|
416
|
+
When I run `ruby lint.rb`
|
|
417
|
+
Then it should pass with exactly:
|
|
418
|
+
"""
|
|
419
|
+
"""
|
|
420
|
+
### Feature Missing Test Action (features/missing_test_action.feature)
|
|
421
|
+
As a Business Analyst
|
|
422
|
+
I want to be warned if I missed an action to test
|
|
423
|
+
so that all my scenarios actually stimulate the system and provoke a behavior
|
|
424
|
+
#### Background:
|
|
425
|
+
Given a file named "lint.rb" with:
|
|
426
|
+
"""
|
|
427
|
+
$LOAD_PATH << '../../lib'
|
|
428
|
+
require 'gherkin_lint'
|
|
429
|
+
linter = GherkinLint.new
|
|
430
|
+
linter.enable %w(MissingTestAction)
|
|
431
|
+
linter.analyze 'lint.feature'
|
|
432
|
+
exit linter.report
|
|
433
|
+
"""
|
|
434
|
+
#### Scenario: Warns for missing action
|
|
435
|
+
Given a file named "lint.feature" with:
|
|
436
|
+
"""
|
|
437
|
+
Feature: Test
|
|
438
|
+
Scenario: A
|
|
439
|
+
Given setup
|
|
440
|
+
Then verification
|
|
441
|
+
"""
|
|
442
|
+
When I run `ruby lint.rb`
|
|
443
|
+
Then it should fail with exactly:
|
|
444
|
+
"""
|
|
445
|
+
MissingTestAction - No 'When'-Step
|
|
446
|
+
lint.feature (2): Test.A
|
|
447
|
+
"""
|
|
448
|
+
#### Scenario: Passes for valid feature
|
|
449
|
+
Given a file named "lint.feature" with:
|
|
450
|
+
"""
|
|
451
|
+
Feature: Test
|
|
452
|
+
Scenario: A
|
|
453
|
+
Given setup
|
|
454
|
+
When action
|
|
455
|
+
Then verification
|
|
456
|
+
"""
|
|
457
|
+
When I run `ruby lint.rb`
|
|
458
|
+
Then it should pass with exactly:
|
|
459
|
+
"""
|
|
460
|
+
"""
|
|
461
|
+
### Feature Missing Verification (features/missing_verification.feature)
|
|
462
|
+
As a Business Analyst
|
|
463
|
+
I want that each test contains at least one verification
|
|
464
|
+
so that I'm sure that the behavior of the system is tested
|
|
465
|
+
#### Background:
|
|
466
|
+
Given a file named "lint.rb" with:
|
|
467
|
+
"""
|
|
468
|
+
$LOAD_PATH << '../../lib'
|
|
469
|
+
require 'gherkin_lint'
|
|
470
|
+
linter = GherkinLint.new
|
|
471
|
+
linter.enable %w(MissingVerification)
|
|
472
|
+
linter.analyze 'lint.feature'
|
|
473
|
+
exit linter.report
|
|
474
|
+
"""
|
|
475
|
+
#### Scenario: Warns for missing verification
|
|
476
|
+
Given a file named "lint.feature" with:
|
|
477
|
+
"""
|
|
478
|
+
Feature: Test
|
|
479
|
+
Scenario: A
|
|
480
|
+
Given setup
|
|
481
|
+
When test
|
|
482
|
+
"""
|
|
483
|
+
When I run `ruby lint.rb`
|
|
484
|
+
Then it should fail with exactly:
|
|
485
|
+
"""
|
|
486
|
+
MissingVerification - No verification step
|
|
487
|
+
lint.feature (2): Test.A
|
|
488
|
+
"""
|
|
489
|
+
#### Scenario: Passes for valid feature
|
|
490
|
+
Given a file named "lint.feature" with:
|
|
491
|
+
"""
|
|
492
|
+
Feature: Test
|
|
493
|
+
Scenario: A
|
|
494
|
+
Given setup
|
|
495
|
+
When action
|
|
496
|
+
Then verification
|
|
497
|
+
"""
|
|
498
|
+
When I run `ruby lint.rb`
|
|
499
|
+
Then it should pass with exactly:
|
|
500
|
+
"""
|
|
501
|
+
"""
|
|
502
|
+
### Feature Unique Scenario Names (features/unique_scenario_names.feature)
|
|
503
|
+
As a Customer
|
|
504
|
+
I want unique scenario names
|
|
505
|
+
so that I can refer to them in case of issues
|
|
506
|
+
#### Background:
|
|
507
|
+
Given a file named "lint.rb" with:
|
|
508
|
+
"""
|
|
509
|
+
$LOAD_PATH << '../../lib'
|
|
510
|
+
require 'gherkin_lint'
|
|
511
|
+
linter = GherkinLint.new
|
|
512
|
+
linter.enable %w(UniqueScenarioNames)
|
|
513
|
+
linter.analyze 'lint.feature'
|
|
514
|
+
exit linter.report
|
|
515
|
+
"""
|
|
516
|
+
#### Scenario: Warns for non unique scenario name
|
|
517
|
+
Given a file named "lint.feature" with:
|
|
518
|
+
"""
|
|
519
|
+
Feature: Unique Scenario Names
|
|
520
|
+
Scenario: A
|
|
521
|
+
Scenario: A
|
|
522
|
+
"""
|
|
523
|
+
When I run `ruby lint.rb`
|
|
524
|
+
Then it should fail with exactly:
|
|
525
|
+
"""
|
|
526
|
+
UniqueScenarioNames - 'Unique Scenario Names.A' used 2 times
|
|
527
|
+
lint.feature (2): Unique Scenario Names.A
|
|
528
|
+
lint.feature (3): Unique Scenario Names.A
|
|
529
|
+
"""
|
|
530
|
+
#### Scenario: Passes for unique scenario names
|
|
531
|
+
Given a file named "lint.feature" with:
|
|
532
|
+
"""
|
|
533
|
+
Feature: Unique Scenario Names
|
|
534
|
+
Scenario: A
|
|
535
|
+
Scenario: B
|
|
536
|
+
"""
|
|
537
|
+
When I run `ruby lint.rb`
|
|
538
|
+
Then it should pass with exactly:
|
|
539
|
+
"""
|
|
540
|
+
"""
|
|
541
|
+
### Feature Unused Variable (features/unused_variable.feature)
|
|
542
|
+
As a Business Analyst
|
|
543
|
+
I want to be warned about unused variables
|
|
544
|
+
so that I can delete them if they are not used any more or refer them again
|
|
545
|
+
#### Background:
|
|
546
|
+
Given a file named "lint.rb" with:
|
|
547
|
+
"""
|
|
548
|
+
$LOAD_PATH << '../../lib'
|
|
549
|
+
require 'gherkin_lint'
|
|
550
|
+
linter = GherkinLint.new
|
|
551
|
+
linter.enable %w(UnusedVariable)
|
|
552
|
+
linter.analyze 'lint.feature'
|
|
553
|
+
exit linter.report
|
|
554
|
+
"""
|
|
555
|
+
#### Scenario: Unused Variable in step
|
|
556
|
+
Given a file named "lint.feature" with:
|
|
557
|
+
"""
|
|
558
|
+
Feature: Test
|
|
559
|
+
Scenario Outline: A
|
|
560
|
+
When <bar>
|
|
561
|
+
|
|
562
|
+
Examples: Values
|
|
563
|
+
| bar | foo |
|
|
564
|
+
| 1 | 2 |
|
|
565
|
+
"""
|
|
566
|
+
When I run `ruby lint.rb`
|
|
567
|
+
Then it should fail with exactly:
|
|
568
|
+
"""
|
|
569
|
+
UnusedVariable - '<foo>' is unused
|
|
570
|
+
lint.feature (2): Test.A
|
|
571
|
+
"""
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
#### Scenario: Unused Variable in table
|
|
575
|
+
|
|
576
|
+
Given a file named "lint.feature" with:
|
|
577
|
+
"""
|
|
578
|
+
Feature: Test
|
|
579
|
+
Scenario Outline: A
|
|
580
|
+
When test
|
|
581
|
+
| value |
|
|
582
|
+
| <bar> |
|
|
583
|
+
|
|
584
|
+
Examples: Values
|
|
585
|
+
| bar | foo |
|
|
586
|
+
| 1 | 2 |
|
|
587
|
+
"""
|
|
588
|
+
When I run `ruby lint.rb`
|
|
589
|
+
Then it should fail with exactly:
|
|
590
|
+
"""
|
|
591
|
+
UnusedVariable - '<foo>' is unused
|
|
592
|
+
lint.feature (2): Test.A
|
|
593
|
+
|
|
594
|
+
"""
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
#### Scenario: Unused Variable in pystring
|
|
598
|
+
|
|
599
|
+
Given a file named "lint.feature" with:
|
|
600
|
+
"""
|
|
601
|
+
Feature: Test
|
|
602
|
+
Scenario Outline: A
|
|
603
|
+
When test
|
|
604
|
+
"""
|
|
605
|
+
<bar>
|
|
606
|
+
"""
|
|
607
|
+
|
|
608
|
+
Examples: Values
|
|
609
|
+
| bar | foo |
|
|
610
|
+
| 1 | 2 |
|
|
611
|
+
"""
|
|
612
|
+
When I run `ruby lint.rb`
|
|
613
|
+
Then it should fail with exactly:
|
|
614
|
+
"""
|
|
615
|
+
UnusedVariable - '<foo>' is unused
|
|
616
|
+
lint.feature (2): Test.A
|
|
617
|
+
|
|
618
|
+
"""
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
#### Scenario: Passes for Test
|
|
622
|
+
|
|
623
|
+
Given a file named "lint.feature" with:
|
|
624
|
+
"""
|
|
625
|
+
Feature: Test
|
|
626
|
+
Scenario Outline: A
|
|
627
|
+
Given <first>
|
|
628
|
+
| value |
|
|
629
|
+
| <second> |
|
|
630
|
+
When test
|
|
631
|
+
"""
|
|
632
|
+
<third>
|
|
633
|
+
"""
|
|
634
|
+
|
|
635
|
+
Examples: Test
|
|
636
|
+
| first | second | third |
|
|
637
|
+
| used value | used | also |
|
|
638
|
+
"""
|
|
639
|
+
When I run `ruby lint.rb`
|
|
640
|
+
Then it should pass with exactly:
|
|
641
|
+
"""
|
|
642
|
+
|
|
643
|
+
"""
|
|
644
|
+
|