gherkin_lint 0.6.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +19 -1
  4. data/Dockerfile +2 -0
  5. data/Gemfile +3 -2
  6. data/README.md +24 -2
  7. data/Rakefile +3 -3
  8. data/bin/gherkin_lint +10 -2
  9. data/config/default.yml +58 -0
  10. data/features/avoid_outline_for_single_example.feature +2 -1
  11. data/features/avoid_period.feature +1 -1
  12. data/features/avoid_scripting.feature +1 -1
  13. data/features/background_does_more_than_setup.feature +1 -1
  14. data/features/background_requires_scenario.feature +1 -1
  15. data/features/bad_scenario_name.feature +1 -1
  16. data/features/be_declarative.feature +1 -1
  17. data/features/disable_tags.feature +1 -2
  18. data/features/file_name_differs_feature_name.feature +2 -2
  19. data/features/invalid_file_name.feature +1 -1
  20. data/features/invalid_step_flow.feature +1 -1
  21. data/features/missing_example_name.feature +1 -2
  22. data/features/missing_feature_description.feature +1 -1
  23. data/features/missing_feature_name.feature +1 -1
  24. data/features/missing_scenario_name.feature +1 -1
  25. data/features/missing_test_action.feature +1 -2
  26. data/features/missing_verification.feature +1 -2
  27. data/features/precedence.feature +72 -0
  28. data/features/required_tags_starts_with.feature +95 -0
  29. data/features/same_tag_for_all_scenarios.feature +1 -5
  30. data/features/support/env.rb +72 -0
  31. data/features/tag_used_multiple_times.feature +1 -1
  32. data/features/too_clumsy.feature +1 -1
  33. data/features/too_long_step.feature +1 -1
  34. data/features/too_many_different_tags.feature +1 -1
  35. data/features/too_many_steps.feature +1 -1
  36. data/features/too_many_tags.feature +1 -1
  37. data/features/unique_scenario_names.feature +1 -1
  38. data/features/unknown_variable.feature +1 -1
  39. data/features/unused_variable.feature +1 -1
  40. data/features/use_background.feature +1 -2
  41. data/features/use_outline.feature +1 -2
  42. data/gherkin_lint.gemspec +3 -3
  43. data/lib/gherkin_lint.rb +44 -51
  44. data/lib/gherkin_lint/configuration.rb +32 -0
  45. data/lib/gherkin_lint/issue.rb +1 -1
  46. data/lib/gherkin_lint/linter.rb +6 -10
  47. data/lib/gherkin_lint/linter/avoid_scripting.rb +1 -1
  48. data/lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb +1 -1
  49. data/lib/gherkin_lint/linter/bad_scenario_name.rb +1 -1
  50. data/lib/gherkin_lint/linter/be_declarative.rb +10 -8
  51. data/lib/gherkin_lint/linter/required_tags_starts_with.rb +16 -0
  52. data/lib/gherkin_lint/linter/tag_collector.rb +9 -0
  53. data/lib/gherkin_lint/linter/tag_constraint.rb +32 -0
  54. data/lib/gherkin_lint/linter/too_many_different_tags.rb +3 -0
  55. data/lib/gherkin_lint/linter/too_many_tags.rb +3 -0
  56. data/spec/configuration_spec.rb +58 -0
  57. data/spec/gherkin_lint_spec.rb +68 -0
  58. data/spec/required_tags_starts_with_spec.rb +74 -0
  59. data/spec/shared_contexts/file_exists.rb +12 -0
  60. data/spec/shared_contexts/gherkin_linter.rb +14 -0
  61. metadata +18 -3
@@ -11,6 +11,7 @@ Feature: Missing Feature Name
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(MissingFeatureName)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -37,5 +38,4 @@ Feature: Missing Feature Name
37
38
  When I run `ruby lint.rb`
38
39
  Then it should pass with exactly:
39
40
  """
40
-
41
41
  """
@@ -11,6 +11,7 @@ Feature: Missing Scenario Name
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(MissingScenarioName)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -53,5 +54,4 @@ Feature: Missing Scenario Name
53
54
  When I run `ruby lint.rb`
