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 +4 -4
- data/CHANGELOG.md +6 -0
- data/config/default.yml +13 -21
- data/lib/rubocop/cop/rspec_parity/department_config.rb +20 -11
- data/lib/rubocop/rspec_parity/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a292f9a4bfd8a377704932840853dc8ab47f7e8b6665c0a99d9039b806e1e75c
|
|
4
|
+
data.tar.gz: a35e6b56eb08faa4ecbc0561ed1dc39b53f1c892c9c5ecb9342c9f73bd5734ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
#
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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"
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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)
|