gherkin_lint 0.1.2 → 0.3.0

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.
Files changed (41) hide show
  1. data/.rubocop.yml +1 -1
  2. data/Gemfile +1 -0
  3. data/README.md +42 -631
  4. data/Rakefile +6 -2
  5. data/features/avoid_scripting.feature +2 -0
  6. data/features/be_declarative.feature +53 -0
  7. data/features/missing_example_name.feature +24 -0
  8. data/features/same_tag_for_all_scenarios.feature +41 -1
  9. data/gherkin_lint.gemspec +3 -2
  10. data/lib/gherkin_lint.rb +10 -4
  11. data/lib/gherkin_lint/issue.rb +13 -0
  12. data/lib/gherkin_lint/linter.rb +15 -11
  13. data/lib/gherkin_lint/linter/avoid_outline_for_single_example.rb +1 -1
  14. data/lib/gherkin_lint/linter/avoid_period.rb +1 -1
  15. data/lib/gherkin_lint/linter/avoid_scripting.rb +1 -1
  16. data/lib/gherkin_lint/linter/background_does_more_than_setup.rb +1 -1
  17. data/lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb +1 -1
  18. data/lib/gherkin_lint/linter/bad_scenario_name.rb +1 -1
  19. data/lib/gherkin_lint/linter/be_declarative.rb +45 -0
  20. data/lib/gherkin_lint/linter/file_name_differs_feature_name.rb +1 -1
  21. data/lib/gherkin_lint/linter/invalid_file_name.rb +1 -1
  22. data/lib/gherkin_lint/linter/invalid_step_flow.rb +3 -3
  23. data/lib/gherkin_lint/linter/missing_example_name.rb +2 -1
  24. data/lib/gherkin_lint/linter/missing_feature_description.rb +1 -1
  25. data/lib/gherkin_lint/linter/missing_feature_name.rb +1 -1
  26. data/lib/gherkin_lint/linter/missing_scenario_name.rb +1 -1
  27. data/lib/gherkin_lint/linter/missing_test_action.rb +1 -1
  28. data/lib/gherkin_lint/linter/missing_verification.rb +1 -1
  29. data/lib/gherkin_lint/linter/same_tag_for_all_scenarios.rb +39 -6
  30. data/lib/gherkin_lint/linter/too_clumsy.rb +1 -1
  31. data/lib/gherkin_lint/linter/too_long_step.rb +1 -1
  32. data/lib/gherkin_lint/linter/too_many_different_tags.rb +2 -2
  33. data/lib/gherkin_lint/linter/too_many_steps.rb +1 -1
  34. data/lib/gherkin_lint/linter/too_many_tags.rb +1 -1
  35. data/lib/gherkin_lint/linter/unique_scenario_names.rb +1 -1
  36. data/lib/gherkin_lint/linter/unknown_variable.rb +1 -1
  37. data/lib/gherkin_lint/linter/unused_variable.rb +1 -1
  38. data/lib/gherkin_lint/linter/use_background.rb +1 -1
  39. data/lib/gherkin_lint/linter/use_outline.rb +1 -1
  40. metadata +43 -15
  41. checksums.yaml +0 -7
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  base = File.basename file
9
9
  next unless base != base.downcase || base =~ /[ -]/
10
10
  references = [reference(file)]
11
- add_issue(references, 'Feature files should be snake_cased')
11
+ add_error(references, 'Feature files should be snake_cased')
12
12
  end
13
13
  end
14
14
  end
@@ -14,7 +14,7 @@ module GherkinLint
14
14
 
15
15
  def last_step_is_an_action(file, feature, scenario, steps)
16
16
  references = [reference(file, feature, scenario, steps.last)]
17
- add_issue(references, 'Last step is an action') if steps.last['keyword'] == 'When '
17
+ add_error(references, 'Last step is an action') if steps.last['keyword'] == 'When '
18
18
  end
19
19
 
20
20
  def given_after_non_given(file, feature, scenario, steps)
@@ -22,7 +22,7 @@ module GherkinLint
22
22
  steps.each do |step|
23
23
  references = [reference(file, feature, scenario, step)]
24
24
  description = 'Given after Action or Verification'
25
- add_issue(references, description) if step['keyword'] == 'Given ' && last_step['keyword'] != 'Given '
25
+ add_error(references, description) if step['keyword'] == 'Given ' && last_step['keyword'] != 'Given '
26
26
  last_step = step