54
55
  Then it should pass with exactly:
55
56
  """
56
-
57
57
  """
@@ -11,6 +11,7 @@ Feature: Missing Test Action
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(MissingTestAction)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -44,7 +45,6 @@ Feature: Missing Test Action
44
45
  When I run `ruby lint.rb`
45
46
  Then it should pass with exactly:
46
47
  """
47
-
48
48
  """
49
49
 
50
50
  Scenario: Empty Scenario
@@ -56,5 +56,4 @@ Feature: Missing Test Action
56
56
  When I run `ruby lint.rb`
57
57
  Then it should pass with exactly:
58
58
  """
59
-
60
59
  """
@@ -11,6 +11,7 @@ Feature: Missing Verification
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(MissingVerification)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -44,7 +45,6 @@ Feature: Missing Verification
44
45
  When I run `ruby lint.rb`
45
46
  Then it should pass with exactly:
46
47
  """
47
-
48
48
  """
49
49
 
50
50
  Scenario: Empty Scenario
@@ -56,5 +56,4 @@ Feature: Missing Verification
56
56
  When I run `ruby lint.rb`
57
57
  Then it should pass with exactly:
58
58
  """
59
-
60
59
  """
@@ -0,0 +1,72 @@
1
+ Feature: Precedence
2
+ As a User
3
+ I want to be able to turn linters of and on with configuration and CLI
4
+ so that it's easier to enable and disable linters
5
+
6
+ Scenario: Disable With local override
7
+ Given a file named "lint.rb" with:
8
+ """
9
+ $LOAD_PATH << '../../lib'
10
+ require 'gherkin_lint'
11
+
12
+ linter = GherkinLint::GherkinLint.new
13
+ linter.set_linter
14
+ linter.analyze 'lint.feature'
15
+ exit linter.report
16
+
17
+ """
18
+ And a file named ".gherkin_lint.yml" with:
19
+ """
20
+ ---
21
+ AvoidPeriod:
22
+ Enabled: false
23
+ """
24
+ And a file named "lint.feature" with:
25
+ """
26
+ Feature: Lint
27
+ A User can test a feature
28
+ Scenario: A
29
+ Given this is a setup
30
+ When I run the test
31
+ Then I see the verification.
32
+ """
33
+ When I run `ruby lint.rb`
34
+ Then it should pass with exactly:
35
+ """
36
+ """
37
+
38
+ Scenario: Disable on local, Enable on CLI
39
+ Given a file named "lint.rb" with:
40
+ """
41
+ $LOAD_PATH << '../../lib'
42
+ require 'gherkin_lint'
43
+
44
+ linter = GherkinLint::GherkinLint.new
45
+ linter.enable %w(AvoidPeriod)
46
+ linter.set_linter
47
+ linter.analyze 'lint.feature'
48
+ exit linter.report
49
+
50
+ """
51
+ And a file named ".gherkin_lint.yml" with:
52
+ """
53
+ ---
54
+ AvoidPeriod:
55
+ Enabled: false
56
+ """
57
+ And a file named "lint.feature" with:
58
+ """
59
+ Feature: Lint
60
+ A User can test a feature
61
+ Scenario: A
62
+ Given this is a setup
63
+ When I run the test
64
+ Then I see the verification.
65
+ """
66
+ When I run `ruby lint.rb`
67
+ Then it should fail with exactly:
68
+ """
69
+ AvoidPeriod
70
+ lint.feature (6): Lint.A step: I see the verification.
71
+
72
+ """
@@ -0,0 +1,95 @@
1
+ Feature: Required Tags Starts With
2
+ As a tester I dont want to miss certain tags on my scenarios
3
+
4
+ Background: Prepare Testee
5
+ Given a file named ".gherkin_lint.yml" with:
6
+ """
7
+ ---
8
+ RequiredTagsStartsWith:
9
+ Enabled: true
10
+ Matcher: ['PB','MCC']
11
+ """
12
+ And a file named "lint.rb" with:
13
+ """
14
+ $LOAD_PATH << '../../lib'
15
+ require 'gherkin_lint'
16
+
17
+ linter = GherkinLint::GherkinLint.new
18
+ linter.disable_all
19
+ linter.enable %w(RequiredTagsStartsWith)
20
+ linter.set_linter
21
+ linter.analyze 'lint.feature'
22
+ exit linter.report
23
+
24
+ """
25
+ Scenario: Scenario without required tags
26
+ Given a file named "lint.feature" with:
27
+ """
28
+ Feature: Test
29
+ Scenario: A
30
+ When action
31
+ Then verification
32
+ """
33
+ When I run `ruby lint.rb`
34
+ Then it should fail with exactly:
35
+ """
36
+ RequiredTagsStartsWith - Required Tag not found
37
+ lint.feature (2): Test.A
38
+
39
+ """
40
+
41
+ Scenario: Scenario with PB Feature Tag
42
+ Given a file named "lint.feature" with:
43
+ """
44
+ @PB-1234
45
+ Feature: Test
46
+ Scenario: A
47
+ When action
48
+ Then verification
49
+ """
50
+ When I run `ruby lint.rb`
51
+ Then it should pass with exactly:
52
+ """
53
+ """
54
+
55
+ Scenario: Scenario with MCC feature tag
56
+ Given a file named "lint.feature" with:
57
+ """
58
+ @MCC-1234
59
+ Feature: Test
60
+ Scenario: A
61
+ When action
62
+ Then verification
63
+ """
64
+ When I run `ruby lint.rb`
65
+ Then it should pass with exactly:
66
+ """
67
+ """
68
+
69
+ Scenario: Scenario with PR Scenario tag
70
+ Given a file named "lint.feature" with:
71
+ """
72
+ Feature: Test
73
+ @PB-1234
74
+ Scenario: A
75
+ When action
76
+ Then verification
77
+ """
78
+ When I run `ruby lint.rb`
79
+ Then it should pass with exactly:
80
+ """
81
+ """
82
+
83
+ Scenario: Scenario with MCC tags
84
+ Given a file named "lint.feature" with:
85
+ """
86
+ Feature: Test
87
+ @MCC-1234
88
+ Scenario: A
89
+ When action
90
+ Then verification
91
+ """
92
+ When I run `ruby lint.rb`
93
+ Then it should pass with exactly:
94
+ """
95
+ """
@@ -11,6 +11,7 @@ Feature: Same Tag For All Scenarios
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(SameTagForAllScenarios)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -70,7 +71,6 @@ Feature: Same Tag For All Scenarios
70
71
  When I run `ruby lint.rb`
