chutney 3.3.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/chutney.gemspec +2 -2
- data/config/chutney_defaults.yml +6 -0
- data/docs/usage/rules.md +6 -0
- data/lib/chutney/linter/avoid_outline_for_single_example.rb +1 -0
- data/lib/chutney/linter/inconsistent_quoting.rb +42 -0
- data/lib/chutney/linter/missing_example_table.rb +17 -0
- data/lib/chutney/linter/missing_scenario_outline.rb +17 -0
- data/lib/chutney/version.rb +1 -1
- data/lib/chutney.rb +3 -0
- data/lib/config/locales/en.yml +10 -0
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0badc9f82efb1e59bc755597c4ef3f7a4f973e37fec2fc25d4b93192319a75eb
|
4
|
+
data.tar.gz: 9459b41ac94999efc721d07f54e8e14b3c83c4f00786f003937a65dd2054fb9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 404c7bd04be47d2c2fb6c71e9d44bc317b5d0a9abe1a3362945ce2841a76f9cc25eb7703cc39134c2065dfcc8c83d5f615f24e035160cd10aab09178e8f8d6fe
|
7
|
+
data.tar.gz: 29150aae2c605d2ce489dd3a41b914ad7bc67dc53867122c7c11b67830d5fe82771a433d0b6250c926d0e7bd34c0fa8af53941c734e32d5d8db3f435153f8c0f
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
</div>
|
21
21
|
|
22
|
-
Read the documentation [here](https://billyruffian.github.io/chutney/)
|
22
|
+
Read the documentation [here](https://billyruffian.github.io/chutney/).
|
23
23
|
|
24
24
|
See [this page](https://billyruffian.github.io/chutney/usage/rules.html) for a full list of the rules chutney encourages.
|
25
25
|
|
data/chutney.gemspec
CHANGED
@@ -50,7 +50,7 @@ Gem::Specification.new do |spec|
|
|
50
50
|
|
51
51
|
spec.add_runtime_dependency 'amatch', '~> 0.4.0'
|
52
52
|
spec.add_runtime_dependency 'cuke_modeler', '~> 3.3'
|
53
|
-
spec.add_runtime_dependency 'i18n', '>= 1.8.2', '< 1.
|
53
|
+
spec.add_runtime_dependency 'i18n', '>= 1.8.2', '< 1.15.0'
|
54
54
|
spec.add_runtime_dependency 'pastel', '~> 0.7'
|
55
55
|
spec.add_runtime_dependency 'tty-pie', '~> 0.3'
|
56
56
|
|
@@ -61,7 +61,7 @@ Gem::Specification.new do |spec|
|
|
61
61
|
spec.add_development_dependency 'rake', '~> 13.0'
|
62
62
|
spec.add_development_dependency 'rerun', '~> 0.13'
|
63
63
|
spec.add_development_dependency 'rspec-expectations', '~> 3.0'
|
64
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
64
|
+
spec.add_development_dependency 'rubocop', '~> 1.50.2'
|
65
65
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
66
66
|
|
67
67
|
spec.required_ruby_version = '>= 2.6'
|
data/config/chutney_defaults.yml
CHANGED
@@ -24,16 +24,22 @@ GivensAfterBackground:
|
|
24
24
|
Enabled: true
|
25
25
|
MissingExampleName:
|
26
26
|
Enabled: true
|
27
|
+
MissingExampleTable:
|
28
|
+
Enabled: true
|
27
29
|
MissingFeatureDescription:
|
28
30
|
Enabled: true
|
29
31
|
MissingFeatureName:
|
30
32
|
Enabled: true
|
31
33
|
MissingScenarioName:
|
32
34
|
Enabled: true
|
35
|
+
MissingScenarioOutline:
|
36
|
+
Enabled: true
|
33
37
|
MissingTestAction:
|
34
38
|
Enabled: true
|
35
39
|
MissingVerification:
|
36
40
|
Enabled: true
|
41
|
+
InconsistentQuoting:
|
42
|
+
Enabled: true
|
37
43
|
InvalidFileName:
|
38
44
|
Enabled: true
|
39
45
|
InvalidStepFlow:
|
data/docs/usage/rules.md
CHANGED
@@ -33,18 +33,24 @@ Chutney enforces its rules with the linters. These are:
|
|
33
33
|
|
34
34
|
[GivensAfterBackground](https://github.com/BillyRuffian/chutney/blob/master/features/givens_after_background.feature): 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
35
|
|
36
|
+
[InconsistentQuoting](https://github.com/BillyRuffian/chutney/blob/master/features/inconsistent_quoting.feature): Use either single quotation marks *or* double quotation marks around parameters but don't use a mix of the two styles.
|
37
|
+
|
36
38
|
[InvalidFileName](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_file_name.feature): Make sure your file name is in snake case, not mixed case or with spaces.
|
37
39
|
|
38
40
|
[InvalidStepFlow](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_step_flow.feature): Your scenarios should follow Given → When → Then, in that order.
|
39
41
|
|
40
42
|
[MissingExampleName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_example_name.feature): If you have more than one example table in your scenario, they should each be given unique names.
|
41
43
|
|
44
|
+
[MissingExampleTable](https://github.com/BillyRuffian/chutney/blob/master/features/missing_example_table.feature): You are missing an example table. You should have at least one example table when using Scenario outlines.
|
45
|
+
|
42
46
|
[MissingFeatureDescription](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_description.feature): Your feature should have a value statement. These are usually in the form 'As a... I want.. So that...'.
|
43
47
|
|
44
48
|
[MissingFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_name.feature): You should give your features a descriptive name.
|
45
49
|
|
46
50
|
[MissingScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_scenario_name.feature): You should name your scenarios and scenario outlines.
|
47
51
|
|
52
|
+
[MissingScenarioOutline](https://github.com/BillyRuffian/chutney/blob/master/features/missing_scenario_outline.feature): You should use Scenario Outline instead of Scenario when there is an Examples table to indicate that this scenario will be run multiple times with different data.
|
53
|
+
|
48
54
|
[MissingTestAction](https://github.com/BillyRuffian/chutney/blob/master/features/missing_test_action.feature): You don't have an action (a `When` step) in your scenario.
|
49
55
|
|
50
56
|
[MissingVerification](https://github.com/BillyRuffian/chutney/blob/master/features/missing_verification.feature): You don't have a verification step (a `Then` step) in your scenario.
|
@@ -9,6 +9,7 @@ module Chutney
|
|
9
9
|
next unless scenario.examples
|
10
10
|
|
11
11
|
next if scenario.examples.length > 1
|
12
|
+
next if scenario.examples.first.nil? # dont run lint if the example does not exist
|
12
13
|
next if scenario.examples.first.rows.length > 2 # first row is the header
|
13
14
|
|
14
15
|
add_issue(I18n.t('linters.avoid_outline_for_single_example'), feature, scenario)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Chutney
|
4
|
+
# service class to lint for avoiding periods
|
5
|
+
class InconsistentQuoting < Linter
|
6
|
+
# regular expression to extract quoted string
|
7
|
+
# matching group 1: opening quote; 2: quoted text; 3: closing quote
|
8
|
+
# opening and closing quote must match (via backrefs)
|
9
|
+
# apostrophes, both singular and plural posessives, are accounted for
|
10
|
+
QUOTED_STRING = /(?!\b\b)(['"])(.*(?:\b'\b[^\1]*)*(?!\b[\1]\b))(\1)/.freeze
|
11
|
+
Parameter = Struct.new('Parameter', :quotation_mark, :name)
|
12
|
+
|
13
|
+
def lint
|
14
|
+
quoted_params = parameters.group_by(&:quotation_mark)
|
15
|
+
single_quoted = quoted_params[%(')] || []
|
16
|
+
double_quoted = quoted_params[%(")] || []
|
17
|
+
return unless single_quoted.count.positive? && double_quoted.count.positive?
|
18
|
+
|
19
|
+
add_issue(
|
20
|
+
I18n.t('linters.inconsistent_quoting',
|
21
|
+
count_single: single_quoted.count, count_double: double_quoted.count,
|
22
|
+
example_single: %('#{single_quoted.first.name}'), example_double: %("#{double_quoted.first.name}")),
|
23
|
+
feature
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def parameters
|
28
|
+
parameters = []
|
29
|
+
|
30
|
+
steps do |_feature, _child, step|
|
31
|
+
step_parameters = step
|
32
|
+
.text
|
33
|
+
.scan(QUOTED_STRING)
|
34
|
+
.map { |p| p.take(2) } # close quote will match open quote: drop it
|
35
|
+
.map { |p| Parameter.new(*p) }
|
36
|
+
parameters.concat(step_parameters)
|
37
|
+
end
|
38
|
+
|
39
|
+
parameters
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'chutney/linter'
|
4
|
+
|
5
|
+
module Chutney
|
6
|
+
# service class to lint for missing example tables in scenario outlines
|
7
|
+
class MissingExampleTable < Linter
|
8
|
+
def lint
|
9
|
+
scenarios do |_feature, scenario|
|
10
|
+
next unless scenario.is_a? CukeModeler::Outline
|
11
|
+
next unless scenario.examples.empty?
|
12
|
+
|
13
|
+
add_issue(I18n.t('linters.missing_example_table'), feature, scenario)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'chutney/linter'
|
4
|
+
|
5
|
+
module Chutney
|
6
|
+
# service class to lint for missing scenario outlines when examples tables given
|
7
|
+
class MissingScenarioOutline < Linter
|
8
|
+
def lint
|
9
|
+
scenarios do |_feature, scenario|
|
10
|
+
next unless scenario.is_a? CukeModeler::Outline
|
11
|
+
next unless scenario.keyword == 'Scenario'
|
12
|
+
|
13
|
+
add_issue(I18n.t('linters.missing_scenario_outline'), feature, scenario)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/chutney/version.rb
CHANGED
data/lib/chutney.rb
CHANGED
@@ -16,12 +16,15 @@ require 'chutney/linter/bad_scenario_name'
|
|
16
16
|
require 'chutney/linter/empty_feature_file'
|
17
17
|
require 'chutney/linter/file_name_differs_feature_name'
|
18
18
|
require 'chutney/linter/givens_after_background'
|
19
|
+
require 'chutney/linter/inconsistent_quoting'
|
19
20
|
require 'chutney/linter/invalid_file_name'
|
20
21
|
require 'chutney/linter/invalid_step_flow'
|
21
22
|
require 'chutney/linter/missing_example_name'
|
23
|
+
require 'chutney/linter/missing_example_table'
|
22
24
|
require 'chutney/linter/missing_feature_description'
|
23
25
|
require 'chutney/linter/missing_feature_name'
|
24
26
|
require 'chutney/linter/missing_scenario_name'
|
27
|
+
require 'chutney/linter/missing_scenario_outline'
|
25
28
|
require 'chutney/linter/missing_test_action'
|
26
29
|
require 'chutney/linter/missing_verification'
|
27
30
|
require 'chutney/linter/required_tags_starts_with'
|
data/lib/config/locales/en.yml
CHANGED
@@ -33,6 +33,12 @@ en:
|
|
33
33
|
givens_after_background: >-
|
34
34
|
Avoid using the 'Given' keyword in scenarios if you have a background.
|
35
35
|
Instead, setup steps begin your scenario and should start with an 'And' or 'But' keyword.
|
36
|
+
inconsistent_quoting: >-
|
37
|
+
Avoid using inconsistent quoting for your parameters.
|
38
|
+
You have %{count_single} single-quoted parameters (e.g. %{example_single})
|
39
|
+
and %{count_double} double-quoted parameters (e.g. %{example_double}).
|
40
|
+
You should adopt a single style to avoid confusion about the meaning and purpose
|
41
|
+
of the parameters.
|
36
42
|
invalid_file_name: >-
|
37
43
|
Filenames of feature files should be in snake case.
|
38
44
|
You should name this file '%{recommended_name}'.
|
@@ -49,6 +55,8 @@ en:
|
|
49
55
|
You have a scenerio with more than one example table, at least one of which is
|
50
56
|
unnamed or has a duplicate name.
|
51
57
|
You should give your example tables clear and meaningful names when you have more than one.
|
58
|
+
missing_example_table: >-
|
59
|
+
Scenario Outline must have at least one Examples table.
|
52
60
|
missing_feature_description: >-
|
53
61
|
Features should have a description / value statement so that the importance of the feature
|
54
62
|
is well understood.
|
@@ -56,6 +64,8 @@ en:
|
|
56
64
|
This feature is unnamed. You should name all features.
|
57
65
|
missing_scenario_name: >-
|
58
66
|
This scenario is unnamed. You should name all scenarios.
|
67
|
+
missing_scenario_outline: >-
|
68
|
+
Scenario Outline should be used instead of Scenario when there is an Examples table.
|
59
69
|
missing_test_action: >-
|
60
70
|
Your test has no action step. All scenarios should have a 'When' step indicating the
|
61
71
|
action being taken.
|
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: 3.
|
4
|
+
version: 3.6.0
|
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:
|
14
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: amatch
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
version: 1.8.2
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 1.15.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
version: 1.8.2
|
61
61
|
- - "<"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 1.
|
63
|
+
version: 1.15.0
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: pastel
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,14 +179,14 @@ dependencies:
|
|
179
179
|
requirements:
|
180
180
|
- - "~>"
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 1.
|
182
|
+
version: 1.50.2
|
183
183
|
type: :development
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - "~>"
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: 1.
|
189
|
+
version: 1.50.2
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: rspec
|
192
192
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,12 +262,15 @@ files:
|
|
262
262
|
- lib/chutney/linter/empty_feature_file.rb
|
263
263
|
- lib/chutney/linter/file_name_differs_feature_name.rb
|
264
264
|
- lib/chutney/linter/givens_after_background.rb
|
265
|
+
- lib/chutney/linter/inconsistent_quoting.rb
|
265
266
|
- lib/chutney/linter/invalid_file_name.rb
|
266
267
|
- lib/chutney/linter/invalid_step_flow.rb
|
267
268
|
- lib/chutney/linter/missing_example_name.rb
|
269
|
+
- lib/chutney/linter/missing_example_table.rb
|
268
270
|
- lib/chutney/linter/missing_feature_description.rb
|
269
271
|
- lib/chutney/linter/missing_feature_name.rb
|
270
272
|
- lib/chutney/linter/missing_scenario_name.rb
|
273
|
+
- lib/chutney/linter/missing_scenario_outline.rb
|
271
274
|
- lib/chutney/linter/missing_test_action.rb
|
272
275
|
- lib/chutney/linter/missing_verification.rb
|
273
276
|
- lib/chutney/linter/required_tags_starts_with.rb
|
@@ -312,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
315
|
- !ruby/object:Gem::Version
|
313
316
|
version: '0'
|
314
317
|
requirements: []
|
315
|
-
rubygems_version: 3.
|
318
|
+
rubygems_version: 3.4.10
|
316
319
|
signing_key:
|
317
320
|
specification_version: 4
|
318
321
|
summary: A linter for multi-lingual Gherkin
|