27
27
  end
28
28
  end
@@ -31,7 +31,7 @@ module GherkinLint
31
31
  steps.each do |step|
32
32
  break if step['keyword'] == 'When '
33
33
  references = [reference(file, feature, scenario, step)]
34
- add_issue(references, 'Missing Action') if step['keyword'] == 'Then '
34
+ add_error(references, 'Missing Action') if step['keyword'] == 'Then '
35
35
  end
36
36
  end
37
37
  end
@@ -6,11 +6,12 @@ module GherkinLint
6
6
  def lint
7
7
  scenarios do |file, feature, scenario|
8
8
  next unless scenario.key? 'examples'
9
+ next unless scenario['examples'].length > 1
9
10
  scenario['examples'].each do |example|
10
11
  name = example.key?('name') ? example['name'].strip : ''
11
12
  next unless name.empty?
12
13
  references = [reference(file, feature, scenario)]
13
- add_issue(references, 'No Example Name')
14
+ add_error(references, 'No Example Name')
14
15
  end
15
16
  end
16
17
  end
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  name = feature.key?('description') ? feature['description'].strip : ''
9
9
  next unless name.empty?
10
10
  references = [reference(file, feature)]
11
- add_issue(references, 'Favor a user story as description')
11
+ add_error(references, 'Favor a user story as description')
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  name = feature.key?('name') ? feature['name'].strip : ''
9
9
  next unless name.empty?
10
10
  references = [reference(file, feature)]
11
- add_issue(references, 'No Feature Name')
11
+ add_error(references, 'No Feature Name')
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  name = scenario.key?('name') ? scenario['name'].strip : ''
9
9
  references = [reference(file, feature, scenario)]
10
10
  next unless name.empty?
11
- add_issue(references, 'No Scenario Name')
11
+ add_error(references, 'No Scenario Name')
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  when_steps = scenario['steps'].select { |step| step['keyword'] == 'When ' }
9
9
  next unless when_steps.empty?
10
10
  references = [reference(file, feature, scenario)]
11
- add_issue(references, 'No \'When\'-Step')
11
+ add_error(references, 'No \'When\'-Step')
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  then_steps = scenario['steps'].select { |step| step['keyword'] == 'Then ' }
9
9
  next unless then_steps.empty?
10
10
  references = [reference(file, feature, scenario)]
11
- add_issue(references, 'No verification step')
11
+ add_error(references, 'No verification step')
12
12
  end
13
13
  end
14
14
  end
@@ -5,13 +5,34 @@ module GherkinLint
5
5
  class SameTagForAllScenarios < Linter
6
6
  def lint
7
7
  features do |file, feature|
8
- tags = gather_same_tags feature
9
- next if tags.nil?
10
- next if tags.empty?
11
- next unless feature['elements'].length > 1
12
- references = [reference(file, feature)]
8
+ lint_scenarios file, feature
9
+ lint_examples file, feature
10
+ end
11
+ end
12
+
13
+ def lint_scenarios(file, feature)
14
+ tags = gather_same_tags feature
15
+ return if tags.nil?
16
+ return if tags.length < 1
17
+ return unless feature['elements'].length > 1
18
+ references = [reference(file, feature)]
19
+ tags.each do |tag|
20
+ next if tag == '@skip'
21
+
22
+ add_error(references, "Tag '#{tag}' should be used at Feature level")
23
+ end
24
+ end
25
+
26
+ def lint_examples(file, feature)
27
+ feature['elements'].each do |scenario|
28
+ tags = gather_same_tags_for_outline scenario
29
+ next if tags.nil? || tags.empty?
30
+ next unless scenario['examples'].length > 1
31
+ references = [reference(file, feature, scenario)]
13
32
  tags.each do |tag|
14
- add_issue(references, "Tag '#{tag}' should be used at Feature level")
33
+ next if tag == '@skip'
34
+
35
+ add_error(references, "Tag '#{tag}' should be used at Scenario Outline level")
15
36
  end
16
37
  end
17
38
  end
@@ -28,5 +49,17 @@ module GherkinLint
28
49
  end
29
50
  result
30
51
  end
52
+
53
+ def gather_same_tags_for_outline(scenario)
54
+ result = nil
55
+ return result unless scenario.include? 'examples'
56
+ scenario['examples'].each do |example|
57
+ return nil unless example.include? 'tags'
58
+ tags = example['tags'].map { |tag| tag['name'] }
59
+ result = tags if result.nil?
60
+ result &= tags
61
+ end
62
+ result
63
+ end
31
64
  end
