gherkin_lint 0.5.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55e2f43b28308b30833c2b07a91ae28e8074c6d6
4
- data.tar.gz: 6a3c3f5df11ae6f61fc79a50c03a53a3838aeeb2
3
+ metadata.gz: 909ea2a079a8f31e840ca9c4dc10559e88e1f8bd
4
+ data.tar.gz: c343b5aa43e0c930b9080de3b4885080c00436ec
5
5
  SHA512:
6
- metadata.gz: e4e3dd19a9559351279e7765618324381513d88e807e7e12f8de3ee8278190641833881432a50d20df19adc6d0358a2641beb874c085df8b24064f0aa5ea1c60
7
- data.tar.gz: 94cbc13a038fefa351f0e18ca93fdd783135f2a15d31d1afdfc86c8f5368098c4395492450394fa2e284e59a2017c2492ac83f82914503abe87a99e5e4254ac4
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
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  desc 'Publishes the Gem'
13
13
  task :push do
14
- sh 'gem push gherkin_lint-0.5.0.gem'
14
+ sh 'gem push gherkin_lint-0.6.0.gem'
15
15
  end
16
16
 
17
17
  desc 'Checks ruby style'
@@ -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
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gherkin_lint'
3
- s.version = '0.5.0'
4
- s.date = '2016-08-31'
3
+ s.version = '0.6.0'
4
+ s.date = '2016-10-14'
5
5
  s.summary = 'Gherkin Lint'
6
6
  s.description = 'Lint Gherkin Files'
7
7
  s.authors = ['Stefan Rohe']
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.5.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-08-31 00:00:00.000000000 Z
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