rubocop-rspec_parity 1.4.1 → 1.4.2

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: 944e7c309cb2d5e95c94878066fdee5483054e1585bf272116825603ac2fc265
4
- data.tar.gz: e72069e31fc0ee1b0b63db9d33f316cb9a5b3d52dcfd8d6de65071d406f3514e
3
+ metadata.gz: a292f9a4bfd8a377704932840853dc8ab47f7e8b6665c0a99d9039b806e1e75c
4
+ data.tar.gz: a35e6b56eb08faa4ecbc0561ed1dc39b53f1c892c9c5ecb9342c9f73bd5734ac
5
5
  SHA512:
6
- metadata.gz: 0d6e482836054a7069f89f2a2a350c70579c5459c58897d7cd4f539c670f3099512e71efc93f26fde2877d1582dfa3a2e238f0ba355c3a449ef50b1417379e61
7
- data.tar.gz: 91eac7edad8d9d7f54fd3e3c7b0bb8973fa89e4c3d33ddd869c9db36ab0d6ae607162e4c7e097cd6203b541bc57ee39d01905598f69b629ff899e4293ccb4bfc
6
+ metadata.gz: d41834a22a635130c9f6fce2657a353988f3517a003ad2a2c8f31181a81cd55b48227509919d304433a92f2abecec172ad05c193b8788f0d007e18b77083cc47
7
+ data.tar.gz: 604c27a89fe267823aa79fe275d50f8247e0ed09246dc114895d937d5824c879290c5eadedcda185a7a6cb22e9703ae9636a03eca86e50b3c5de91928a616d43
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.4.2] - 2026-03-03
4
+
5
+ Fixed: `PublicMethodHasSpec` now reports violations even when the spec file does not exist, since a missing spec file means the method is untested
6
+ Fixed: Department-level config keys (`DescribeAliases`, `SkipMethodDescribeFor`) no longer trigger unsupported parameter warnings when overridden at cop level
7
+ Added: `Include` and `Exclude` can now be set at department level (`RSpecParity:`) to apply to all cops
8
+
3
9
  ## [1.4.1] - 2026-03-03
4
10
 
5
11
  Fixed: `PublicMethodHasSpec` now reports violations even when the spec file does not exist, since a missing spec file means the method is untested
data/config/default.yml CHANGED
@@ -1,16 +1,12 @@
1
1
  # Default configuration for rubocop-rspec_parity
2
2
 
3
3
  # Department-level shared configuration for all RSpecParity cops.
4
- # Cop-level settings override these when explicitly set per-cop.
4
+ # Set these in your .rubocop.yml under RSpecParity: to share across all cops.
5
+ # Supported keys: SpecFilePathMappings, DescribeAliases, SkipMethodDescribeFor,
6
+ # Include, Exclude.
7
+ # Department-level values override cop-level defaults.
8
+ # Cop-level values set explicitly in your .rubocop.yml override department-level.
5
9
  RSpecParity:
6
- SpecFilePathMappings:
7
- 'app/': ['spec/']
8
- DescribeAliases: {}
9
- SkipMethodDescribeFor: []
10
-
11
- RSpecParity/FileHasSpec:
12
- Description: 'Checks that each Ruby file in the app directory has a corresponding spec file.'
13
- Enabled: true
14
10
  Include:
15
11
  - 'app/**/*.rb'
16
12
  Exclude:
@@ -18,23 +14,19 @@ RSpecParity/FileHasSpec:
18
14
  - 'app/views/**/*'
19
15
  - 'app/javascript/**/*'
20
16
 
17
+ RSpecParity/FileHasSpec:
18
+ Description: 'Checks that each Ruby file in the app directory has a corresponding spec file.'
19
+ Enabled: true
20
+
21
21
  RSpecParity/PublicMethodHasSpec:
22
22
  Description: 'Checks that each public method has a corresponding spec test.'
23
23
  Enabled: true
24
- Include:
25
- - 'app/**/*.rb'
26
- Exclude:
27
- - 'app/assets/**/*'
28
- - 'app/views/**/*'
29
- - 'app/javascript/**/*'
24
+ SkipMethodDescribeFor: []
25
+ DescribeAliases: {}
30
26
 
31
27
  RSpecParity/SufficientContexts:
32
28
  Description: 'Ensures specs have at least as many contexts as the method has branches.'
33
29
  Enabled: true
34
30
  IgnoreMemoization: true
35
- Include:
36
- - 'app/**/*.rb'
37
- Exclude:
38
- - 'app/assets/**/*'
39
- - 'app/views/**/*'
40
- - 'app/javascript/**/*'
31
+ SkipMethodDescribeFor: []
32
+ DescribeAliases: {}
@@ -7,6 +7,12 @@ module RuboCop
7
7
  # Provides config resolution (cop-level > department-level > default),
8
8
  # spec file path mappings, and shared describe aliases / skip paths.
9
9
  module DepartmentConfig
10
+ SHARED_CONFIG_DEFAULTS = {
11
+ "SpecFilePathMappings" => { "app/" => ["spec/"] },
12
+ "DescribeAliases" => {},
13
+ "SkipMethodDescribeFor" => []
14
+ }.freeze
15
+
10
16
  private
11
17
 
12
18
  def department_config
@@ -14,15 +20,15 @@ module RuboCop
14
20
  end
15
21
 
16
22
  def spec_file_path_mappings
17
- resolve_config("SpecFilePathMappings", { "app/" => ["spec/"] })
23
+ resolve_config("SpecFilePathMappings")
18
24
  end
19
25
 
20
26
  def shared_describe_aliases
21
- resolve_config("DescribeAliases", {})
27
+ resolve_config("DescribeAliases")
22
28
  end
23
29
 
24
30
  def shared_skip_method_describe_paths
25
- resolve_config("SkipMethodDescribeFor", [])
31
+ resolve_config("SkipMethodDescribeFor")
26
32
  end
27
33
 
28
34
  def expected_spec_paths(source_path = nil) # rubocop:disable Metrics/MethodLength
@@ -55,14 +61,17 @@ module RuboCop
55
61
  root ? spec_path.sub("#{root}/", "") : spec_path
56
62
  end
57
63
 
58
- def resolve_config(key, default)
59
- if cop_config.key?(key)
60
- cop_config[key]
61
- elsif department_config.key?(key)
62
- department_config[key]
63
- else
64
- default
65
- end
64
+ # Precedence: cop-level user override > department-level > default.
65
+ # Detects cop-level user overrides by comparing against the known default.
66
+ def resolve_config(key)
67
+ default = SHARED_CONFIG_DEFAULTS[key]
68
+ cop_value = cop_config.key?(key) ? cop_config[key] : nil
69
+ user_overrode_cop = !cop_value.nil? && cop_value != default
70
+
71
+ return cop_value if user_overrode_cop
72
+ return department_config[key] if department_config.key?(key)
73
+
74
+ cop_value || default
66
75
  end
67
76
 
68
77
  def path_matches_mapping?(source_path, source_dir)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module RSpecParity
5
- VERSION = "1.4.1"
5
+ VERSION = "1.4.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec_parity
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Povilas Jurcys