gherkin_lint 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/features/tag_used_multiple_times.feature +51 -0
- data/gherkin_lint.gemspec +2 -2
- data/lib/gherkin_lint.rb +2 -0
- data/lib/gherkin_lint/linter/tag_used_multiple_times.rb +21 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 909ea2a079a8f31e840ca9c4dc10559e88e1f8bd
|
4
|
+
data.tar.gz: c343b5aa43e0c930b9080de3b4885080c00436ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bb488ace7530e0174c56fac9f0a2417662d3f2046dd063aae55d90b3553ae383c032ade3276db80899a6bda369c2f998f64b55262482502ac788f117f1359cc
|
7
|
+
data.tar.gz: b32dfc103df0d73c7dfcec87c9fed96548c5d593261cad1146de8c48390b4a9806c166f1b35033f1a44c713516bf285f6855d0ea2f0258ca5eee34c3bc80de1d
|
data/README.md
CHANGED
@@ -36,6 +36,7 @@ Detailed usage within the [disable_tags](https://github.com/funkwerk/gherkin_lin
|
|
36
36
|
- [missing test action](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_test_action.feature)
|
37
37
|
- [missing verification](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_verification.feature)
|
38
38
|
- [same tag for all scenarios](https://github.com/funkwerk/gherkin_lint/blob/master/features/same_tag_for_all_scenarios.feature)
|
39
|
+
- [tag used multiple times](https://github.com/funkwerk/gherkin_lint/blob/master/features/tag_used_multiple_times.feature)
|
39
40
|
- [too clumsy](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_clumsy.feature)
|
40
41
|
- [too long step](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_long_step.feature)
|
41
42
|
- [too many different tags](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_many_different_tags.feature)
|
data/Rakefile
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
Feature: Tag Used Multiple Times
|
2
|
+
As a Business Analyst
|
3
|
+
I want to use tags just once
|
4
|
+
so that redundancy is minimized.
|
5
|
+
|
6
|
+
Background: Prepare Testee
|
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.enable %w(TagUsedMultipleTimes)
|
14
|
+
linter.analyze 'lint.feature'
|
15
|
+
exit linter.report
|
16
|
+
|
17
|
+
"""
|
18
|
+
|
19
|
+
Scenario Outline: Tag used twice
|
20
|
+
Given a file named "lint.feature" with:
|
21
|
+
"""
|
22
|
+
<feature tag>
|
23
|
+
Feature: Test
|
24
|
+
@tag <scenario tag>
|
25
|
+
Scenario: A
|
26
|
+
"""
|
27
|
+
When I run `ruby lint.rb`
|
28
|
+
Then it should fail with exactly:
|
29
|
+
"""
|
30
|
+
TagUsedMultipleTimes - Tag @tag used multiple times
|
31
|
+
lint.feature (4): Test.A
|
32
|
+
|
33
|
+
"""
|
34
|
+
|
35
|
+
Examples: Invalid Tag Combinations
|
36
|
+
| feature tag | scenario tag |
|
37
|
+
| @tag | |
|
38
|
+
| | @tag |
|
39
|
+
|
40
|
+
Scenario: Just unique tags
|
41
|
+
Given a file named "lint.feature" with:
|
42
|
+
"""
|
43
|
+
Feature: Test
|
44
|
+
@tag_a @tag_b
|
45
|
+
Scenario: A
|
46
|
+
"""
|
47
|
+
When I run `ruby lint.rb`
|
48
|
+
Then it should pass with exactly:
|
49
|
+
"""
|
50
|
+
|
51
|
+
"""
|
data/gherkin_lint.gemspec
CHANGED
data/lib/gherkin_lint.rb
CHANGED
@@ -18,6 +18,7 @@ require 'gherkin_lint/linter/missing_scenario_name'
|
|
18
18
|
require 'gherkin_lint/linter/missing_test_action'
|
19
19
|
require 'gherkin_lint/linter/missing_verification'
|
20
20
|
require 'gherkin_lint/linter/same_tag_for_all_scenarios'
|
21
|
+
require 'gherkin_lint/linter/tag_used_multiple_times'
|
21
22
|
require 'gherkin_lint/linter/too_clumsy'
|
22
23
|
require 'gherkin_lint/linter/too_long_step'
|
23
24
|
require 'gherkin_lint/linter/too_many_different_tags'
|
@@ -52,6 +53,7 @@ module GherkinLint
|
|
52
53
|
InvalidFileName,
|
53
54
|
InvalidStepFlow,
|
54
55
|
SameTagForAllScenarios,
|
56
|
+
TagUsedMultipleTimes,
|
55
57
|
TooClumsy,
|
56
58
|
TooManyDifferentTags,
|
57
59
|
TooManySteps,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'gherkin_lint/linter'
|
2
|
+
|
3
|
+
module GherkinLint
|
4
|
+
# service class to lint for tags used multiple times
|
5
|
+
class TagUsedMultipleTimes < Linter
|
6
|
+
def lint
|
7
|
+
scenarios do |file, feature, scenario|
|
8
|
+
references = [reference(file, feature, scenario)]
|
9
|
+
total_tags = tags(feature) + tags(scenario)
|
10
|
+
double_used_tags = total_tags.find_all { |a| total_tags.count(a) > 1 }.uniq!
|
11
|
+
next if double_used_tags.nil?
|
12
|
+
add_error(references, "Tag #{double_used_tags.join(' and ')} used multiple times")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def tags(element)
|
17
|
+
return [] unless element.include? :tags
|
18
|
+
element[:tags].map { |a| a[:name] }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gherkin_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rohe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- features/missing_verification.feature
|
116
116
|
- features/same_tag_for_all_scenarios.feature
|
117
117
|
- features/support/env.rb
|
118
|
+
- features/tag_used_multiple_times.feature
|
118
119
|
- features/too_clumsy.feature
|
119
120
|
- features/too_long_step.feature
|
120
121
|
- features/too_many_different_tags.feature
|
@@ -146,6 +147,7 @@ files:
|
|
146
147
|
- lib/gherkin_lint/linter/missing_test_action.rb
|
147
148
|
- lib/gherkin_lint/linter/missing_verification.rb
|
148
149
|
- lib/gherkin_lint/linter/same_tag_for_all_scenarios.rb
|
150
|
+
- lib/gherkin_lint/linter/tag_used_multiple_times.rb
|
149
151
|
- lib/gherkin_lint/linter/too_clumsy.rb
|
150
152
|
- lib/gherkin_lint/linter/too_long_step.rb
|
151
153
|
- lib/gherkin_lint/linter/too_many_different_tags.rb
|