rubocop-rspec_parity 1.2.0 → 1.2.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f6cb712ad716f1a6c82659cd5114785bd93f7ed7344fb2ba6317de8bae3d37e
|
|
4
|
+
data.tar.gz: 2588d5b16c636142a361c2d0723d049099e7e1da76ed30b72b0c78b211734fb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2d8de79c7cf285c21e656b96ac473037aabd21c9d206753d44c863b6844d9393217bdf1850b21646f96996355270467e07d711230702fbbb6ed51b4c3536699
|
|
7
|
+
data.tar.gz: 65836a3ae64470aa713d5c3492fb33b993d137f66f1be2d464104a3ce75a22733dd0a055fd2875f6d7ad24c25b407869d42bfebb9d494c3416a4d7003813d8b8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.2.2] - 2026-02-10
|
|
4
|
+
|
|
5
|
+
Added: `PublicMethodHasSpec` now skips class methods marked with `private_class_method` (both inline and post-hoc forms)
|
|
6
|
+
|
|
7
|
+
## [1.2.1] - 2026-02-09
|
|
8
|
+
|
|
9
|
+
Fixed: Detect tested methods correctly for classes nested inside modules (e.g. `Calendar::UserCreator`)
|
|
10
|
+
|
|
3
11
|
## [1.2.0] - 2026-02-09
|
|
4
12
|
|
|
5
13
|
Added: `SufficientContexts` now counts direct `it` blocks alongside `context` blocks as an additional implicit context
|
|
@@ -36,13 +36,35 @@ module RuboCop
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def on_defs(node)
|
|
39
|
-
return unless checkable_method?(node)
|
|
39
|
+
return unless checkable_method?(node) && public_class_method?(node)
|
|
40
40
|
|
|
41
41
|
check_method_has_spec(node, instance_method: false)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
private
|
|
45
45
|
|
|
46
|
+
def public_class_method?(node)
|
|
47
|
+
# Inline form: private_class_method def self.method_name
|
|
48
|
+
return false if node.parent&.send_type? && node.parent.method_name == :private_class_method
|
|
49
|
+
|
|
50
|
+
# Post-hoc form: private_class_method :method_name
|
|
51
|
+
class_node = find_class_or_module(node)
|
|
52
|
+
return true unless class_node&.body
|
|
53
|
+
|
|
54
|
+
!private_class_method_declared?(class_node, node.method_name)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def private_class_method_declared?(class_node, method_name)
|
|
58
|
+
children = class_node.body.begin_type? ? class_node.body.children : [class_node.body]
|
|
59
|
+
children.any? { |child| private_class_method_call?(child, method_name) }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def private_class_method_call?(node, method_name)
|
|
63
|
+
node&.send_type? &&
|
|
64
|
+
node.method_name == :private_class_method &&
|
|
65
|
+
node.arguments.any? { |arg| arg.sym_type? && arg.value == method_name }
|
|
66
|
+
end
|
|
67
|
+
|
|
46
68
|
def checkable_method?(node)
|
|
47
69
|
should_check_file? && !excluded_method?(node.method_name.to_s)
|
|
48
70
|
end
|
|
@@ -11,15 +11,27 @@ module RuboCop
|
|
|
11
11
|
class_node = find_class_or_module(node)
|
|
12
12
|
|
|
13
13
|
if class_node
|
|
14
|
-
# Get the class/module name from the AST
|
|
15
14
|
const_node = class_node.children[0]
|
|
16
|
-
return
|
|
15
|
+
return fully_qualified_class_name(class_node) if const_node.const_type?
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
# Fallback: infer class name from file path
|
|
20
19
|
infer_class_name_from_path
|
|
21
20
|
end
|
|
22
21
|
|
|
22
|
+
def fully_qualified_class_name(class_node)
|
|
23
|
+
names = [class_node.children[0].const_name]
|
|
24
|
+
current = class_node
|
|
25
|
+
|
|
26
|
+
while (ancestor = current.each_ancestor.find { |n| n.class_type? || n.module_type? })
|
|
27
|
+
ancestor_const = ancestor.children[0]
|
|
28
|
+
names.unshift(ancestor_const.const_name) if ancestor_const.const_type?
|
|
29
|
+
current = ancestor
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
names.join("::")
|
|
33
|
+
end
|
|
34
|
+
|
|
23
35
|
def find_class_or_module(node)
|
|
24
36
|
node.each_ancestor.find { |n| n.class_type? || n.module_type? }
|
|
25
37
|
end
|