chutney 3.10.0 → 3.11.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6734d8a322d5394f40d363d0ad93def2424ea97be81f4a13cd7bb92c91ade597
4
- data.tar.gz: 0146772a58c64cfa3aa8f7ab05861c94945d37abec3ff10c93bd3f653c9784b4
3
+ metadata.gz: 74225c8b4badcb729231121bce2547b43c1a7d21b239bf17f0de152a4a425686
4
+ data.tar.gz: acfe603816c3c0bafd77e4fc149d895d665745b5260b341f24744baa7ab162c1
5
5
  SHA512:
6
- metadata.gz: 9f869fc17e30cee78412fab391049971c81316937148e73dcd6111afb6d55a5c60e9ac5db24d36917b9be63556dd8ee63ea4b1d082f8fd4a8b3edb3bae037ba4
7
- data.tar.gz: 87f372ffc4bcef3f514aef73ae971d8a5dd8545d6bd7897770e7c69808c11fd7f0740afd0befe271ef49274720e91da5a92a4913cd108737bf2e1fbe99f1dd5e
6
+ metadata.gz: d4a3ed6425a8157e7dbcba96808fd8e340760da1140b3966e25b44fc4d2d5849f774e6cd0f3bd9c8c93bf4c6e7aedd4c648476d2a393e819a39cfc5c69d00c96
7
+ data.tar.gz: 5f51a71f864e39ee219b841167fa5a8bffdf9837db27bb705089573e7402a9dd3931c6340c51861c2363bc8bbce73718404221280a348dbceebae027a9c6beb8
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ gemspec
6
6
 
7
7
  gem 'coveralls', '~> 0.8'
8
8
  gem 'cucumber', '>= 9.0'
9
- gem 'pry-byebug', '~> 3.0'
10
9
  gem 'rake', '~> 13.0'
11
10
  gem 'rerun', '~> 0.13'
12
11
  gem 'rspec', '~> 3.13'
@@ -50,6 +50,8 @@ InvalidStepFlow:
50
50
  Enabled: true
51
51
  RequiredTagsStartsWith:
52
52
  Enabled: false
53
+ SameScenario:
54
+ Enabled: true
53
55
  SameTagDifferentCase:
54
56
  Enabled: true
55
57
  SameTagForAllScenarios:
data/docs/usage/rules.md CHANGED
@@ -57,6 +57,8 @@ Chutney enforces its rules with the linters. These are:
57
57
 
58
58
  [RequiredTagsStartWith](https://github.com/BillyRuffian/chutney/blob/master/features/required_tags_starts_with.feature): Chutney can enforce a configurable naming prefix for your tags.
59
59
 
60
+ [SameSecenario](https://github.com/BillyRuffian/chutney/blob/master/features/same_scenario.feature): Makes sure you don't acidentally duplicate the actions of your scenario. *Since v3.11.0*
61
+
60
62
  [SameTagForDifferentCase](https://github.com/BillyRuffian/chutney/blob/master/features/same_tag_different_case.feature): Don't mix the case of tags which have already appeared. Cucumber tags are case sensitive. *Since 3.1.0*
61
63
 
62
64
  [SameTagForAllScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/same_tag_for_all_scenarios.feature): You have the same tag for all you scenarios; move the tag to the feature level instead.
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Chutney
4
+ # Rule to find all the duplicated scenarios
5
+ class SameScenario < Linter
6
+ def lint
7
+ dictionary = Hash.new { |hash, key| hash[key] = [] }
8
+
9
+ scenarios do |feature, scenario|
10
+ text = scenario
11
+ .steps
12
+ .map { |step| "#{step.text} #{child_text(step)}" }
13
+ .join("\n") + example_text(scenario)
14
+
15
+ digest = Digest::SHA2.hexdigest(text)
16
+ dictionary[digest] << { scenario:, feature: }
17
+ end
18
+
19
+ dictionary.filter { |_k, v| v.size > 1 }
20
+ .each_value do |v|
21
+ v[1...].each do |problem|
22
+ add_issue(I18n.t('linters.same_scenario',
23
+ feature: problem[:feature].name,
24
+ scenario: problem[:scenario].name,
25
+ original_feature: v.first[:feature].name,
26
+ original_scenario: v.first[:scenario].name),
27
+ problem[:feature], problem[:scenario], nil)
28
+ end
29
+ end
30
+ end
31
+
32
+ def child_text(step)
33
+ step.children.map do |child|
34
+ if child.is_a?(CukeModeler::Table)
35
+ child.rows.flat_map(&:cells).map(&:value).join(' | ')
36
+ elsif child.is_a?(CukeModeler::DocString)
37
+ child.content
38
+ else
39
+ ''
40
+ end
41
+ end
42
+ end
43
+
44
+ def example_text(scenario)
45
+ if scenario.is_a?(CukeModeler::Outline)
46
+ "\n" + scenario.examples
47
+ .flat_map(&:rows)
48
+ .flat_map(&:cells)
49
+ .map(&:value).join(' | ')
50
+ else
51
+ ''
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chutney
4
- VERSION = '3.10.0'
4
+ VERSION = '3.11.1'
5
5
  end
data/lib/chutney.rb CHANGED
@@ -30,6 +30,7 @@ require 'chutney/linter/missing_scenario_outline'
30
30
  require 'chutney/linter/missing_test_action'
31
31
  require 'chutney/linter/missing_verification'
32
32
  require 'chutney/linter/required_tags_starts_with'
33
+ require 'chutney/linter/same_scenario'
33
34
  require 'chutney/linter/same_tag_different_case'
34
35
  require 'chutney/linter/same_tag_for_all_scenarios'
35
36
  require 'chutney/linter/scenario_names_match'
@@ -48,6 +49,7 @@ require 'chutney/locator'
48
49
  require 'chutney/version'
49
50
 
50
51
  require 'cuke_modeler'
52
+ require 'digest'
51
53
  require 'forwardable'
52
54
  require 'i18n'
53
55
  require 'yaml'
@@ -78,6 +78,8 @@ en:
78
78
  the assertion being tested.
79
79
  required_tags_starts_with: >-
80
80
  You have tags which do not match the required format. Allowed prefixes are '%{allowed}'.
81
+ same_scenario: >-
82
+ Duplicate scenario detected: %{feature} / %{scenario} is a duplicate of %{original_feature} / %{original_scenario}
81
83
  scenario_names_match: >-
82
84
  You have a scenario name which does not match the required format.
83
85
  Allowed patterns are '%{pattern}'.
@@ -81,6 +81,8 @@ sidebar:
81
81
  url: /docs/rules/missing-test-verification/
82
82
  - title: "Required tags start with"
83
83
  url: /docs/rules/required-tags-start-with/
84
+ - title: "Same Scenario"
85
+ url: /docs/rules/same-scenario/
84
86
  - title: "Same tag different case"
85
87
  url: /docs/rules/same-tag-different-case/
86
88
  - title: "Same tag for all scenarios"
@@ -0,0 +1,24 @@
1
+ ---
2
+ title: "Same Scenario"
3
+ layout: single
4
+ permalink: /docs/rules/same-scenario/
5
+ ---
6
+
7
+ You have a `Scenario`, or a `Scenario Outline` which appears to be duplicated. This probably means you have a redundant test. You should probably make sure you only have one copy of your steps to be consitent and efficient.
8
+
9
+
10
+ This rule ignores the names of your scenarios but takes into account data tables, examples and doc strings.
11
+
12
+ ## Examples
13
+
14
+ ```gherkin
15
+ Feature: Test
16
+ Scenario: Scenario A
17
+ When I do a thing
18
+ Then A thing happens
19
+
20
+ Scenario: Scenario B
21
+ When I do a thing
22
+ Then A thing happens
23
+ ```
24
+
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chutney
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.11.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:
12
11
  bindir: exe
13
12
  cert_chain: []
14
- date: 2024-11-27 00:00:00.000000000 Z
13
+ date: 1980-01-02 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: amatch
@@ -181,6 +180,7 @@ files:
181
180
  - lib/chutney/linter/missing_test_action.rb
182
181
  - lib/chutney/linter/missing_verification.rb
183
182
  - lib/chutney/linter/required_tags_starts_with.rb
183
+ - lib/chutney/linter/same_scenario.rb
184
184
  - lib/chutney/linter/same_tag_different_case.rb
185
185
  - lib/chutney/linter/same_tag_for_all_scenarios.rb
186
186
  - lib/chutney/linter/scenario_names_match.rb
@@ -241,6 +241,7 @@ files:
241
241
  - usechutney.com/docs/rules/missing-test-action/index.md
242
242
  - usechutney.com/docs/rules/missing-test-verification/index.md
243
243
  - usechutney.com/docs/rules/required-tag-starts-with/index.md
244
+ - usechutney.com/docs/rules/same-scenario/index.md
244
245
  - usechutney.com/docs/rules/same-tag-different-case/index.md
245
246
  - usechutney.com/docs/rules/same-tag-for-all-scenarios/index.md
246
247
  - usechutney.com/docs/rules/scenario-names-match/index.md
@@ -266,7 +267,6 @@ metadata:
266
267
  homepage_uri: https://www.usechutney.com/
267
268
  source_code_uri: https://github.com/BillyRuffian/chutney
268
269
  changelog_uri: https://github.com/BillyRuffian/chutney/releases
269
- post_install_message:
270
270
  rdoc_options: []
271
271
  require_paths:
272
272
  - lib
@@ -281,8 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubygems_version: 3.5.23
285
- signing_key:
284
+ rubygems_version: 3.6.9
286
285
  specification_version: 4
287
286
  summary: A linter for multi-lingual Gherkin
288
287
  test_files: []