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: 2d2f62960e2b46b31972221b577d79aed5b54db2f90b6d9cf277dcaa9b432e92
4
- data.tar.gz: 320594b7e229f9910535fe7e30233a1f0d56a286676cc8fc636cd782f1c8f113
3
+ metadata.gz: 7f6cb712ad716f1a6c82659cd5114785bd93f7ed7344fb2ba6317de8bae3d37e
4
+ data.tar.gz: 2588d5b16c636142a361c2d0723d049099e7e1da76ed30b72b0c78b211734fb9
5
5
  SHA512:
6
- metadata.gz: da7f6916ecd8946f04ffdf8d67af1c566cbee961d120e2e1ad8fd2d78c8b0238989d4321b5eb5f3179aee0d28197bc88284283bffed042019001cffbaf2d2fc3
7
- data.tar.gz: 43653613dfcef10d0a7c21485171a9532c045372354fc1df0ae244d436e4076568696b3b38591e015d0cd75360d39762d19243bd9ab1424a089530f2b04cd693
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 const_node.const_name if const_node.const_type?
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module RSpecParity
5
- VERSION = "1.2.0"
5
+ VERSION = "1.2.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.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Povilas Jurcys