32
65
  end
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  characters = scenario['steps'].map { |step| step['name'].length }.inject(0, :+)
9
9
  next if characters < 400
10
10
  references = [reference(file, feature, scenario)]
11
- add_issue(references, "Used #{characters} Characters")
11
+ add_error(references, "Used #{characters} Characters")
12
12
  end
13
13
  end
14
14
  end
@@ -7,7 +7,7 @@ module GherkinLint
7
7
  steps do |file, feature, scenario, step|
8
8
  next if step['name'].length < 80
9
9
  references = [reference(file, feature, scenario, step)]
10
- add_issue(references, "Used #{step['name'].length} characters")
10
+ add_error(references, "Used #{step['name'].length} characters")
11
11
  end
12
12
  end
13
13
  end
@@ -20,14 +20,14 @@ module GherkinLint
20
20
  tags.uniq!
21
21
  references.uniq!
22
22
  return false unless tags.length >= 3
23
- add_issue(references, "Used #{tags.length} Tags within single Feature")
23
+ add_error(references, "Used #{tags.length} Tags within single Feature")
24
24
  end
25
25
 
26
26
  def warn_across_all_features(references, tags)
27
27
  tags.uniq!
28
28
  references.uniq!
29
29
  return false unless tags.length >= 10
30
- add_issue(references, "Used #{tags.length} Tags across all Features")
30
+ add_error(references, "Used #{tags.length} Tags across all Features")
31
31
  end
32
32
 
33
33
  def tags_for_feature(feature)
@@ -7,7 +7,7 @@ module GherkinLint
7
7
  filled_scenarios do |file, feature, scenario|
8
8
  next if scenario['steps'].length < 10
9
9
  references = [reference(file, feature, scenario)]
10
- add_issue(references, "Used #{scenario['steps'].length} Steps")
10
+ add_error(references, "Used #{scenario['steps'].length} Steps")
11
11
  end
12
12
  end
13
13
  end
@@ -8,7 +8,7 @@ module GherkinLint
8
8
  tags = gather_tags(feature) + gather_tags(scenario)
9
9
  next unless tags.length >= 3
10
10
  references = [reference(file, feature, scenario)]
11
- add_issue(references, "Used #{tags.length} Tags")
11
+ add_error(references, "Used #{tags.length} Tags")
12
12
  end
13
13
  end
14
14
  end
@@ -12,7 +12,7 @@ module GherkinLint
12
12
  end
13
13
  references_by_name.each do |name, references|
14
14
  next if references.length <= 1
15
- add_issue(references, "'#{name}' used #{references.length} times")
15
+ add_error(references, "'#{name}' used #{references.length} times")
16
16
  end
17
17
  end
18
18
  end
@@ -10,7 +10,7 @@ module GherkinLint
10
10
  step_vars(step).each do |used_var|
11
11
  next if known_vars.include? used_var
12
12
  references = [reference(file, feature, scenario)]
13
- add_issue(references, "'<#{used_var}>' is unknown")
13
+ add_error(references, "'<#{used_var}>' is unknown")
14
14
  end
15
15
  end
16
16
  end
@@ -10,7 +10,7 @@ module GherkinLint
10
10
  next unless example.key? 'rows'
11
11
  example['rows'].first['cells'].each do |variable|
12
12
  references = [reference(file, feature, scenario)]
13
- add_issue(references, "'<#{variable}>' is unused") unless used?(variable, scenario)
13
+ add_error(references, "'<#{variable}>' is unused") unless used?(variable, scenario)
14
14
  end
15
15
  end
16
16
  end
@@ -11,7 +11,7 @@ module GherkinLint
11
11
  next if givens.length <= 1
12
12
  next if givens.uniq.length > 1
13
13
  references = [reference(file, feature)]
14
- add_issue(references, "Step '#{givens.uniq.first}' should be part of background")
14
+ add_error(references, "Step '#{givens.uniq.first}' should be part of background")
15
15
  end
16
16
  end
17
17
 
@@ -17,7 +17,7 @@ module GherkinLint
17
17
  similarity = determine_similarity(lhs[:text], rhs[:text])
18
18
  next unless similarity >= 0.95