71
72
  Then it should pass with exactly:
72
73
  """
73
-
74
74
  """
75
75
 
76
76
  Scenario: Valid Example with different Tags
@@ -85,7 +85,6 @@ Feature: Same Tag For All Scenarios
85
85
  When I run `ruby lint.rb`
86
86
  Then it should pass with exactly:
87
87
  """
88
-
89
88
  """
90
89
 
91
90
  Scenario: Valid Example with single Tag
@@ -100,7 +99,6 @@ Feature: Same Tag For All Scenarios
100
99
  When I run `ruby lint.rb`
101
100
  Then it should pass with exactly:
102
101
  """
103
-
104
102
  """
105
103
 
106
104
  Scenario: Tags for features with single scenario
@@ -113,7 +111,6 @@ Feature: Same Tag For All Scenarios
113
111
  When I run `ruby lint.rb`
114
112
  Then it should pass with exactly:
115
113
  """
116
-
117
114
  """
118
115
 
119
116
  Scenario: Outline even without Examples
@@ -129,5 +126,4 @@ Feature: Same Tag For All Scenarios
129
126
  When I run `ruby lint.rb`
130
127
  Then it should pass with exactly:
131
128
  """
132
-
133
129
  """
@@ -3,3 +3,75 @@ require 'aruba/cucumber'
3
3
  Before do
4
4
  @aruba_timeout_seconds = 10 # too slow on sloppy machines
5
5
  end
