gherkin_lint 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +1 -1
- data/Gemfile +1 -0
- data/README.md +42 -631
- data/Rakefile +6 -2
- data/features/avoid_scripting.feature +2 -0
- data/features/be_declarative.feature +53 -0
- data/features/missing_example_name.feature +24 -0
- data/features/same_tag_for_all_scenarios.feature +41 -1
- data/gherkin_lint.gemspec +3 -2
- data/lib/gherkin_lint.rb +10 -4
- data/lib/gherkin_lint/issue.rb +13 -0
- data/lib/gherkin_lint/linter.rb +15 -11
- data/lib/gherkin_lint/linter/avoid_outline_for_single_example.rb +1 -1
- data/lib/gherkin_lint/linter/avoid_period.rb +1 -1
- data/lib/gherkin_lint/linter/avoid_scripting.rb +1 -1
- data/lib/gherkin_lint/linter/background_does_more_than_setup.rb +1 -1
- data/lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb +1 -1
- data/lib/gherkin_lint/linter/bad_scenario_name.rb +1 -1
- data/lib/gherkin_lint/linter/be_declarative.rb +45 -0
- data/lib/gherkin_lint/linter/file_name_differs_feature_name.rb +1 -1
- data/lib/gherkin_lint/linter/invalid_file_name.rb +1 -1
- data/lib/gherkin_lint/linter/invalid_step_flow.rb +3 -3
- data/lib/gherkin_lint/linter/missing_example_name.rb +2 -1
- data/lib/gherkin_lint/linter/missing_feature_description.rb +1 -1
- data/lib/gherkin_lint/linter/missing_feature_name.rb +1 -1
- data/lib/gherkin_lint/linter/missing_scenario_name.rb +1 -1
- data/lib/gherkin_lint/linter/missing_test_action.rb +1 -1
- data/lib/gherkin_lint/linter/missing_verification.rb +1 -1
- data/lib/gherkin_lint/linter/same_tag_for_all_scenarios.rb +39 -6
- data/lib/gherkin_lint/linter/too_clumsy.rb +1 -1
- data/lib/gherkin_lint/linter/too_long_step.rb +1 -1
- data/lib/gherkin_lint/linter/too_many_different_tags.rb +2 -2
- data/lib/gherkin_lint/linter/too_many_steps.rb +1 -1
- data/lib/gherkin_lint/linter/too_many_tags.rb +1 -1
- data/lib/gherkin_lint/linter/unique_scenario_names.rb +1 -1
- data/lib/gherkin_lint/linter/unknown_variable.rb +1 -1
- data/lib/gherkin_lint/linter/unused_variable.rb +1 -1
- data/lib/gherkin_lint/linter/use_background.rb +1 -1
- data/lib/gherkin_lint/linter/use_outline.rb +1 -1
- metadata +43 -15
- checksums.yaml +0 -7
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -13,637 +13,48 @@ run `gherkin_lint` on a list of files
|
|
13
13
|
|
14
14
|
With `--disable CHECK` or `--enable CHECK` it's possible to disable respectivly enable program wide checks.
|
15
15
|
|
16
|
-
Checks could be disabled using tags within Feature Files. To do so, add @disableCHECK.
|
17
|
-
|
18
|
-
## Checks
|
19
|
-
|
20
|
-
### Feature Avoid colon (features/avoid_colon.feature)
|
21
|
-
As a Business Analyst
|
22
|
-
I do not want colons at the end of my user stories
|
23
|
-
#### Background:
|
24
|
-
Given a file named "lint.rb" with:
|
25
|
-
"""
|
26
|
-
$LOAD_PATH << '../../lib'
|
27
|
-
require 'gherkin_lint'
|
28
|
-
linter = GherkinLint.new
|
29
|
-
linter.enable %w(AvoidColon)
|
30
|
-
linter.analyze 'lint.feature'
|
31
|
-
exit linter.report
|
32
|
-
"""
|
33
|
-
#### Scenario: Warns for colon
|
34
|
-
Given a file named "lint.feature" with:
|
35
|
-
"""
|
36
|
-
Feature: Test
|
37
|
-
Scenario: A
|
38
|
-
Given setup
|
39
|
-
When test
|
40
|
-
Then verification.
|
41
|
-
"""
|
42
|
-
When I run `ruby lint.rb`
|
43
|
-
Then it should fail with exactly:
|
44
|
-
"""
|
45
|
-
AvoidColon
|
46
|
-
lint.feature (5): Test.A step: verification.
|
47
|
-
"""
|
48
|
-
#### Scenario: Passes for Test
|
49
|
-
Given a file named "lint.feature" with:
|
50
|
-
"""
|
51
|
-
Feature: Test
|
52
|
-
Scenario: A
|
53
|
-
Given setup
|
54
|
-
When test
|
55
|
-
Then verification
|
56
|
-
"""
|
57
|
-
When I run `ruby lint.rb`
|
58
|
-
Then it should pass with exactly:
|
59
|
-
"""
|
60
|
-
"""
|
61
|
-
### Feature Background does more than setup (features/background_does_more_than_setup.feature)
|
62
|
-
As a Business Analyst
|
63
|
-
I want to be warned if there is more than setup in background
|
64
|
-
so that tests stay understandable
|
65
|
-
#### Background:
|
66
|
-
Given a file named "lint.rb" with:
|
67
|
-
"""
|
68
|
-
$LOAD_PATH << '../../lib'
|
69
|
-
require 'gherkin_lint'
|
70
|
-
linter = GherkinLint.new
|
71
|
-
linter.enable %w(BackgroundDoesMoreThanSetup)
|
72
|
-
linter.analyze 'lint.feature'
|
73
|
-
exit linter.report
|
74
|
-
"""
|
75
|
-
#### Scenario: Warns for missing verification
|
76
|
-
Given a file named "lint.feature" with:
|
77
|
-
"""
|
78
|
-
Feature: Test
|
79
|
-
Background: Preparation
|
80
|
-
Given setup
|
81
|
-
When test
|
82
|
-
"""
|
83
|
-
When I run `ruby lint.rb`
|
84
|
-
Then it should fail with exactly:
|
85
|
-
"""
|
86
|
-
BackgroundDoesMoreThanSetup - Just Given Steps allowed
|
87
|
-
lint.feature (4): Test.Preparation step: test
|
88
|
-
"""
|
89
|
-
#### Scenario: Passes for valid feature
|
90
|
-
Given a file named "lint.feature" with:
|
91
|
-
"""
|
92
|
-
Feature: Test
|
93
|
-
Background: Preparation
|
94
|
-
Given setup
|
95
|
-
"""
|
96
|
-
When I run `ruby lint.rb`
|
97
|
-
Then it should pass with exactly:
|
98
|
-
"""
|
99
|
-
"""
|
100
|
-
### Feature Invalid File Name (features/invalid_file_name.feature)
|
101
|
-
As a Business Analyst
|
102
|
-
I want to be warned about invalid file named
|
103
|
-
so that I name all features consistently
|
104
|
-
#### Background:
|
105
|
-
Given a file named "lint.rb" with:
|
106
|
-
"""
|
107
|
-
$LOAD_PATH << '../../lib'
|
108
|
-
require 'gherkin_lint'
|
109
|
-
require 'optparse'
|
110
|
-
options = {}
|
111
|
-
OptionParser.new { |opts| }.parse!
|
112
|
-
linter = GherkinLint.new
|
113
|
-
linter.enable %w(InvalidFileName)
|
114
|
-
ARGV.each { |file| linter.analyze file }
|
115
|
-
exit linter.report
|
116
|
-
"""
|
117
|
-
#### Scenario Outline: Warns for "verification" within scenario name
|
118
|
-
Given a file named "<invalid name>.feature" with:
|
119
|
-
"""
|
120
|
-
Feature: Test
|
121
|
-
"""
|
122
|
-
When I run `ruby lint.rb <invalid name>.feature`
|
123
|
-
Then it should fail with exactly:
|
124
|
-
"""
|
125
|
-
InvalidFileName - Feature files should be snake_cased
|
126
|
-
<invalid name>.feature
|
127
|
-
"""
|
128
|
-
##### Examples: Invalid Names
|
129
|
-
| invalid name |
|
130
|
-
| Lint |
|
131
|
-
| lintMe |
|
132
|
-
#### Scenario: Passes for unique scenario names
|
133
|
-
Given a file named "lint.feature" with:
|
134
|
-
"""
|
135
|
-
Feature: Test
|
136
|
-
"""
|
137
|
-
When I run `ruby lint.rb lint.feature`
|
138
|
-
Then it should pass with exactly:
|
139
|
-
"""
|
140
|
-
"""
|
141
|
-
### Feature Invalid Scenario Name (features/invalid_scenario_name.feature)
|
142
|
-
As a Business Analyst
|
143
|
-
I want to be warned about invalid scenario names
|
144
|
-
so that I am able to look for better naming
|
145
|
-
#### Background:
|
146
|
-
Given a file named "lint.rb" with:
|
147
|
-
"""
|
148
|
-
$LOAD_PATH << '../../lib'
|
149
|
-
require 'gherkin_lint'
|
150
|
-
linter = GherkinLint.new
|
151
|
-
linter.enable %w(InvalidScenarioName)
|
152
|
-
linter.analyze 'lint.feature'
|
153
|
-
exit linter.report
|
154
|
-
"""
|
155
|
-
#### Scenario Outline: Warns for "verification" within scenario name
|
156
|
-
Given a file named "lint.feature" with:
|
157
|
-
"""
|
158
|
-
Feature: Test
|
159
|
-
Scenario: <bad word> something
|
160
|
-
"""
|
161
|
-
When I run `ruby lint.rb`
|
162
|
-
Then it should fail with exactly:
|
163
|
-
"""
|
164
|
-
InvalidScenarioName - Prefer to rely just on Given and When steps when name your scenario to keep it stable
|
165
|
-
lint.feature (2): Test.<bad word> something
|
166
|
-
"""
|
167
|
-
##### Examples: bad words
|
168
|
-
| bad word |
|
169
|
-
| Verifies |
|
170
|
-
| Verification |
|
171
|
-
| Verify |
|
172
|
-
| Checks |
|
173
|
-
| Check |
|
174
|
-
| Tests |
|
175
|
-
| Test |
|
176
|
-
#### Scenario: Passes for unique scenario names
|
177
|
-
Given a file named "lint.feature" with:
|
178
|
-
"""
|
179
|
-
Feature: Unique Scenario Names
|
180
|
-
Scenario: A
|
181
|
-
"""
|
182
|
-
When I run `ruby lint.rb`
|
183
|
-
Then it should pass with exactly:
|
184
|
-
"""
|
185
|
-
"""
|
186
|
-
### Feature Invalid Step Flow (features/invalid_step_flow.feature)
|
187
|
-
As a Business Analyst
|
188
|
-
I want to be warned about invalid step flow
|
189
|
-
so that all my tests make sense
|
190
|
-
#### Background:
|
191
|
-
Given a file named "lint.rb" with:
|
192
|
-
"""
|
193
|
-
$LOAD_PATH << '../../lib'
|
194
|
-
require 'gherkin_lint'
|
195
|
-
linter = GherkinLint.new
|
196
|
-
linter.enable %w(InvalidStepFlow)
|
197
|
-
linter.analyze 'lint.feature'
|
198
|
-
exit linter.report
|
199
|
-
"""
|
200
|
-
#### Scenario: Verification before Action
|
201
|
-
Given a file named "lint.feature" with:
|
202
|
-
"""
|
203
|
-
Feature: Test
|
204
|
-
Scenario: A
|
205
|
-
Given setup
|
206
|
-
Then verify
|
207
|
-
"""
|
208
|
-
When I run `ruby lint.rb`
|
209
|
-
Then it should fail with exactly:
|
210
|
-
"""
|
211
|
-
InvalidStepFlow - Verification before action
|
212
|
-
lint.feature (4): Test.A step: verify
|
213
|
-
"""
|
214
|
-
#### Scenario: Setup after Action
|
215
|
-
Given a file named "lint.feature" with:
|
216
|
-
"""
|
217
|
-
Feature: Test
|
218
|
-
Scenario: A
|
219
|
-
When test
|
220
|
-
Given setup
|
221
|
-
Then verify
|
222
|
-
"""
|
223
|
-
When I run `ruby lint.rb`
|
224
|
-
Then it should fail with exactly:
|
225
|
-
"""
|
226
|
-
InvalidStepFlow - Given after Action or Verification
|
227
|
-
lint.feature (4): Test.A step: setup
|
228
|
-
"""
|
229
|
-
#### Scenario: Action as last step
|
230
|
-
Given a file named "lint.feature" with:
|
231
|
-
"""
|
232
|
-
Feature: Test
|
233
|
-
Scenario: A
|
234
|
-
Given setup
|
235
|
-
When test
|
236
|
-
Then verify
|
237
|
-
When test
|
238
|
-
"""
|
239
|
-
When I run `ruby lint.rb`
|
240
|
-
Then it should fail with exactly:
|
241
|
-
"""
|
242
|
-
InvalidStepFlow - Last step is an action
|
243
|
-
lint.feature (6): Test.A step: test
|
244
|
-
"""
|
245
|
-
#### Scenario: Passes for Test
|
246
|
-
Given a file named "lint.feature" with:
|
247
|
-
"""
|
248
|
-
Feature: Test
|
249
|
-
Scenario: A
|
250
|
-
Given setup
|
251
|
-
When test
|
252
|
-
Then verification
|
253
|
-
When test
|
254
|
-
Then verification
|
255
|
-
"""
|
256
|
-
When I run `ruby lint.rb`
|
257
|
-
Then it should pass with exactly:
|
258
|
-
"""
|
259
|
-
"""
|
260
|
-
### Feature Missing Example Name (features/missing_example_name.feature)
|
261
|
-
As a Customer
|
262
|
-
I want examples to be named
|
263
|
-
so that I'm able to understand why this example exists
|
264
|
-
#### Background:
|
265
|
-
Given a file named "lint.rb" with:
|
266
|
-
"""
|
267
|
-
$LOAD_PATH << '../../lib'
|
268
|
-
require 'gherkin_lint'
|
269
|
-
linter = GherkinLint.new
|
270
|
-
linter.enable %w(MissingExampleName)
|
271
|
-
linter.analyze 'lint.feature'
|
272
|
-
exit linter.report
|
273
|
-
"""
|
274
|
-
#### Scenario: Warns for missing example name
|
275
|
-
Given a file named "lint.feature" with:
|
276
|
-
"""
|
277
|
-
Feature: Test
|
278
|
-
Scenario Outline: A
|
279
|
-
When test
|
280
|
-
Then <value>
|
281
|
-
Examples:
|
282
|
-
| value |
|
283
|
-
| test |
|
284
|
-
"""
|
285
|
-
When I run `ruby lint.rb`
|
286
|
-
Then it should fail with exactly:
|
287
|
-
"""
|
288
|
-
MissingExampleName - No Example Name
|
289
|
-
lint.feature (2): Test.A
|
290
|
-
"""
|
291
|
-
#### Scenario: Passes for valid feature
|
292
|
-
Given a file named "lint.feature" with:
|
293
|
-
"""
|
294
|
-
Feature: Test
|
295
|
-
Scenario Outline: A
|
296
|
-
When test
|
297
|
-
Then <value>
|
298
|
-
Examples: Table
|
299
|
-
| value |
|
300
|
-
| test |
|
301
|
-
"""
|
302
|
-
When I run `ruby lint.rb`
|
303
|
-
Then it should pass with exactly:
|
304
|
-
"""
|
305
|
-
"""
|
306
|
-
### Feature Missing Feature Description (features/missing_feature_description.feature)
|
307
|
-
As a Customer
|
308
|
-
I want feature descriptions
|
309
|
-
so that I know why the features exist
|
310
|
-
#### Background:
|
311
|
-
Given a file named "lint.rb" with:
|
312
|
-
"""
|
313
|
-
$LOAD_PATH << '../../lib'
|
314
|
-
require 'gherkin_lint'
|
315
|
-
linter = GherkinLint.new
|
316
|
-
linter.enable %w(MissingFeatureDescription)
|
317
|
-
linter.analyze 'lint.feature'
|
318
|
-
exit linter.report
|
319
|
-
"""
|
320
|
-
#### Scenario: Warns for missing feature name
|
321
|
-
Given a file named "lint.feature" with:
|
322
|
-
"""
|
323
|
-
Feature: Test
|
324
|
-
"""
|
325
|
-
When I run `ruby lint.rb`
|
326
|
-
Then it should fail with exactly:
|
327
|
-
"""
|
328
|
-
MissingFeatureDescription - Favor a user story as description
|
329
|
-
lint.feature (1): Test
|
330
|
-
"""
|
331
|
-
#### Scenario: Passes for valid feature
|
332
|
-
Given a file named "lint.feature" with:
|
333
|
-
"""
|
334
|
-
Feature: Test
|
335
|
-
As a feature
|
336
|
-
I want to have a description,
|
337
|
-
so that everybody know why I exist
|
338
|
-
"""
|
339
|
-
When I run `ruby lint.rb`
|
340
|
-
Then it should pass with exactly:
|
341
|
-
"""
|
342
|
-
"""
|
343
|
-
### Feature Missing Feature Name (features/missing_feature_name.feature)
|
344
|
-
As a Customer
|
345
|
-
I want named features
|
346
|
-
so that I know what the feature is about just by reading the name
|
347
|
-
#### Background:
|
348
|
-
Given a file named "lint.rb" with:
|
349
|
-
"""
|
350
|
-
$LOAD_PATH << '../../lib'
|
351
|
-
require 'gherkin_lint'
|
352
|
-
linter = GherkinLint.new
|
353
|
-
linter.enable %w(MissingFeatureName)
|
354
|
-
linter.analyze 'lint.feature'
|
355
|
-
exit linter.report
|
356
|
-
"""
|
357
|
-
#### Scenario: Warns for missing feature name
|
358
|
-
Given a file named "lint.feature" with:
|
359
|
-
"""
|
360
|
-
Feature:
|
361
|
-
"""
|
362
|
-
When I run `ruby lint.rb`
|
363
|
-
Then it should fail with exactly:
|
364
|
-
"""
|
365
|
-
MissingFeatureName - No Feature Name
|
366
|
-
lint.feature
|
367
|
-
"""
|
368
|
-
#### Scenario: Passes for valid feature
|
369
|
-
Given a file named "lint.feature" with:
|
370
|
-
"""
|
371
|
-
Feature: Test
|
372
|
-
"""
|
373
|
-
When I run `ruby lint.rb`
|
374
|
-
Then it should pass with exactly:
|
375
|
-
"""
|
376
|
-
"""
|
377
|
-
### Feature Missing Scenario Name (features/missing_scenario_name.feature)
|
378
|
-
As a Customer
|
379
|
-
I want named scenarios
|
380
|
-
so that I know what this scenario is about without reading it
|
381
|
-
#### Background:
|
382
|
-
Given a file named "lint.rb" with:
|
383
|
-
"""
|
384
|
-
$LOAD_PATH << '../../lib'
|
385
|
-
require 'gherkin_lint'
|
386
|
-
linter = GherkinLint.new
|
387
|
-
linter.enable %w(MissingScenarioName)
|
388
|
-
linter.analyze 'lint.feature'
|
389
|
-
exit linter.report
|
390
|
-
"""
|
391
|
-
#### Scenario: Warns for missing scenario name
|
392
|
-
Given a file named "lint.feature" with:
|
393
|
-
"""
|
394
|
-
Feature: Test
|
395
|
-
Scenario:
|
396
|
-
"""
|
397
|
-
When I run `ruby lint.rb`
|
398
|
-
Then it should fail with exactly:
|
399
|
-
"""
|
400
|
-
MissingScenarioName - No Scenario Name
|
401
|
-
lint.feature (2): Test
|
402
|
-
"""
|
403
|
-
#### Scenario: Warns for missing scenario outline name
|
404
|
-
Given a file named "lint.feature" with:
|
405
|
-
"""
|
406
|
-
Feature: Test
|
407
|
-
Scenario Outline:
|
408
|
-
"""
|
409
|
-
When I run `ruby lint.rb`
|
410
|
-
Then it should fail with exactly:
|
411
|
-
"""
|
412
|
-
MissingScenarioName - No Scenario Name
|
413
|
-
lint.feature (2): Test
|
414
|
-
"""
|
415
|
-
#### Scenario: Passes for valid feature
|
416
|
-
Given a file named "lint.feature" with:
|
417
|
-
"""
|
418
|
-
Feature: Test
|
419
|
-
Scenario: A
|
420
|
-
"""
|
421
|
-
When I run `ruby lint.rb`
|
422
|
-
Then it should pass with exactly:
|
423
|
-
"""
|
424
|
-
"""
|
425
|
-
### Feature Missing Test Action (features/missing_test_action.feature)
|
426
|
-
As a Business Analyst
|
427
|
-
I want to be warned if I missed an action to test
|
428
|
-
so that all my scenarios actually stimulate the system and provoke a behavior
|
429
|
-
#### Background:
|
430
|
-
Given a file named "lint.rb" with:
|
431
|
-
"""
|
432
|
-
$LOAD_PATH << '../../lib'
|
433
|
-
require 'gherkin_lint'
|
434
|
-
linter = GherkinLint.new
|
435
|
-
linter.enable %w(MissingTestAction)
|
436
|
-
linter.analyze 'lint.feature'
|
437
|
-
exit linter.report
|
438
|
-
"""
|
439
|
-
#### Scenario: Warns for missing action
|
440
|
-
Given a file named "lint.feature" with:
|
441
|
-
"""
|
442
|
-
Feature: Test
|
443
|
-
Scenario: A
|
444
|
-
Given setup
|
445
|
-
Then verification
|
446
|
-
"""
|
447
|
-
When I run `ruby lint.rb`
|
448
|
-
Then it should fail with exactly:
|
449
|
-
"""
|
450
|
-
MissingTestAction - No 'When'-Step
|
451
|
-
lint.feature (2): Test.A
|
452
|
-
"""
|
453
|
-
#### Scenario: Passes for valid feature
|
454
|
-
Given a file named "lint.feature" with:
|
455
|
-
"""
|
456
|
-
Feature: Test
|
457
|
-
Scenario: A
|
458
|
-
Given setup
|
459
|
-
When action
|
460
|
-
Then verification
|
461
|
-
"""
|
462
|
-
When I run `ruby lint.rb`
|
463
|
-
Then it should pass with exactly:
|
464
|
-
"""
|
465
|
-
"""
|
466
|
-
### Feature Missing Verification (features/missing_verification.feature)
|
467
|
-
As a Business Analyst
|
468
|
-
I want that each test contains at least one verification
|
469
|
-
so that I'm sure that the behavior of the system is tested
|
470
|
-
#### Background:
|
471
|
-
Given a file named "lint.rb" with:
|
472
|
-
"""
|
473
|
-
$LOAD_PATH << '../../lib'
|
474
|
-
require 'gherkin_lint'
|
475
|
-
linter = GherkinLint.new
|
476
|
-
linter.enable %w(MissingVerification)
|
477
|
-
linter.analyze 'lint.feature'
|
478
|
-
exit linter.report
|
479
|
-
"""
|
480
|
-
#### Scenario: Warns for missing verification
|
481
|
-
Given a file named "lint.feature" with:
|
482
|
-
"""
|
483
|
-
Feature: Test
|
484
|
-
Scenario: A
|
485
|
-
Given setup
|
486
|
-
When test
|
487
|
-
"""
|
488
|
-
When I run `ruby lint.rb`
|
489
|
-
Then it should fail with exactly:
|
490
|
-
"""
|
491
|
-
MissingVerification - No verification step
|
492
|
-
lint.feature (2): Test.A
|
493
|
-
"""
|
494
|
-
#### Scenario: Passes for valid feature
|
495
|
-
Given a file named "lint.feature" with:
|
496
|
-
"""
|
497
|
-
Feature: Test
|
498
|
-
Scenario: A
|
499
|
-
Given setup
|
500
|
-
When action
|
501
|
-
Then verification
|
502
|
-
"""
|
503
|
-
When I run `ruby lint.rb`
|
504
|
-
Then it should pass with exactly:
|
505
|
-
"""
|
506
|
-
"""
|
507
|
-
### Feature Unique Scenario Names (features/unique_scenario_names.feature)
|
508
|
-
As a Customer
|
509
|
-
I want unique scenario names
|
510
|
-
so that I can refer to them in case of issues
|
511
|
-
#### Background:
|
512
|
-
Given a file named "lint.rb" with:
|
513
|
-
"""
|
514
|
-
$LOAD_PATH << '../../lib'
|
515
|
-
require 'gherkin_lint'
|
516
|
-
linter = GherkinLint.new
|
517
|
-
linter.enable %w(UniqueScenarioNames)
|
518
|
-
linter.analyze 'lint.feature'
|
519
|
-
exit linter.report
|
520
|
-
"""
|
521
|
-
#### Scenario: Warns for non unique scenario name
|
522
|
-
Given a file named "lint.feature" with:
|
523
|
-
"""
|
524
|
-
Feature: Unique Scenario Names
|
525
|
-
Scenario: A
|
526
|
-
Scenario: A
|
527
|
-
"""
|
528
|
-
When I run `ruby lint.rb`
|
529
|
-
Then it should fail with exactly:
|
530
|
-
"""
|
531
|
-
UniqueScenarioNames - 'Unique Scenario Names.A' used 2 times
|
532
|
-
lint.feature (2): Unique Scenario Names.A
|
533
|
-
lint.feature (3): Unique Scenario Names.A
|
534
|
-
"""
|
535
|
-
#### Scenario: Passes for unique scenario names
|
536
|
-
Given a file named "lint.feature" with:
|
537
|
-
"""
|
538
|
-
Feature: Unique Scenario Names
|
539
|
-
Scenario: A
|
540
|
-
Scenario: B
|
541
|
-
"""
|
542
|
-
When I run `ruby lint.rb`
|
543
|
-
Then it should pass with exactly:
|
544
|
-
"""
|
545
|
-
"""
|
546
|
-
### Feature Unused Variable (features/unused_variable.feature)
|
547
|
-
As a Business Analyst
|
548
|
-
I want to be warned about unused variables
|
549
|
-
so that I can delete them if they are not used any more or refer them again
|
550
|
-
#### Background:
|
551
|
-
Given a file named "lint.rb" with:
|
552
|
-
"""
|
553
|
-
$LOAD_PATH << '../../lib'
|
554
|
-
require 'gherkin_lint'
|
555
|
-
linter = GherkinLint.new
|
556
|
-
linter.enable %w(UnusedVariable)
|
557
|
-
linter.analyze 'lint.feature'
|
558
|
-
exit linter.report
|
559
|
-
"""
|
560
|
-
#### Scenario: Unused Variable in step
|
561
|
-
Given a file named "lint.feature" with:
|
562
|
-
"""
|
563
|
-
Feature: Test
|
564
|
-
Scenario Outline: A
|
565
|
-
When <bar>
|
566
|
-
|
567
|
-
Examples: Values
|
568
|
-
| bar | foo |
|
569
|
-
| 1 | 2 |
|
570
|
-
"""
|
571
|
-
When I run `ruby lint.rb`
|
572
|
-
Then it should fail with exactly:
|
573
|
-
"""
|
574
|
-
UnusedVariable - '<foo>' is unused
|
575
|
-
lint.feature (2): Test.A
|
576
|
-
"""
|
577
|
-
|
578
|
-
|
579
|
-
#### Scenario: Unused Variable in table
|
580
|
-
|
581
|
-
Given a file named "lint.feature" with:
|
582
|
-
"""
|
583
|
-
Feature: Test
|
584
|
-
Scenario Outline: A
|
585
|
-
When test
|
586
|
-
| value |
|
587
|
-
| <bar> |
|
588
|
-
|
589
|
-
Examples: Values
|
590
|
-
| bar | foo |
|
591
|
-
| 1 | 2 |
|
592
|
-
"""
|
593
|
-
When I run `ruby lint.rb`
|
594
|
-
Then it should fail with exactly:
|
595
|
-
"""
|
596
|
-
UnusedVariable - '<foo>' is unused
|
597
|
-
lint.feature (2): Test.A
|
598
|
-
|
599
|
-
"""
|
16
|
+
Checks could be disabled using tags within Feature Files. To do so, add @disableCHECK.
|
17
|
+
Detailed usage within the [disable_tags](https://github.com/funkwerk/gherkin_lint/blob/master/features/disable_tags.feature) feature.
|
600
18
|
|
601
19
|
|
602
|
-
|
603
|
-
|
604
|
-
Given a file named "lint.feature" with:
|
605
|
-
"""
|
606
|
-
Feature: Test
|
607
|
-
Scenario Outline: A
|
608
|
-
When test
|
609
|
-
"""
|
610
|
-
<bar>
|
611
|
-
"""
|
612
|
-
|
613
|
-
Examples: Values
|
614
|
-
| bar | foo |
|
615
|
-
| 1 | 2 |
|
616
|
-
"""
|
617
|
-
When I run `ruby lint.rb`
|
618
|
-
Then it should fail with exactly:
|
619
|
-
"""
|
620
|
-
UnusedVariable - '<foo>' is unused
|
621
|
-
lint.feature (2): Test.A
|
622
|
-
|
623
|
-
"""
|
624
|
-
|
625
|
-
|
626
|
-
#### Scenario: Passes for Test
|
627
|
-
|
628
|
-
Given a file named "lint.feature" with:
|
629
|
-
"""
|
630
|
-
Feature: Test
|
631
|
-
Scenario Outline: A
|
632
|
-
Given <first>
|
633
|
-
| value |
|
634
|
-
| <second> |
|
635
|
-
When test
|
636
|
-
"""
|
637
|
-
<third>
|
638
|
-
"""
|
639
|
-
|
640
|
-
Examples: Test
|
641
|
-
| first | second | third |
|
642
|
-
| used value | used | also |
|
643
|
-
"""
|
644
|
-
When I run `ruby lint.rb`
|
645
|
-
Then it should pass with exactly:
|
646
|
-
"""
|
647
|
-
|
648
|
-
"""
|
20
|
+
## Checks
|
649
21
|
|
22
|
+
- [avoid outline for single example](https://github.com/funkwerk/gherkin_lint/blob/master/features/avoid_outline_for_single_example.feature)
|
23
|
+
- [avoid period](https://github.com/funkwerk/gherkin_lint/blob/master/features/avoid_period.feature)
|
24
|
+
- [avoid scripting](https://github.com/funkwerk/gherkin_lint/blob/master/features/avoid_scripting.feature)
|
25
|
+
- [be declarative](https://github.com/funkwerk/gherkin_lint/blob/master/features/be_declarative.feature)
|
26
|
+
- [background does more than setup](https://github.com/funkwerk/gherkin_lint/blob/master/features/background_does_more_than_setup.feature)
|
27
|
+
- [background requires scenario](https://github.com/funkwerk/gherkin_lint/blob/master/features/background_requires_scenario.feature)
|
28
|
+
- [bad scenario name](https://github.com/funkwerk/gherkin_lint/blob/master/features/bad_scenario_name.feature)
|
29
|
+
- [file name differs feature name](https://github.com/funkwerk/gherkin_lint/blob/master/features/file_name_differs_feature_name.feature)
|
30
|
+
- [invalid file name](https://github.com/funkwerk/gherkin_lint/blob/master/features/invalid_file_name.feature)
|
31
|
+
- [invalid step flow](https://github.com/funkwerk/gherkin_lint/blob/master/features/invalid_step_flow.feature)
|
32
|
+
- [missing example name](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_example_name.feature)
|
33
|
+
- [missing feature description](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_feature_description.feature)
|
34
|
+
- [missing feature name](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_feature_name.feature)
|
35
|
+
- [missing scenario name](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_scenario_name.feature)
|
36
|
+
- [missing test action](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_test_action.feature)
|
37
|
+
- [missing verification](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_verification.feature)
|
38
|
+
- [same tag for all scenarios](https://github.com/funkwerk/gherkin_lint/blob/master/features/same_tag_for_all_scenarios.feature)
|
39
|
+
- [too clumsy](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_clumsy.feature)
|
40
|
+
- [too long step](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_long_step.feature)
|
41
|
+
- [too many different tags](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_many_different_tags.feature)
|
42
|
+
- [too many steps](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_many_steps.feature)
|
43
|
+
- [too many tags](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_many_tags.feature)
|
44
|
+
- [unique scenario names](https://github.com/funkwerk/gherkin_lint/blob/master/features/unique_scenario_names.feature)
|
45
|
+
- [unknown variable](https://github.com/funkwerk/gherkin_lint/blob/master/features/unknown_variable.feature)
|
46
|
+
- [use background](https://github.com/funkwerk/gherkin_lint/blob/master/features/use_background.feature)
|
47
|
+
- [use outline](https://github.com/funkwerk/gherkin_lint/blob/master/features/use_outline.feature)
|
48
|
+
|
49
|
+
## Errors and Warnings
|
50
|
+
|
51
|
+
There are errors and warnings.
|
52
|
+
|
53
|
+
### Warnings
|
54
|
+
|
55
|
+
Warnings are for issues that do not influence the returncode. These issues are also for introducing new checks.
|
56
|
+
These new checks will stay some releases as warning and will be later declared as error, to give users the possibility to adapt their codebase.
|
57
|
+
|
58
|
+
### Errors
|
59
|
+
|
60
|
+
If there is at least one error, the returncode will be set to ERROR (!= 0).
|