chutney 2.1.1 → 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/config/chutney.yml +2 -0
- data/docs/usage/rules.md +3 -0
- data/lib/chutney.rb +10 -9
- data/lib/chutney/linter.rb +6 -4
- data/lib/chutney/linter/empty_feature_file.rb +8 -0
- data/lib/chutney/version.rb +1 -1
- data/lib/config/locales/en.yml +2 -0
- metadata +3 -2
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/config/chutney.yml
CHANGED
data/docs/usage/rules.md
CHANGED
@@ -30,6 +30,9 @@ Chutney enforces its rules with the linters. These are:
|
|
30
30
|
[BadScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/bad_scenario_name.feature)
|
31
31
|
: You should avoid using words like 'test' or 'check' in your scenario names, instead you should define the behaviour of your system.
|
32
32
|
|
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
|
+
|
33
36
|
[FileNameDiffersFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/file_name_differs_feature_name.feature)
|
34
37
|
: The feature should have a name that follows the file name.
|
35
38
|
|
data/lib/chutney.rb
CHANGED
@@ -8,6 +8,7 @@ require 'chutney/linter/avoid_typographers_quotes'
|
|
8
8
|
require 'chutney/linter/background_does_more_than_setup'
|
9
9
|
require 'chutney/linter/background_requires_multiple_scenarios'
|
10
10
|
require 'chutney/linter/bad_scenario_name'
|
11
|
+
require 'chutney/linter/empty_feature_file'
|
11
12
|
require 'chutney/linter/file_name_differs_feature_name'
|
12
13
|
require 'chutney/linter/givens_after_background'
|
13
14
|
require 'chutney/linter/invalid_file_name'
|
@@ -46,7 +47,7 @@ module Chutney
|
|
46
47
|
attr_accessor :verbose
|
47
48
|
attr_reader :files
|
48
49
|
attr_reader :results
|
49
|
-
|
50
|
+
|
50
51
|
def_delegators :@files, :<<, :clear, :delete, :include?
|
51
52
|
|
52
53
|
def initialize(*files)
|
@@ -57,7 +58,7 @@ module Chutney
|
|
57
58
|
|
58
59
|
I18n.load_path << i18n_paths
|
59
60
|
end
|
60
|
-
|
61
|
+
|
61
62
|
def configuration
|
62
63
|
unless @config
|
63
64
|
default_file = [File.expand_path('..', __dir__), '**/config', 'chutney.yml']
|
@@ -66,11 +67,11 @@ module Chutney
|
|
66
67
|
end
|
67
68
|
@config
|
68
69
|
end
|
69
|
-
|
70
|
+
|
70
71
|
def configuration=(config)
|
71
72
|
@config = config
|
72
73
|
end
|
73
|
-
|
74
|
+
|
74
75
|
def analyse
|
75
76
|
files.each do |f|
|
76
77
|
lint(f)
|
@@ -80,23 +81,23 @@ module Chutney
|
|
80
81
|
# alias for non-british English
|
81
82
|
# https://dictionary.cambridge.org/dictionary/english/analyse
|
82
83
|
alias analyze analyse
|
83
|
-
|
84
|
+
|
84
85
|
def linters
|
85
86
|
@linters ||= Linter.descendants.filter { |l| configuration.dig(l.linter_name, 'Enabled') }
|
86
87
|
end
|
87
|
-
|
88
|
+
|
88
89
|
def linters=(*linters)
|
89
90
|
@linters = linters
|
90
91
|
end
|
91
|
-
|
92
|
+
|
92
93
|
private
|
93
|
-
|
94
|
+
|
94
95
|
def parse(text)
|
95
96
|
@parser ||= Gherkin::Parser.new
|
96
97
|
scanner = Gherkin::TokenScanner.new(text)
|
97
98
|
@parser.parse(scanner)
|
98
99
|
end
|
99
|
-
|
100
|
+
|
100
101
|
def lint(file)
|
101
102
|
parsed = parse(File.read(file))
|
102
103
|
linters.each do |linter_class|
|
data/lib/chutney/linter.rb
CHANGED
@@ -68,12 +68,12 @@ module Chutney
|
|
68
68
|
element[:tags].map { |tag| tag[:name][1..-1] }
|
69
69
|
end
|
70
70
|
|
71
|
-
def add_issue(message, feature, scenario = nil, step = nil)
|
71
|
+
def add_issue(message, feature = nil, scenario = nil, step = nil)
|
72
72
|
issues << Lint.new(
|
73
73
|
message: message,
|
74
74
|
gherkin_type: type(feature, scenario, step),
|
75
75
|
location: location(feature, scenario, step),
|
76
|
-
feature: feature[:name],
|
76
|
+
feature: feature ? feature[:name] : nil,
|
77
77
|
scenario: scenario ? scenario[:name] : nil,
|
78
78
|
step: step ? step[:text] : nil
|
79
79
|
).to_h
|
@@ -82,8 +82,10 @@ module Chutney
|
|
82
82
|
def location(feature, scenario, step)
|
83
83
|
if step
|
84
84
|
step[:location]
|
85
|
-
|
86
|
-
scenario
|
85
|
+
elsif scenario
|
86
|
+
scenario[:location]
|
87
|
+
else
|
88
|
+
feature ? feature[:location] : 0
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
data/lib/chutney/version.rb
CHANGED
data/lib/config/locales/en.yml
CHANGED
@@ -21,6 +21,8 @@ en:
|
|
21
21
|
Avoid using Background if you only have a single scenario.
|
22
22
|
bad_scenario_name: >-
|
23
23
|
You should avoid using words like '%{word}' in your scenario names.
|
24
|
+
empty_feature_file: >-
|
25
|
+
The feature file is empty
|
24
26
|
file_name_differs_feature_name: >-
|
25
27
|
The name of the feature should reflect the file name. Consider renaming this feature
|
26
28
|
to '%{expected}'.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-08-
|
14
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: amatch
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- lib/chutney/linter/background_does_more_than_setup.rb
|
248
248
|
- lib/chutney/linter/background_requires_multiple_scenarios.rb
|
249
249
|
- lib/chutney/linter/bad_scenario_name.rb
|
250
|
+
- lib/chutney/linter/empty_feature_file.rb
|
250
251
|
- lib/chutney/linter/file_name_differs_feature_name.rb
|
251
252
|
- lib/chutney/linter/givens_after_background.rb
|
252
253
|
- lib/chutney/linter/invalid_file_name.rb
|