gherkin_lint 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -2
- data/Rakefile +1 -1
- data/features/avoid_scripting.feature +67 -0
- data/features/invalid_file_name.feature +0 -1
- data/gherkin_lint.gemspec +2 -2
- data/lib/gherkin_lint.rb +2 -0
- data/lib/gherkin_lint/linter.rb +1 -1
- data/lib/gherkin_lint/linter/avoid_scripting.rb +22 -0
- data/lib/gherkin_lint/linter/file_name_differs_feature_name.rb +1 -1
- data/lib/gherkin_lint/linter/missing_test_action.rb +1 -1
- data/lib/gherkin_lint/linter/missing_verification.rb +1 -1
- data/lib/gherkin_lint/linter/same_tag_for_all_scenarios.rb +1 -1
- 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: 55bcc404f41403702960d9d2947515739567023f
|
4
|
+
data.tar.gz: a26de407f1adb5dfd372da3f4e32a395ff85d20a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15112d1f645e2c06b58d9022d44e5004ac38c75c87caf8ba5d2c9776eb1eeabe62f61b05908ca058fe8f7a64736758d2d7e029d1fd673eaae321bf2db073bee4
|
7
|
+
data.tar.gz: 4c93f4a4e9e479d2f9764ec71e4064d9aa6f50a43a26c7ce511f976c11a0fe5f4b45a4224f1575412c999de9633a2df0934fb4caa587ddecef37f46947b790a8
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2016-02-28
|
3
|
+
# on 2016-02-28 15:30:26 +0100 using RuboCop version 0.37.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -11,8 +11,14 @@
|
|
11
11
|
Metrics/ClassLength:
|
12
12
|
Max: 116
|
13
13
|
|
14
|
-
# Offense count:
|
14
|
+
# Offense count: 28
|
15
15
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
16
16
|
# URISchemes: http, https
|
17
17
|
Metrics/LineLength:
|
18
18
|
Max: 118
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
# Cop supports --auto-correct.
|
22
|
+
Performance/Casecmp:
|
23
|
+
Exclude:
|
24
|
+
- 'lib/gherkin_lint/linter/invalid_file_name.rb'
|
data/Rakefile
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
Feature: Avoid Scripting
|
2
|
+
As a Business Analyst
|
3
|
+
I want to be warned about scripted tests
|
4
|
+
so that all my tests follow the guideline of single action per scenario.
|
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(AvoidScripting)
|
14
|
+
linter.analyze 'lint.feature'
|
15
|
+
exit linter.report
|
16
|
+
|
17
|
+
"""
|
18
|
+
|
19
|
+
Scenario: Multiple Actions
|
20
|
+
Given a file named "lint.feature" with:
|
21
|
+
"""
|
22
|
+
Feature: Test
|
23
|
+
Scenario: A
|
24
|
+
Given setup
|
25
|
+
When action
|
26
|
+
And something else
|
27
|
+
Then verify
|
28
|
+
"""
|
29
|
+
When I run `ruby lint.rb`
|
30
|
+
Then it should fail with exactly:
|
31
|
+
"""
|
32
|
+
AvoidScripting - Multiple Actions
|
33
|
+
lint.feature (2): Test.A
|
34
|
+
"""
|
35
|
+
|
36
|
+
Scenario: Repeat Action-Verfication Steps
|
37
|
+
Given a file named "lint.feature" with:
|
38
|
+
"""
|
39
|
+
Feature: Test
|
40
|
+
Scenario: A
|
41
|
+
Given setup
|
42
|
+
When test
|
43
|
+
Then verify
|
44
|
+
When test
|
45
|
+
Then verify
|
46
|
+
"""
|
47
|
+
When I run `ruby lint.rb`
|
48
|
+
Then it should fail with exactly:
|
49
|
+
"""
|
50
|
+
AvoidScripting - Multiple Actions
|
51
|
+
lint.feature (2): Test.A
|
52
|
+
"""
|
53
|
+
|
54
|
+
Scenario: Valid Example
|
55
|
+
Given a file named "lint.feature" with:
|
56
|
+
"""
|
57
|
+
Feature: Test
|
58
|
+
Scenario: A
|
59
|
+
Given setup
|
60
|
+
When test
|
61
|
+
Then verification
|
62
|
+
"""
|
63
|
+
When I run `ruby lint.rb`
|
64
|
+
Then it should pass with exactly:
|
65
|
+
"""
|
66
|
+
|
67
|
+
"""
|
data/gherkin_lint.gemspec
CHANGED
data/lib/gherkin_lint.rb
CHANGED
@@ -4,6 +4,7 @@ require 'gherkin/formatter/json_formatter'
|
|
4
4
|
require 'gherkin/parser/parser'
|
5
5
|
require 'gherkin_lint/linter/avoid_outline_for_single_example'
|
6
6
|
require 'gherkin_lint/linter/avoid_period'
|
7
|
+
require 'gherkin_lint/linter/avoid_scripting'
|
7
8
|
require 'gherkin_lint/linter/background_does_more_than_setup'
|
8
9
|
require 'gherkin_lint/linter/background_requires_multiple_scenarios'
|
9
10
|
require 'gherkin_lint/linter/bad_scenario_name'
|
@@ -36,6 +37,7 @@ module GherkinLint
|
|
36
37
|
class GherkinLint
|
37
38
|
LINTER = [
|
38
39
|
AvoidPeriod,
|
40
|
+
AvoidScripting,
|
39
41
|
AvoidOutlineForSingleExample,
|
40
42
|
BackgroundDoesMoreThanSetup,
|
41
43
|
BackgroundRequiresMultipleScenarios,
|
data/lib/gherkin_lint/linter.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'gherkin_lint/linter'
|
2
|
+
|
3
|
+
module GherkinLint
|
4
|
+
# service class to lint for avoid scripting
|
5
|
+
class AvoidScripting < Linter
|
6
|
+
def lint
|
7
|
+
filled_scenarios do |file, feature, scenario|
|
8
|
+
steps = filter_when_steps scenario['steps']
|
9
|
+
|
10
|
+
next if steps.length <= 1
|
11
|
+
references = [reference(file, feature, scenario)]
|
12
|
+
add_issue(references, 'Multiple Actions')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def filter_when_steps(steps)
|
17
|
+
steps = steps.drop_while { |step| step['keyword'] != 'When ' }
|
18
|
+
steps = steps.reverse.drop_while { |step| step['keyword'] != 'Then ' }.reverse
|
19
|
+
steps.select { |step| step['keyword'] != 'Then ' }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -7,7 +7,7 @@ module GherkinLint
|
|
7
7
|
features do |file, feature|
|
8
8
|
next unless feature.include? 'name'
|
9
9
|
expected_feature_name = title_case file
|
10
|
-
next
|
10
|
+
next if feature['name'].casecmp(expected_feature_name) == 0
|
11
11
|
references = [reference(file, feature)]
|
12
12
|
add_issue(references, "Feature name should be '#{expected_feature_name}'")
|
13
13
|
end
|
@@ -6,7 +6,7 @@ module GherkinLint
|
|
6
6
|
def lint
|
7
7
|
filled_scenarios do |file, feature, scenario|
|
8
8
|
when_steps = scenario['steps'].select { |step| step['keyword'] == 'When ' }
|
9
|
-
next
|
9
|
+
next unless when_steps.empty?
|
10
10
|
references = [reference(file, feature, scenario)]
|
11
11
|
add_issue(references, 'No \'When\'-Step')
|
12
12
|
end
|
@@ -6,7 +6,7 @@ module GherkinLint
|
|
6
6
|
def lint
|
7
7
|
filled_scenarios do |file, feature, scenario|
|
8
8
|
then_steps = scenario['steps'].select { |step| step['keyword'] == 'Then ' }
|
9
|
-
next
|
9
|
+
next unless then_steps.empty?
|
10
10
|
references = [reference(file, feature, scenario)]
|
11
11
|
add_issue(references, 'No verification step')
|
12
12
|
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.1.
|
4
|
+
version: 0.1.2
|
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-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- bin/gherkin_lint
|
85
85
|
- features/avoid_outline_for_single_example.feature
|
86
86
|
- features/avoid_period.feature
|
87
|
+
- features/avoid_scripting.feature
|
87
88
|
- features/background_does_more_than_setup.feature
|
88
89
|
- features/background_requires_scenario.feature
|
89
90
|
- features/bad_scenario_name.feature
|
@@ -115,6 +116,7 @@ files:
|
|
115
116
|
- lib/gherkin_lint/linter.rb
|
116
117
|
- lib/gherkin_lint/linter/avoid_outline_for_single_example.rb
|
117
118
|
- lib/gherkin_lint/linter/avoid_period.rb
|
119
|
+
- lib/gherkin_lint/linter/avoid_scripting.rb
|
118
120
|
- lib/gherkin_lint/linter/background_does_more_than_setup.rb
|
119
121
|
- lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb
|
120
122
|
- lib/gherkin_lint/linter/bad_scenario_name.rb
|