gherkin_lint 0.0.12 → 0.0.13
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 +4 -4
- data/Dockerfile +5 -0
- data/Gemfile +1 -1
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/features/support/env.rb +1 -1
- data/features/unknown_variable.feature +17 -0
- data/gherkin_lint.gemspec +2 -2
- data/lib/gherkin_lint.rb +13 -14
- data/lib/gherkin_lint/linter.rb +14 -18
- data/lib/gherkin_lint/linter/unknown_variable.rb +6 -10
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f6a87e94f184beadb3e93477e179de06cabd490
|
4
|
+
data.tar.gz: 051d3c873a7089ff9981738391a848cb8b77f7f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b13bf8e881f58d0e5a53d72c5449c4feb17272f065b60d807887047af1a6aba8ebba2ff41692eafe9e76cd6805b97398758048a1ec67ed2f2f597921eee8493
|
7
|
+
data.tar.gz: b96ccffdae892aae560a77c5bc4c4ca9f5ecaa556dbbb46478c1ca775f1bf0f95182c85996f05b939f9268a1608f0df24857f0dec235b574e1606694a07773a8
|
data/Dockerfile
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Lint Gherkin Files
|
2
2
|
|
3
3
|
[](https://travis-ci.org/funkwerk/gherkin_lint)
|
4
|
+
[](https://codeclimate.com/github/funkwerk/gherkin_lint)
|
4
5
|
|
5
6
|
This tool lints gherkin files.
|
6
7
|
|
data/Rakefile
CHANGED
data/features/support/env.rb
CHANGED
@@ -35,6 +35,23 @@ Feature: Unknown Variable
|
|
35
35
|
|
36
36
|
"""
|
37
37
|
|
38
|
+
Scenario: Unknown Step Variable Even For Missing Examples
|
39
|
+
Given a file named "lint.feature" with:
|
40
|
+
"""
|
41
|
+
Feature: Test
|
42
|
+
Scenario Outline: A
|
43
|
+
When <baz> and <bar>
|
44
|
+
"""
|
45
|
+
When I run `ruby lint.rb`
|
46
|
+
Then it should fail with exactly:
|
47
|
+
"""
|
48
|
+
UnknownVariable - '<baz>' is unknown
|
49
|
+
lint.feature (2): Test.A
|
50
|
+
UnknownVariable - '<bar>' is unknown
|
51
|
+
lint.feature (2): Test.A
|
52
|
+
|
53
|
+
"""
|
54
|
+
|
38
55
|
Scenario: Unknown Table Variable
|
39
56
|
Given a file named "lint.feature" with:
|
40
57
|
"""
|
data/gherkin_lint.gemspec
CHANGED
data/lib/gherkin_lint.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
gem 'gherkin', '=2.12.2'
|
2
|
+
|
1
3
|
require 'gherkin/formatter/json_formatter'
|
2
4
|
require 'gherkin/parser/parser'
|
3
5
|
require 'gherkin_lint/linter/avoid_outline_for_single_example'
|
@@ -58,7 +60,7 @@ module GherkinLint
|
|
58
60
|
UnusedVariable,
|
59
61
|
UseBackground,
|
60
62
|
UseOutline
|
61
|
-
]
|
63
|
+
].freeze
|
62
64
|
|
63
65
|
def initialize
|
64
66
|
@files = {}
|
@@ -71,29 +73,26 @@ module GherkinLint
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def enable(enabled_linter)
|
74
|
-
|
75
|
-
enabled_linter = Set.new enabled_linter
|
76
|
-
LINTER.each do |linter|
|
77
|
-
new_linter = linter.new
|
78
|
-
next unless enabled_linter.include? new_linter.class.name.split('::').last
|
79
|
-
register_linter new_linter
|
80
|
-
end
|
76
|
+
set_linter(enabled_linter)
|
81
77
|
end
|
82
78
|
|
83
79
|
def disable(disabled_linter)
|
80
|
+
set_linter([], disabled_linter)
|
81
|
+
end
|
82
|
+
|
83
|
+
def set_linter(enabled_linter, disabled_linter = [])
|
84
84
|
@linter = []
|
85
|
+
enabled_linter = Set.new enabled_linter
|
85
86
|
disabled_linter = Set.new disabled_linter
|
86
87
|
LINTER.each do |linter|
|
87
88
|
new_linter = linter.new
|
88
|
-
|
89
|
-
|
89
|
+
name = new_linter.class.name.split('::').last
|
90
|
+
next unless enabled_linter.include? name
|
91
|
+
next if disabled_linter.include? name
|
92
|
+
@linter.push new_linter
|
90
93
|
end
|
91
94
|
end
|
92
95
|
|
93
|
-
def register_linter(linter)
|
94
|
-
@linter.push linter
|
95
|
-
end
|
96
|
-
|
97
96
|
def analyze(file)
|
98
97
|
@files[file] = parse file
|
99
98
|
end
|
data/lib/gherkin_lint/linter.rb
CHANGED
@@ -24,42 +24,38 @@ module GherkinLint
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def scenarios
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
feature['elements'].each do |scenario|
|
31
|
-
next if scenario['keyword'] == 'Background'
|
32
|
-
yield(file, feature, scenario)
|
33
|
-
end
|
34
|
-
end
|
27
|
+
elements do |file, feature, scenario|
|
28
|
+
next if scenario['keyword'] == 'Background'
|
29
|
+
yield(file, feature, scenario)
|
35
30
|
end
|
36
31
|
end
|
37
32
|
|
38
33
|
def filled_scenarios
|
39
34
|
scenarios do |file, feature, scenario|
|
40
35
|
next unless scenario.include? 'steps'
|
41
|
-
yield(file, feature, scenario)
|
36
|
+
yield(file, feature, scenario)
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
45
40
|
def steps
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
feature['elements'].each do |scenario|
|
50
|
-
next unless scenario.include? 'steps'
|
51
|
-
scenario['steps'].each { |step| yield(file, feature, scenario, step) }
|
52
|
-
end
|
53
|
-
end
|
41
|
+
elements do |file, feature, scenario|
|
42
|
+
next unless scenario.include? 'steps'
|
43
|
+
scenario['steps'].each { |step| yield(file, feature, scenario, step) }
|
54
44
|
end
|
55
45
|
end
|
56
46
|
|
57
47
|
def backgrounds
|
48
|
+
elements do |file, feature, scenario|
|
49
|
+
next unless scenario['keyword'] == 'Background'
|
50
|
+
yield(file, feature, scenario)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def elements
|
58
55
|
@files.each do |file, content|
|
59
56
|
content.each do |feature|
|
60
57
|
next unless feature.key? 'elements'
|
61
58
|
feature['elements'].each do |scenario|
|
62
|
-
next unless scenario['keyword'] == 'Background'
|
63
59
|
yield(file, feature, scenario)
|
64
60
|
end
|
65
61
|
end
|
@@ -5,7 +5,7 @@ module GherkinLint
|
|
5
5
|
class UnknownVariable < Linter
|
6
6
|
def lint
|
7
7
|
filled_scenarios do |file, feature, scenario|
|
8
|
-
known_vars = known_variables scenario
|
8
|
+
known_vars = Set.new known_variables scenario
|
9
9
|
scenario['steps'].each do |step|
|
10
10
|
step_vars(step).each do |used_var|
|
11
11
|
next if known_vars.include? used_var
|
@@ -19,12 +19,9 @@ module GherkinLint
|
|
19
19
|
def step_vars(step)
|
20
20
|
vars = gather_vars step['name']
|
21
21
|
vars += gather_vars step['doc_string']['value'] if step.key? 'doc_string'
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end.flatten
|
26
|
-
end
|
27
|
-
vars
|
22
|
+
vars + (step['rows'] || []).map do |row|
|
23
|
+
row['cells'].map { |value| gather_vars value }.flatten
|
24
|
+
end.flatten
|
28
25
|
end
|
29
26
|
|
30
27
|
def gather_vars(string)
|
@@ -32,11 +29,10 @@ module GherkinLint
|
|
32
29
|
end
|
33
30
|
|
34
31
|
def known_variables(scenario)
|
35
|
-
|
36
|
-
Set.new(scenario['examples'].map do |example|
|
32
|
+
(scenario['examples'] || []).map do |example|
|
37
33
|
next unless example.key? 'rows'
|
38
34
|
example['rows'].first['cells'].map(&:strip)
|
39
|
-
end.flatten
|
35
|
+
end.flatten
|
40
36
|
end
|
41
37
|
end
|
42
38
|
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.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rohe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".rubocop.yml"
|
77
77
|
- ".travis.yml"
|
78
|
+
- Dockerfile
|
78
79
|
- Gemfile
|
79
80
|
- Guardfile
|
80
81
|
- LICENSE
|
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
156
|
version: '0'
|
156
157
|
requirements: []
|
157
158
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.2.
|
159
|
+
rubygems_version: 2.2.5
|
159
160
|
signing_key:
|
160
161
|
specification_version: 4
|
161
162
|
summary: Gherkin Lint
|