6
+
7
+ After do
8
+ FileUtils.rm_rf('tmp')
9
+ end
10
+
11
+ def disable_linters
12
+ <<-content
13
+ AvoidOutlineForSingleExample:
14
+ Enabled: false
15
+ AvoidPeriod:
16
+ Enabled: false
17
+ AvoidScripting:
18
+ Enabled: false
19
+ BackgroundDoesMoreThanSetup:
20
+ Enabled: false
21
+ BackgroundRequiresMultipleScenarios:
22
+ Enabled: false
23
+ BadScenarioName:
24
+ Enabled: false
25
+ BeDeclarative:
26
+ Enabled: false
27
+ FileNameDiffersFeatureName:
28
+ Enabled: false
29
+ MissingExampleName:
30
+ Enabled: false
31
+ MissingFeatureDescription:
32
+ Enabled: false
33
+ MissingFeatureName:
34
+ Enabled: false
35
+ MissingScenarioName:
36
+ Enabled: false
37
+ MissingTestAction:
38
+ Enabled: false
39
+ MissingVerification:
40
+ Enabled: false
41
+ InvalidFileName:
42
+ Enabled: false
43
+ InvalidStepFlow:
44
+ Enabled: false
45
+ RequiredTagsStartsWith:
46
+ Enabled: false
47
+ SameTagForAllScenarios:
48
+ Enabled: false
49
+ TagUsedMultipleTimes:
50
+ Enabled: false
51
+ TooClumsy:
52
+ Enabled: false
53
+ TooManyDifferentTags:
54
+ Enabled: false
55
+ TooManySteps:
56
+ Enabled: false
57
+ TooManyTags:
58
+ Enabled: false
59
+ TooLongStep:
60
+ Enabled: false
61
+ UniqueScenarioNames:
62
+ Enabled: false
63
+ UnknownVariable:
64
+ Enabled: false
65
+ UnusedVariable:
66
+ Enabled: false
67
+ UseBackground:
68
+ Enabled: false
69
+ UseOutline:
70
+ Enabled: false
71
+ content
72
+ end
73
+
74
+ Before do
75
+ Dir.pwd
76
+ File.open('tmp/aruba/.gherkin_lint.yml', 'w') { |f| f.write disable_linters }
77
+ end
@@ -11,6 +11,7 @@ Feature: Tag Used Multiple Times
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(TagUsedMultipleTimes)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -47,5 +48,4 @@ Feature: Tag Used Multiple Times
47
48
  When I run `ruby lint.rb`
48
49
  Then it should pass with exactly:
49
50
  """
50
-
51
51
  """
@@ -11,6 +11,7 @@ Feature: Too Clumsy
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(TooClumsy)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -53,5 +54,4 @@ Feature: Too Clumsy
53
54
  When I run `ruby lint.rb`
54
55
  Then it should pass with exactly:
55
56
  """
56
-
57
57
  """
@@ -11,6 +11,7 @@ Feature: Too Long Step
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(TooLongStep)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -43,5 +44,4 @@ Feature: Too Long Step
43
44
  When I run `ruby lint.rb`
44
45
  Then it should pass with exactly:
45
46
  """
46
-
47
47
  """
@@ -11,6 +11,7 @@ Feature: Too Many Different Tags
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(TooManyDifferentTags)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -59,5 +60,4 @@ Feature: Too Many Different Tags
59
60
  When I run `ruby lint.rb`
60
61
  Then it should pass with exactly:
61
62
  """
62
-
63
63
  """
@@ -11,6 +11,7 @@ Feature: Too Many Steps
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(TooManySteps)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -53,5 +54,4 @@ Feature: Too Many Steps
53
54
  When I run `ruby lint.rb`
54
55
  Then it should pass with exactly:
55
56
  """
56
-
57
57
  """
@@ -11,6 +11,7 @@ Feature: Too Many Tags
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(TooManyTags)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -43,5 +44,4 @@ Feature: Too Many Tags
43
44
  When I run `ruby lint.rb`
44
45
  Then it should pass with exactly:
45
46
  """
46
-
47
47
  """