19
19
  references = [lhs[:reference], rhs[:reference]]
20
- add_issue(references, "Scenarios are similar by #{similarity.round(3) * 100} %")
20
+ add_error(references, "Scenarios are similar by #{similarity.round(3) * 100} %")
21
21
  end
22
22
  end
23
23
 
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Stefan Rohe
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-04-17 00:00:00.000000000 Z
12
+ date: 2016-05-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: gherkin
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - '='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - '='
25
28
  - !ruby/object:Gem::Version
@@ -27,43 +30,65 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: term-ansicolor
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 1.3.2
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 1.3.2
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: amatch
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: 0.3.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - ">="
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: 0.3.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: engtagger
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.2.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.2.0
55
78
  - !ruby/object:Gem::Dependency
56
79
  name: aruba
57
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
58
82
  requirements:
59
- - - ">="
83
+ - - ! '>='
60
84
  - !ruby/object:Gem::Version
61
85
  version: 0.6.2
62
86
  type: :development
63
87
  prerelease: false
64
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
65
90
  requirements:
66
- - - ">="
91
+ - - ! '>='
67
92
  - !ruby/object:Gem::Version
68
93
  version: 0.6.2
69
94
  description: Lint Gherkin Files
@@ -73,8 +98,8 @@ executables:
73
98
  extensions: []
74
99
  extra_rdoc_files: []
75
100
  files:
76
- - ".rubocop.yml"
77
- - ".travis.yml"
101
+ - .rubocop.yml
102
+ - .travis.yml
78
103
  - Dockerfile
79
104
  - Gemfile
80
105
  - Guardfile
@@ -88,6 +113,7 @@ files:
88
113
  - features/background_does_more_than_setup.feature
89
114
  - features/background_requires_scenario.feature
90
115
  - features/bad_scenario_name.feature
116
+ - features/be_declarative.feature
91
117
  - features/disable_tags.feature
92
118
  - features/file_name_differs_feature_name.feature
93
119
  - features/invalid_file_name.feature
@@ -120,6 +146,7 @@ files:
120
146
  - lib/gherkin_lint/linter/background_does_more_than_setup.rb
121
147
  - lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb
122
148
  - lib/gherkin_lint/linter/bad_scenario_name.rb
149
+ - lib/gherkin_lint/linter/be_declarative.rb
123
150
  - lib/gherkin_lint/linter/file_name_differs_feature_name.rb
124
151
  - lib/gherkin_lint/linter/invalid_file_name.rb
125
152
  - lib/gherkin_lint/linter/invalid_step_flow.rb
@@ -142,25 +169,26 @@ files:
142
169
  - lib/gherkin_lint/linter/use_outline.rb
143
170
  homepage: http://github.com/funkwerk/gherkin_lint/
144
171
  licenses: []
145
- metadata: {}
146
172
  post_install_message:
147
173
  rdoc_options: []
148
174
  require_paths:
149
175
  - lib
150
176
  required_ruby_version: !ruby/object:Gem::Requirement
177
+ none: false
151
178
  requirements:
152
- - - ">="
179
+ - - ! '>='
153
180
  - !ruby/object:Gem::Version
154
181
  version: '0'
155
182
  required_rubygems_version: !ruby/object:Gem::Requirement
183
+ none: false
156
184
  requirements:
157
- - - ">="
185
+ - - ! '>='
158
186
  - !ruby/object:Gem::Version
159
187
  version: '0'
160
188
  requirements: []
161
189
  rubyforge_project:
162
- rubygems_version: 2.2.2
190
+ rubygems_version: 1.8.23
163
191
  signing_key:
164
- specification_version: 4
192
+ specification_version: 3
165
193
  summary: Gherkin Lint
166
194
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 55bcc404f41403702960d9d2947515739567023f
4
- data.tar.gz: a26de407f1adb5dfd372da3f4e32a395ff85d20a
5
- SHA512:
6
- metadata.gz: 15112d1f645e2c06b58d9022d44e5004ac38c75c87caf8ba5d2c9776eb1eeabe62f61b05908ca058fe8f7a64736758d2d7e029d1fd673eaae321bf2db073bee4
7
- data.tar.gz: 4c93f4a4e9e479d2f9764ec71e4064d9aa6f50a43a26c7ce511f976c11a0fe5f4b45a4224f1575412c999de9633a2df0934fb4caa587ddecef37f46947b790a8