chutney 2.0.2 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rufo +1 -0
- data/README.md +2 -1
- data/chutney.gemspec +2 -1
- data/config/chutney.yml +4 -0
- data/docs/index.md +2 -2
- data/docs/installation.md +2 -2
- data/docs/usage/configuration.md +2 -2
- data/docs/usage/rules.md +37 -31
- data/lib/chutney.rb +11 -9
- data/lib/chutney/linter.rb +11 -6
- data/lib/chutney/linter/avoid_typographers_quotes.rb +37 -0
- data/lib/chutney/linter/empty_feature_file.rb +8 -0
- data/lib/chutney/linter/file_name_differs_feature_name.rb +1 -1
- data/lib/chutney/linter/missing_feature_description.rb +2 -0
- data/lib/chutney/linter/missing_feature_name.rb +2 -0
- data/lib/chutney/linter/same_tag_for_all_scenarios.rb +2 -2
- data/lib/chutney/linter/too_many_different_tags.rb +1 -1
- data/lib/chutney/linter/use_outline.rb +1 -1
- data/lib/chutney/version.rb +1 -1
- data/lib/config/locales/en.yml +6 -0
- metadata +24 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad43c930f710e8cac21960ff14f31da2fb4fe373ed2153fa3ad238b317ebaedd
|
4
|
+
data.tar.gz: 84e96dd0222e18b3ba9f5235e81598accc0e254f1997211c69d7b6fb19532957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d26227a05a2087610a64557529f85b2b26afca8b3c273a63203710a65b8640497f7bf5f1aeb19c7572af2b2d4f2487b3e1eb6cf372c7f53bf00a526acd35260
|
7
|
+
data.tar.gz: a1f32beace478affe4d3ce7a270f9bd411567b9adb421aef0279b495824cdb35236915f7ea8f388b91d826a62a4cb0040041847694679653d4ebc9e0cb7bb665
|
data/.rufo
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
quote_style :single
|
data/README.md
CHANGED
@@ -12,10 +12,11 @@
|
|
12
12
|
<div align="center">
|
13
13
|
|
14
14
|
[![Gem Version](https://badge.fury.io/rb/chutney.svg)](https://badge.fury.io/rb/chutney)
|
15
|
+
[![Downloads](https://img.shields.io/gem/dt/chutney)](https://rubygems.org/gems/chutney)
|
15
16
|
![CircleCI branch](https://img.shields.io/circleci/project/github/BillyRuffian/chutney/master.svg?style=flat-square)
|
16
17
|
[![CodeFactor](https://www.codefactor.io/repository/github/billyruffian/chutney/badge?style=flat-square)](https://www.codefactor.io/repository/github/billyruffian/chutney)
|
17
18
|
![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/BillyRuffian/chutney.svg?style=flat-square)
|
18
19
|
|
19
20
|
</div>
|
20
21
|
|
21
|
-
Read the documentation [here](https://billyruffian.github.io/chutney/).
|
22
|
+
Read the documentation [here](https://billyruffian.github.io/chutney/).
|
data/chutney.gemspec
CHANGED
@@ -51,10 +51,11 @@ Gem::Specification.new do |spec|
|
|
51
51
|
|
52
52
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
53
53
|
spec.add_development_dependency 'cucumber', '~> 3.0'
|
54
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.0'
|
54
55
|
spec.add_development_dependency 'rake', '~> 13.0'
|
55
56
|
spec.add_development_dependency 'rerun', '~> 0.13'
|
56
57
|
spec.add_development_dependency 'rspec-expectations', '~> 3.0'
|
57
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
58
|
+
spec.add_development_dependency 'rubocop', '~> 0.89.0'
|
58
59
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
59
60
|
|
60
61
|
end
|
data/config/chutney.yml
CHANGED
@@ -4,12 +4,16 @@ AvoidFullStop:
|
|
4
4
|
Enabled: true
|
5
5
|
AvoidScripting:
|
6
6
|
Enabled: true
|
7
|
+
AvoidTypographersQuotes:
|
8
|
+
Enabled: true
|
7
9
|
BackgroundDoesMoreThanSetup:
|
8
10
|
Enabled: true
|
9
11
|
BackgroundRequiresMultipleScenarios:
|
10
12
|
Enabled: true
|
11
13
|
BadScenarioName:
|
12
14
|
Enabled: true
|
15
|
+
EmptyFeatureFile:
|
16
|
+
Enabled: true
|
13
17
|
FileNameDiffersFeatureName:
|
14
18
|
Enabled: true
|
15
19
|
GivensAfterBackground:
|
data/docs/index.md
CHANGED
@@ -5,7 +5,7 @@ nav_order: 1
|
|
5
5
|
permalink: /
|
6
6
|
---
|
7
7
|
|
8
|
-
# Best practice for
|
8
|
+
# Best practice for Cucumber
|
9
9
|
{: .fs-9 }
|
10
10
|
|
11
11
|
|
@@ -18,4 +18,4 @@ You're trying to follow TDD or ATDD principles, you're writing executable specif
|
|
18
18
|
|
19
19
|
Cucumber itself is an awesome tool which bridges with gap between business language, software development language and the language of testers. With all these folks interested, it's easy to write problematic and hard to maintain features. Chutney tries to help with that by having a common set of quality rules for your feature files.
|
20
20
|
|
21
|
-
Chutney is able to lint feature files in any spoken language supported by Cucumber 3.
|
21
|
+
Chutney is able to lint feature files in any spoken language supported by Cucumber 3.
|
data/docs/installation.md
CHANGED
@@ -9,7 +9,7 @@ nav_order: 2
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem '
|
12
|
+
gem 'chutney', require: false
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -18,4 +18,4 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install chutney
|
21
|
+
$ gem install chutney
|
data/docs/usage/configuration.md
CHANGED
@@ -7,6 +7,6 @@ nav_order: 3
|
|
7
7
|
|
8
8
|
# Configuration
|
9
9
|
|
10
|
-
Chutney looks for a configuration file in the current directory called `config
|
10
|
+
Chutney looks for a configuration file in the current directory called `config/.chutney.yml`. This configuration mostly switches on individual linters globally, but a few have addition parameters which can be configured (e.g. the maximum characters in a step).
|
11
11
|
|
12
|
-
A default configuration can be found [here](https://github.com/BillyRuffian/chutney/blob/master/config/
|
12
|
+
A default configuration can be found [here](https://github.com/BillyRuffian/chutney/blob/master/config/chutney.yml).
|
data/docs/usage/rules.md
CHANGED
@@ -9,92 +9,98 @@ nav_order: 2
|
|
9
9
|
|
10
10
|
Chutney enforces its rules with the linters. These are:
|
11
11
|
|
12
|
-
AvoidFullStop
|
12
|
+
[AvoidFullStop](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_full_stop.feature)
|
13
13
|
: Don't have a full stop (period) at the end of step because it makes step reuse really hard.
|
14
14
|
|
15
|
-
AvoidOutlineForSingleExample
|
15
|
+
[AvoidOutlineForSingleExample](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_outline_for_single_example.feature)
|
16
16
|
: If you only have a single example in your example table, use a plain-old scenario instead.
|
17
17
|
|
18
|
-
AvoidScripting
|
18
|
+
[AvoidScripting](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_scripting.feature)
|
19
19
|
: You have a lot of steps, are you sure you're not scripting the scenario when you should be specifying the behaviour of the system?
|
20
20
|
|
21
|
-
|
21
|
+
[AvoidTypographersQuotes](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_typographers_quotes.feature)
|
22
|
+
: Cutting and pasting from Word documents? Is that pasting in curly-quotes instead of neutral ones you would type on a keyboard? Are you sure that's what you want?
|
23
|
+
|
24
|
+
[BackgroundDoesMoreThanSetup](https://github.com/BillyRuffian/chutney/blob/master/features/background_does_more_than_setup.feature)
|
22
25
|
: Background in feature files should only do setup activity and so they should only contain `Given` steps.
|
23
26
|
|
24
|
-
BackgroundRequiresMultipleScenarios
|
27
|
+
[BackgroundRequiresMultipleScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/background_requires_multiple_scenarios.feature)
|
25
28
|
: If you only have one scenario, don't bother having a Background section.
|
26
29
|
|
27
|
-
BadScenarioName
|
30
|
+
[BadScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/bad_scenario_name.feature)
|
28
31
|
: You should avoid using words like 'test' or 'check' in your scenario names, instead you should define the behaviour of your system.
|
29
32
|
|
30
|
-
|
33
|
+
[EmptyFeatureFile](https://github.com/BillyRuffian/chutney/blob/master/features/empty_feature_file.feature)
|
34
|
+
: The feature should have content and should avoid committing empty features to repositories.
|
35
|
+
|
36
|
+
[FileNameDiffersFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/file_name_differs_feature_name.feature)
|
31
37
|
: The feature should have a name that follows the file name.
|
32
38
|
|
33
|
-
GivensAfterBackground
|
39
|
+
[GivensAfterBackground](https://github.com/BillyRuffian/chutney/blob/master/features/givens_after_background.feature)
|
34
40
|
: If you have a Background section and your scenario needs more preconditions then it should start immediately with an `And` step and not another `Given`.
|
35
41
|
|
36
|
-
InvalidFileName
|
42
|
+
[InvalidFileName](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_file_name.feature)
|
37
43
|
: Make sure your file name is in snake case, not mixed case or with spaces.
|
38
44
|
|
39
|
-
InvalidStepFlow
|
45
|
+
[InvalidStepFlow](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_step_flow.feature)
|
40
46
|
: Your scenarios should follow Given → When → Then, in that order.
|
41
47
|
|
42
|
-
MissingExampleName
|
48
|
+
[MissingExampleName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_example_name.feature)
|
43
49
|
: If you have more than one example table in your scenario, they should each be given unique names.
|
44
50
|
|
45
|
-
MissingFeatureDescription
|
51
|
+
[MissingFeatureDescription](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_description.feature)
|
46
52
|
: Your feature should have a value statement. These are usually in the form 'As a... I want.. So that...'.
|
47
53
|
|
48
|
-
MissingFeatureName
|
54
|
+
[MissingFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_name.feature)
|
49
55
|
: You should give your features a descriptive name.
|
50
56
|
|
51
|
-
MissingScenarioName
|
57
|
+
[MissingScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_scenario_name.feature)
|
52
58
|
: You should name your scenarios and scenario outlines.
|
53
59
|
|
54
|
-
MissingTestAction
|
60
|
+
[MissingTestAction](https://github.com/BillyRuffian/chutney/blob/master/features/missing_test_action.feature)
|
55
61
|
: You don't have an action (a `When` step) in your scenario.
|
56
62
|
|
57
|
-
MissingVerification
|
63
|
+
[MissingVerification](https://github.com/BillyRuffian/chutney/blob/master/features/missing_verification.feature)
|
58
64
|
: You don't have a verification step (a `Then` step) in your scenario.
|
59
65
|
|
60
|
-
RequiredTagsStartWith
|
66
|
+
[RequiredTagsStartWith](https://github.com/BillyRuffian/chutney/blob/master/features/required_tags_starts_with.feature)
|
61
67
|
: Chutney can enforce a configurable naming prefix for your tags.
|
62
68
|
|
63
|
-
SameTagForAllScenarios
|
69
|
+
[SameTagForAllScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/same_tag_for_all_scenarios.feature)
|
64
70
|
: You have the same tag for all you scenarios; move the tag to the feature level instead.
|
65
71
|
|
66
|
-
ScenarioNamesMatch
|
72
|
+
[ScenarioNamesMatch](https://github.com/BillyRuffian/chutney/blob/master/features/scenario_names_match.feature)
|
67
73
|
: Chutney can enforce a naming convention for your scenario names.
|
68
74
|
|
69
|
-
TagUsedMultipleTimes
|
75
|
+
[TagUsedMultipleTimes](https://github.com/BillyRuffian/chutney/blob/master/features/tag_used_multiple_times.feature)
|
70
76
|
: Chutney can warn if you have used a tag a lot with a feature.
|
71
77
|
|
72
|
-
TooClumsy
|
78
|
+
[TooClumsy](https://github.com/BillyRuffian/chutney/blob/master/features/too_clumsy.feature)
|
73
79
|
: This is a very long scenario. Consider writing it more concisely.
|
74
80
|
|
75
|
-
TooLongStep
|
81
|
+
[TooLongStep](https://github.com/BillyRuffian/chutney/blob/master/features/too_long_step.feature)
|
76
82
|
: This is a very long step. Consider writing it more concisely.
|
77
83
|
|
78
|
-
TooManyDifferentTags
|
79
|
-
: This feature has a lot of
|
84
|
+
[TooManyDifferentTags](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_different_tags.feature)
|
85
|
+
: This feature has a lot of different tags.
|
80
86
|
|
81
|
-
TooManySteps
|
87
|
+
[TooManySteps](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_steps.feature)
|
82
88
|
: This feature has a lot of steps. Consider writing it more concisely.
|
83
89
|
|
84
|
-
TooManyTags
|
90
|
+
[TooManyTags](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_tags.feature)
|
85
91
|
: There are a lot of tags in this feature.
|
86
92
|
|
87
|
-
UniqueScenarioNames
|
93
|
+
[UniqueScenarioNames](https://github.com/BillyRuffian/chutney/blob/master/features/unique_scenario_names.feature)
|
88
94
|
: You have duplicated a scenario name when they should be unique.
|
89
95
|
|
90
|
-
UnknownVariable
|
96
|
+
[UnknownVariable](https://github.com/BillyRuffian/chutney/blob/master/features/unknown_variable.feature)
|
91
97
|
: You are referencing a variable which doesn't appear to be defined. This is a source of subtle errors.
|
92
98
|
|
93
|
-
UnusedVariable
|
99
|
+
[UnusedVariable](https://github.com/BillyRuffian/chutney/blob/master/features/unused_variable.feature)
|
94
100
|
: You have a variable which you are not using.
|
95
101
|
|
96
|
-
UseBackground
|
102
|
+
[UseBackground](https://github.com/BillyRuffian/chutney/blob/master/features/use_background.feature)
|
97
103
|
: You have a setup setup used in all of your scenarios. Move it to a Background section.
|
98
104
|
|
99
|
-
UseOutline
|
105
|
+
[UseOutline](https://github.com/BillyRuffian/chutney/blob/master/features/use_outline.feature)
|
100
106
|
: You have very similar scenarios. You should consider if they should be combined into a Scenario Outline.
|
data/lib/chutney.rb
CHANGED
@@ -4,9 +4,11 @@ require 'chutney/linter'
|
|
4
4
|
require 'chutney/linter/avoid_full_stop'
|
5
5
|
require 'chutney/linter/avoid_outline_for_single_example'
|
6
6
|
require 'chutney/linter/avoid_scripting'
|
7
|
+
require 'chutney/linter/avoid_typographers_quotes'
|
7
8
|
require 'chutney/linter/background_does_more_than_setup'
|
8
9
|
require 'chutney/linter/background_requires_multiple_scenarios'
|
9
10
|
require 'chutney/linter/bad_scenario_name'
|
11
|
+
require 'chutney/linter/empty_feature_file'
|
10
12
|
require 'chutney/linter/file_name_differs_feature_name'
|
11
13
|
require 'chutney/linter/givens_after_background'
|
12
14
|
require 'chutney/linter/invalid_file_name'
|
@@ -45,7 +47,7 @@ module Chutney
|
|
45
47
|
attr_accessor :verbose
|
46
48
|
attr_reader :files
|
47
49
|
attr_reader :results
|
48
|
-
|
50
|
+
|
49
51
|
def_delegators :@files, :<<, :clear, :delete, :include?
|
50
52
|
|
51
53
|
def initialize(*files)
|
@@ -56,7 +58,7 @@ module Chutney
|
|
56
58
|
|
57
59
|
I18n.load_path << i18n_paths
|
58
60
|
end
|
59
|
-
|
61
|
+
|
60
62
|
def configuration
|
61
63
|
unless @config
|
62
64
|
default_file = [File.expand_path('..', __dir__), '**/config', 'chutney.yml']
|
@@ -65,11 +67,11 @@ module Chutney
|
|
65
67
|
end
|
66
68
|
@config
|
67
69
|
end
|
68
|
-
|
70
|
+
|
69
71
|
def configuration=(config)
|
70
72
|
@config = config
|
71
73
|
end
|
72
|
-
|
74
|
+
|
73
75
|
def analyse
|
74
76
|
files.each do |f|
|
75
77
|
lint(f)
|
@@ -79,23 +81,23 @@ module Chutney
|
|
79
81
|
# alias for non-british English
|
80
82
|
# https://dictionary.cambridge.org/dictionary/english/analyse
|
81
83
|
alias analyze analyse
|
82
|
-
|
84
|
+
|
83
85
|
def linters
|
84
86
|
@linters ||= Linter.descendants.filter { |l| configuration.dig(l.linter_name, 'Enabled') }
|
85
87
|
end
|
86
|
-
|
88
|
+
|
87
89
|
def linters=(*linters)
|
88
90
|
@linters = linters
|
89
91
|
end
|
90
|
-
|
92
|
+
|
91
93
|
private
|
92
|
-
|
94
|
+
|
93
95
|
def parse(text)
|
94
96
|
@parser ||= Gherkin::Parser.new
|
95
97
|
scanner = Gherkin::TokenScanner.new(text)
|
96
98
|
@parser.parse(scanner)
|
97
99
|
end
|
98
|
-
|
100
|
+
|
99
101
|
def lint(file)
|
100
102
|
parsed = parse(File.read(file))
|
101
103
|
linters.each do |linter_class|
|
data/lib/chutney/linter.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# gherkin utilities
|
2
|
+
|
2
3
|
module Chutney
|
3
4
|
# base class for all linters
|
4
5
|
class Linter
|
@@ -67,12 +68,12 @@ module Chutney
|
|
67
68
|
element[:tags].map { |tag| tag[:name][1..-1] }
|
68
69
|
end
|
69
70
|
|
70
|
-
def add_issue(message, feature, scenario = nil, step = nil)
|
71
|
+
def add_issue(message, feature = nil, scenario = nil, step = nil)
|
71
72
|
issues << Lint.new(
|
72
73
|
message: message,
|
73
74
|
gherkin_type: type(feature, scenario, step),
|
74
75
|
location: location(feature, scenario, step),
|
75
|
-
feature: feature[:name],
|
76
|
+
feature: feature ? feature[:name] : nil,
|
76
77
|
scenario: scenario ? scenario[:name] : nil,
|
77
78
|
step: step ? step[:text] : nil
|
78
79
|
).to_h
|
@@ -81,8 +82,10 @@ module Chutney
|
|
81
82
|
def location(feature, scenario, step)
|
82
83
|
if step
|
83
84
|
step[:location]
|
84
|
-
|
85
|
-
scenario
|
85
|
+
elsif scenario
|
86
|
+
scenario[:location]
|
87
|
+
else
|
88
|
+
feature ? feature[:location] : 0
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
@@ -102,7 +105,9 @@ module Chutney
|
|
102
105
|
end
|
103
106
|
end
|
104
107
|
|
105
|
-
def elements
|
108
|
+
def elements
|
109
|
+
return [] unless feature
|
110
|
+
|
106
111
|
if block_given?
|
107
112
|
feature[:children].each do |child|
|
108
113
|
next if off_switch?(child)
|
@@ -113,7 +118,7 @@ module Chutney
|
|
113
118
|
feature[:children]
|
114
119
|
end
|
115
120
|
end
|
116
|
-
|
121
|
+
|
117
122
|
def off_switch?(element = feature)
|
118
123
|
off_switch = element[:tags]
|
119
124
|
.then { |tags| tags || [] }
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Chutney
|
2
|
+
# service class to lint for avoid scripting
|
3
|
+
class AvoidTypographersQuotes < Linter
|
4
|
+
TYPOGRAPHER_QUOTES = ["\u201c", "\u201d", "\u2018", "\u2019"].map(&:encode)
|
5
|
+
|
6
|
+
def lint
|
7
|
+
scenarios do |_feature, scenario|
|
8
|
+
lint_steps(scenario[:steps])
|
9
|
+
|
10
|
+
example_count = scenario[:examples]&.length || 0
|
11
|
+
next unless example_count.positive?
|
12
|
+
|
13
|
+
lint_examples(scenario[:examples])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def lint_steps(steps)
|
18
|
+
steps.each do |step|
|
19
|
+
issue(step) if TYPOGRAPHER_QUOTES.any? { |tq| step[:text].include? tq }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def lint_examples(examples)
|
24
|
+
examples.each do |example|
|
25
|
+
example[:tableBody].each do |body|
|
26
|
+
body[:cells].each do |cell|
|
27
|
+
issue(cell) if TYPOGRAPHER_QUOTES.any? { |tq| cell[:value].include? tq }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def issue(location)
|
34
|
+
add_issue(I18n.t('linters.avoid_typographers_quotes'), location)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -2,7 +2,7 @@ module Chutney
|
|
2
2
|
# service class to lint for file name differs feature name
|
3
3
|
class FileNameDiffersFeatureName < Linter
|
4
4
|
def lint
|
5
|
-
return unless feature
|
5
|
+
return unless feature&.include?(:name)
|
6
6
|
|
7
7
|
expected_feature_name = title_case(filename)
|
8
8
|
return if ignore_whitespaces(feature[:name]).casecmp(ignore_whitespaces(expected_feature_name)) == 0
|
@@ -3,6 +3,8 @@ module Chutney
|
|
3
3
|
class MissingFeatureDescription < Linter
|
4
4
|
MESSAGE = 'Features should have a description so that its purpose is clear'.freeze
|
5
5
|
def lint
|
6
|
+
return unless feature
|
7
|
+
|
6
8
|
name = feature.key?(:description) ? feature[:description].strip : ''
|
7
9
|
add_issue(I18n.t('linters.missing_feature_description'), feature) if name.empty?
|
8
10
|
end
|
@@ -2,6 +2,8 @@ module Chutney
|
|
2
2
|
# service class to lint for missing feature names
|
3
3
|
class MissingFeatureName < Linter
|
4
4
|
def lint
|
5
|
+
return unless feature
|
6
|
+
|
5
7
|
name = feature.key?(:name) ? feature[:name].strip : ''
|
6
8
|
add_issue(I18n.t('linters.missing_feature_name'), feature) if name.empty?
|
7
9
|
end
|
@@ -4,8 +4,8 @@ module Chutney
|
|
4
4
|
# service class to lint for using same tag on all scenarios
|
5
5
|
class SameTagForAllScenarios < Linter
|
6
6
|
def lint
|
7
|
-
lint_scenarios if feature
|
8
|
-
lint_examples if feature
|
7
|
+
lint_scenarios if feature&.include?(:children)
|
8
|
+
lint_examples if feature&.include?(:children)
|
9
9
|
end
|
10
10
|
|
11
11
|
def lint_scenarios
|
@@ -36,7 +36,7 @@ module Chutney
|
|
36
36
|
|
37
37
|
def gather_scenarios(feature)
|
38
38
|
scenarios = []
|
39
|
-
return scenarios
|
39
|
+
return scenarios if feature.nil? || !feature.include?(:children)
|
40
40
|
|
41
41
|
feature[:children].each do |scenario|
|
42
42
|
next unless scenario[:type] == :Scenario
|
data/lib/chutney/version.rb
CHANGED
data/lib/config/locales/en.yml
CHANGED
@@ -11,12 +11,18 @@ en:
|
|
11
11
|
avoid_scripting: >-
|
12
12
|
You have %{count} When steps when you should only have one.
|
13
13
|
Be careful not to add And steps following a When.
|
14
|
+
avoid_typographers_quotes: >-
|
15
|
+
You are using typographers quotation marks (curly quotes).
|
16
|
+
Make sure you intend to use this character and not a neutral quote
|
17
|
+
(straight quote) instead.
|
14
18
|
background_does_more_than_setup: >-
|
15
19
|
The Background does more than setup. It should only contain Given steps.
|
16
20
|
background_requires_multiple_scenarios: >-
|
17
21
|
Avoid using Background if you only have a single scenario.
|
18
22
|
bad_scenario_name: >-
|
19
23
|
You should avoid using words like '%{word}' in your scenario names.
|
24
|
+
empty_feature_file: >-
|
25
|
+
The feature file is empty
|
20
26
|
file_name_differs_feature_name: >-
|
21
27
|
The name of the feature should reflect the file name. Consider renaming this feature
|
22
28
|
to '%{expected}'.
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chutney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Brookes-Thomas
|
8
8
|
- Stefan Rohe
|
9
9
|
- Nishtha Argawal
|
10
10
|
- John Gluck
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-
|
14
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: amatch
|
@@ -111,6 +111,20 @@ dependencies:
|
|
111
111
|
- - "~>"
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '3.0'
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: pry-byebug
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - "~>"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '3.0'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '3.0'
|
114
128
|
- !ruby/object:Gem::Dependency
|
115
129
|
name: rake
|
116
130
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,14 +173,14 @@ dependencies:
|
|
159
173
|
requirements:
|
160
174
|
- - "~>"
|
161
175
|
- !ruby/object:Gem::Version
|
162
|
-
version: 0.
|
176
|
+
version: 0.89.0
|
163
177
|
type: :development
|
164
178
|
prerelease: false
|
165
179
|
version_requirements: !ruby/object:Gem::Requirement
|
166
180
|
requirements:
|
167
181
|
- - "~>"
|
168
182
|
- !ruby/object:Gem::Version
|
169
|
-
version: 0.
|
183
|
+
version: 0.89.0
|
170
184
|
- !ruby/object:Gem::Dependency
|
171
185
|
name: rspec
|
172
186
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,6 +209,7 @@ files:
|
|
195
209
|
- ".gitignore"
|
196
210
|
- ".rspec"
|
197
211
|
- ".rubocop.yml"
|
212
|
+
- ".rufo"
|
198
213
|
- Gemfile
|
199
214
|
- LICENSE.txt
|
200
215
|
- README.md
|
@@ -228,9 +243,11 @@ files:
|
|
228
243
|
- lib/chutney/linter/avoid_full_stop.rb
|
229
244
|
- lib/chutney/linter/avoid_outline_for_single_example.rb
|
230
245
|
- lib/chutney/linter/avoid_scripting.rb
|
246
|
+
- lib/chutney/linter/avoid_typographers_quotes.rb
|
231
247
|
- lib/chutney/linter/background_does_more_than_setup.rb
|
232
248
|
- lib/chutney/linter/background_requires_multiple_scenarios.rb
|
233
249
|
- lib/chutney/linter/bad_scenario_name.rb
|
250
|
+
- lib/chutney/linter/empty_feature_file.rb
|
234
251
|
- lib/chutney/linter/file_name_differs_feature_name.rb
|
235
252
|
- lib/chutney/linter/givens_after_background.rb
|
236
253
|
- lib/chutney/linter/invalid_file_name.rb
|
@@ -266,7 +283,7 @@ metadata:
|
|
266
283
|
homepage_uri: https://billyruffian.github.io/chutney/
|
267
284
|
source_code_uri: https://github.com/BillyRuffian/chutney
|
268
285
|
changelog_uri: https://github.com/BillyRuffian/chutney/releases
|
269
|
-
post_install_message:
|
286
|
+
post_install_message:
|
270
287
|
rdoc_options: []
|
271
288
|
require_paths:
|
272
289
|
- lib
|
@@ -282,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
299
|
version: '0'
|
283
300
|
requirements: []
|
284
301
|
rubygems_version: 3.1.2
|
285
|
-
signing_key:
|
302
|
+
signing_key:
|
286
303
|
specification_version: 4
|
287
304
|
summary: A linter for English language Gherkin
|
288
305
|
test_files: []
|