gherkin_lint 0.0.14 → 0.1.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 +4 -4
- data/.rubocop.yml +11 -4
- data/README.md +4 -0
- data/Rakefile +1 -1
- data/features/disable_tags.feature +77 -0
- data/gherkin_lint.gemspec +2 -2
- data/lib/gherkin_lint.rb +5 -4
- data/lib/gherkin_lint/linter.rb +35 -1
- 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: 6cdef24fc92e7521e9ca9994e41562dac5afa094
|
4
|
+
data.tar.gz: 707f5a596fb69a69ab80597edc91c0cfdb017f8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ca646959b80d6112965790512885b7aeb86fd32b742d8a0245fbd502e7b6880d296a8ef5c069c7e4d705328732a232bf673c4b54631b15143af944a50c292ca
|
7
|
+
data.tar.gz: fcfc1d844dfafcfa9b40960c991087df43528c7c2482c716d4241044434ddf438001dae287bc48ff43c92d03d7e3cc016108ee19448224f75a150351ef7f0a5f
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,18 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
#
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-02-28 13:48:49 +0100 using RuboCop version 0.36.0.
|
3
4
|
# The point is for the user to remove these configuration records
|
4
5
|
# one by one as the offenses are removed from the code base.
|
5
6
|
# Note that changes in the inspected code, or installation of new
|
6
7
|
# versions of RuboCop, may require this file to be generated again.
|
7
8
|
|
8
|
-
# Offense count:
|
9
|
-
# Configuration parameters:
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: CountComments.
|
11
|
+
Metrics/ClassLength:
|
12
|
+
Max: 116
|
13
|
+
|
14
|
+
# Offense count: 3
|
15
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
16
|
+
# URISchemes: http, https
|
10
17
|
Metrics/LineLength:
|
11
18
|
Max: 118
|
data/README.md
CHANGED
@@ -11,6 +11,10 @@ run `gherkin_lint` on a list of files
|
|
11
11
|
|
12
12
|
gherkin_lint FEATURE_FILES
|
13
13
|
|
14
|
+
With `--disable CHECK` or `--enable CHECK` it's possible to disable respectivly enable program wide checks.
|
15
|
+
|
16
|
+
Checks could be disabled using tags within Feature Files. To do so, add @disableCHECK. Detailed usage within the disable_tags feature.
|
17
|
+
|
14
18
|
## Checks
|
15
19
|
|
16
20
|
### Feature Avoid colon (features/avoid_colon.feature)
|
data/Rakefile
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
Feature: Disable Tags
|
2
|
+
As a Business Analyst
|
3
|
+
I want to disable checks for specific scenarios
|
4
|
+
so that I can have exceptions on the exception, not on the whole code base
|
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(InvalidStepFlow)
|
14
|
+
linter.analyze 'lint.feature'
|
15
|
+
exit linter.report
|
16
|
+
|
17
|
+
"""
|
18
|
+
|
19
|
+
Scenario: Broken
|
20
|
+
Given a file named "lint.feature" with:
|
21
|
+
"""
|
22
|
+
Feature: Test
|
23
|
+
Background: Preparation
|
24
|
+
Given setup
|
25
|
+
|
26
|
+
Scenario: Test
|
27
|
+
Then check
|
28
|
+
When action
|
29
|
+
Given setup
|
30
|
+
"""
|
31
|
+
When I run `ruby lint.rb`
|
32
|
+
Then it should fail with exactly:
|
33
|
+
"""
|
34
|
+
InvalidStepFlow - Given after Action or Verification
|
35
|
+
lint.feature (8): Test.Test step: setup
|
36
|
+
InvalidStepFlow - Missing Action
|
37
|
+
lint.feature (6): Test.Test step: check
|
38
|
+
|
39
|
+
"""
|
40
|
+
|
41
|
+
Scenario: Disable on Scenario Level
|
42
|
+
Given a file named "lint.feature" with:
|
43
|
+
"""
|
44
|
+
Feature: Test
|
45
|
+
Background: Preparation
|
46
|
+
Given setup
|
47
|
+
|
48
|
+
@disableInvalidStepFlow
|
49
|
+
Scenario: Test
|
50
|
+
Then check
|
51
|
+
When action
|
52
|
+
Given setup
|
53
|
+
"""
|
54
|
+
When I run `ruby lint.rb`
|
55
|
+
Then it should pass with exactly:
|
56
|
+
"""
|
57
|
+
|
58
|
+
"""
|
59
|
+
|
60
|
+
Scenario: Disable on Feature Level
|
61
|
+
Given a file named "lint.feature" with:
|
62
|
+
"""
|
63
|
+
@disableInvalidStepFlow
|
64
|
+
Feature: Test
|
65
|
+
Background: Preparation
|
66
|
+
Given setup
|
67
|
+
|
68
|
+
Scenario: Test
|
69
|
+
Then check
|
70
|
+
When action
|
71
|
+
Given setup
|
72
|
+
"""
|
73
|
+
When I run `ruby lint.rb`
|
74
|
+
Then it should pass with exactly:
|
75
|
+
"""
|
76
|
+
|
77
|
+
"""
|
data/gherkin_lint.gemspec
CHANGED
data/lib/gherkin_lint.rb
CHANGED
@@ -77,7 +77,7 @@ module GherkinLint
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def disable(disabled_linter)
|
80
|
-
set_linter(
|
80
|
+
set_linter(LINTER.map { |linter| linter.new.name.split('::').last }, disabled_linter)
|
81
81
|
end
|
82
82
|
|
83
83
|
def set_linter(enabled_linter, disabled_linter = [])
|
@@ -104,13 +104,14 @@ module GherkinLint
|
|
104
104
|
|
105
105
|
def report
|
106
106
|
issues = @linter.map do |linter|
|
107
|
-
|
107
|
+
tags_to_suppress = LINTER.map { |lint| "disable#{lint.new.class.name.split('::').last}" }
|
108
|
+
linter.lint_files(@files, tags_to_suppress)
|
108
109
|
linter.issues
|
109
110
|
end.flatten
|
110
111
|
|
111
112
|
issues.each { |issue| puts issue.render }
|
112
|
-
|
113
|
-
-1
|
113
|
+
|
114
|
+
issues.empty? ? 0 : -1
|
114
115
|
end
|
115
116
|
|
116
117
|
def to_json(input, file = 'generated.feature')
|
data/lib/gherkin_lint/linter.rb
CHANGED
@@ -66,11 +66,45 @@ module GherkinLint
|
|
66
66
|
self.class.name.split('::').last
|
67
67
|
end
|
68
68
|
|
69
|
-
def lint_files(files)
|
69
|
+
def lint_files(files, tags_to_suppress)
|
70
70
|
@files = files
|
71
|
+
@files = filter_tag(@files, "disable#{name}")
|
72
|
+
@files = suppress_tags(@files, tags_to_suppress)
|
71
73
|
lint
|
72
74
|
end
|
73
75
|
|
76
|
+
def tag?(data, tag)
|
77
|
+
return false if data.class != Hash
|
78
|
+
return false unless data.key? 'tags'
|
79
|
+
data['tags'].map { |item| item['name'] }.include? "@#{tag}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def filter_tag(data, tag)
|
83
|
+
return data.select { |item| !tag?(item, tag) }.map { |item| filter_tag(item, tag) } if data.class == Array
|
84
|
+
return data unless data.class == Hash
|
85
|
+
result = {}
|
86
|
+
|
87
|
+
data.each_pair { |key, value| result[key] = filter_tag(value, tag) }
|
88
|
+
result
|
89
|
+
end
|
90
|
+
|
91
|
+
def suppress(data, tags)
|
92
|
+
data.select { |item| !tags.map { |tag| "@#{tag}" }.include? item['name'] }
|
93
|
+
end
|
94
|
+
|
95
|
+
def suppress_tags(data, tags)
|
96
|
+
return data.map { |item| suppress_tags(item, tags) } if data.class == Array
|
97
|
+
return data unless data.class == Hash
|
98
|
+
result = {}
|
99
|
+
|
100
|
+
data.each_pair do |key, value|
|
101
|
+
value = suppress(value, tags) if key == 'tags'
|
102
|
+
|
103
|
+
result[key] = suppress_tags(value, tags)
|
104
|
+
end
|
105
|
+
result
|
106
|
+
end
|
107
|
+
|
74
108
|
def lint
|
75
109
|
fail 'not implemented'
|
76
110
|
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.1.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-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- features/background_does_more_than_setup.feature
|
88
88
|
- features/background_requires_scenario.feature
|
89
89
|
- features/bad_scenario_name.feature
|
90
|
+
- features/disable_tags.feature
|
90
91
|
- features/file_name_differs_feature_name.feature
|
91
92
|
- features/invalid_file_name.feature
|
92
93
|
- features/invalid_step_flow.feature
|
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
157
|
version: '0'
|
157
158
|
requirements: []
|
158
159
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.2.
|
160
|
+
rubygems_version: 2.2.2
|
160
161
|
signing_key:
|
161
162
|
specification_version: 4
|
162
163
|
summary: Gherkin Lint
|