rubocop-minitest 0.28.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4d321b9b8d16e6c5c3cf304835e7c48fde65c173202925d3e072c779c90bb86
4
- data.tar.gz: 40856b7d83975172736776deae22bb7f62d5d9b913674bb354a6c7cbf7011882
3
+ metadata.gz: 938714064905717403a5e63e0cfcca49356b3240c85f2fc26247faefa08ff65f
4
+ data.tar.gz: 2db37113c89cc16952a020d3a42f4cf3b94ee067b85b3460c0ef9786c69fe338
5
5
  SHA512:
6
- metadata.gz: 54a62f0f9510ef6d00dedccc0f59672446f70fea23d12e63cab8915423932aff0921fde8b52e44ce6b93543a0c43a9726867aeb50a84fae1d8e79a3e0ec40f38
7
- data.tar.gz: 45a933d110a001cb8ada63094fadfb918c814b85c2d68154fc7f1180488f9937a5858a8db2abca0ba7a80323be9ea11e5940df21736ce69166aaf2947388c276
6
+ metadata.gz: c9322ed01a4e6598b65742584421c1e92609d8340e6e077df7eb4126abdf842e646ff33a7ae6577ab1649bc2a9ab212645d607fe3db467596a0e8d61517f823e
7
+ data.tar.gz: bd62a8d102301b4898ab9c23696b8159bb0ba4c3257d37c7e91ba70263d72bf887cfb257e6e0fa060101305f011cf707d47fa69c82e9b1ce4701a47252ab7b35
@@ -36,8 +36,7 @@ module RuboCop
36
36
  private
37
37
 
38
38
  def find_test_case(node)
39
- def_ancestor = node.each_ancestor(:def).first
40
- def_ancestor if test_case?(def_ancestor)
39
+ node.each_ancestor.find { |ancestor| test_case?(ancestor) }
41
40
  end
42
41
 
43
42
  def references_gvar?(assertion, gvar_name)
@@ -32,7 +32,7 @@ module RuboCop
32
32
 
33
33
  next if assertions_count.positive?
34
34
 
35
- add_offense(node.block_type? ? node.loc.expression : node.loc.name)
35
+ add_offense(node.block_type? ? node.source_range : node.loc.name)
36
36
  end
37
37
  end
38
38
  end
@@ -30,22 +30,23 @@ module RuboCop
30
30
  end
31
31
 
32
32
  def test_case?(node)
33
- return false unless node&.def_type? && test_method?(node)
33
+ return false unless (node&.def_type? && test_method?(node)) ||
34
+ (node&.block_type? && test_block?(node))
34
35
 
35
36
  class_ancestor = node.each_ancestor(:class).first
36
37
  test_class?(class_ancestor)
37
38
  end
38
39
 
39
40
  def test_cases(class_node, visibility_check: true)
40
- test_cases = class_def_nodes(class_node).select do |def_node|
41
+ test_methods = class_def_nodes(class_node).select do |def_node|
41
42
  test_method?(def_node, visibility_check: visibility_check)
42
43
  end
43
44
 
44
45
  # Support Active Support's `test 'example' { ... }` method.
45
46
  # https://api.rubyonrails.org/classes/ActiveSupport/Testing/Declarative.html
46
- test_blocks = class_node.each_descendant(:block).select { |block| block.method?(:test) || block.method?(:it) }
47
+ test_blocks = class_node.each_descendant(:block).select { |block_node| test_block?(block_node) }
47
48
 
48
- test_cases + test_blocks
49
+ test_methods + test_blocks
49
50
  end
50
51
 
51
52
  def test_method?(def_node, visibility_check: true)
@@ -54,6 +55,10 @@ module RuboCop
54
55
  test_case_name?(def_node.method_name) && !def_node.arguments?
55
56
  end
56
57
 
58
+ def test_block?(block_node)
59
+ block_node.method?(:test) || block_node.method?(:it)
60
+ end
61
+
57
62
  def lifecycle_hooks(class_node)
58
63
  class_def_nodes(class_node)
59
64
  .select { |def_node| lifecycle_hook_method?(def_node) }
@@ -124,7 +124,7 @@ module RuboCop
124
124
  end
125
125
 
126
126
  def _investigate(cop, processed_source)
127
- team = RuboCop::Cop::Team.new([cop], nil, raise_error: true)
127
+ team = RuboCop::Cop::Team.new([cop], configuration, raise_error: true)
128
128
  report = team.investigate(processed_source)
129
129
  @last_corrector = report.correctors.first || RuboCop::Cop::Corrector.new(processed_source)
130
130
  report.offenses
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Minitest
5
5
  # This module holds the RuboCop Minitest version information.
6
6
  module Version
7
- STRING = '0.28.0'
7
+ STRING = '0.29.0'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-02-20 00:00:00.000000000 Z
13
+ date: 2023-03-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -112,7 +112,7 @@ metadata:
112
112
  homepage_uri: https://docs.rubocop.org/rubocop-minitest/
113
113
  changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
114
114
  source_code_uri: https://github.com/rubocop/rubocop-minitest
115
- documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.28
115
+ documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.29
116
116
  bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
117
117
  rubygems_mfa_required: 'true'
118
118
  post_install_message: