rubocop-minitest 0.23.2 → 0.25.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: ee4acdf54fd339c943921f0bb7ba2e99cd652d2be3e14c8a1c835436e14aa605
4
- data.tar.gz: d33499947d46061e36757f06fbd92666c45dc3efa7600124f0d2cdec62178c92
3
+ metadata.gz: 49b67a4071b6ba9e1499054507097424e25948f916e3ebbcf65603d4e0806b94
4
+ data.tar.gz: 46a351626a6ec6625d5e29fc0f04c47d61844bc28e2745172ea0bb8344936751
5
5
  SHA512:
6
- metadata.gz: 63bf17a69865c62245a43499c72c721c66aa7c4bb8d2f18e9c187ab7d5c5d4b6c47b8511db19a77d7b697d13883f4af430ad435c3f3f31e9503678b843883b93
7
- data.tar.gz: a22a130e89bf44ef0a6b457caf0877e001197bea8a8e34bd099525d880c97e05baf06b9dbe1b76e57ae114bc6ec3b0579b6ade84720238b9c54e4d6a160a9b7d
6
+ metadata.gz: 4abcc9e3035a7e7a2902b27442f02f46a9494a2894acb5f5c98d18293d4c0d1ab94e32b2508bf1b23988cca436f7b7d4fd784dfe09fc21fae0c70ba2d6ef80ec
7
+ data.tar.gz: 6d669e4ff6e60a729a64c5ea87d4f91a20022f4a47cda95a52a10f6084de258a497d66ceeb71c0c08c1e8bbf8538823ac534349ec7644c24ab35df5b8317b30f
data/config/default.yml CHANGED
@@ -239,6 +239,11 @@ Minitest/SkipEnsure:
239
239
  Enabled: pending
240
240
  VersionAdded: '0.20'
241
241
 
242
+ Minitest/SkipWithoutReason:
243
+ Description: 'Checks for skipped tests missing the skipping reason.'
244
+ Enabled: pending
245
+ VersionAdded: '0.24'
246
+
242
247
  Minitest/TestMethodName:
243
248
  Description: 'This cop enforces that test method names start with `test_` prefix.'
244
249
  Enabled: 'pending'
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Minitest
6
+ # Checks for skipped tests missing the skipping reason.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # skip
11
+ # skip('')
12
+ #
13
+ # # bad
14
+ # if condition?
15
+ # skip
16
+ # else
17
+ # skip
18
+ # end
19
+ #
20
+ # # good
21
+ # skip("Reason why the test was skipped")
22
+ #
23
+ # # good
24
+ # skip if condition?
25
+ #
26
+ class SkipWithoutReason < Base
27
+ MSG = 'Add a reason explaining why the test is skipped.'
28
+
29
+ RESTRICT_ON_SEND = %i[skip].freeze
30
+
31
+ def on_send(node)
32
+ return if node.receiver || !blank_argument?(node)
33
+
34
+ conditional_node = conditional_parent(node)
35
+ return if conditional_node && !only_skip_branches?(conditional_node)
36
+
37
+ return if node.parent&.resbody_type?
38
+
39
+ add_offense(node)
40
+ end
41
+
42
+ private
43
+
44
+ def blank_argument?(node)
45
+ message = node.first_argument
46
+ message.nil? || (message.str_type? && message.value == '')
47
+ end
48
+
49
+ def conditional_parent(node)
50
+ return unless (parent = node.parent)
51
+
52
+ if parent.if_type? || parent.case_type?
53
+ parent
54
+ elsif parent.when_type?
55
+ parent.parent
56
+ end
57
+ end
58
+
59
+ def only_skip_branches?(node)
60
+ branches = node.branches.compact
61
+ branches.size > 1 && branches.all? { |branch| branch.send_type? && branch.method?(:skip) }
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -44,6 +44,7 @@ require_relative 'minitest/refute_path_exists'
44
44
  require_relative 'minitest/refute_predicate'
45
45
  require_relative 'minitest/refute_respond_to'
46
46
  require_relative 'minitest/skip_ensure'
47
+ require_relative 'minitest/skip_without_reason'
47
48
  require_relative 'minitest/test_method_name'
48
49
  require_relative 'minitest/unreachable_assertion'
49
50
  require_relative 'minitest/unspecified_exception'
@@ -38,7 +38,7 @@ module RuboCop
38
38
 
39
39
  # Support Active Support's `test 'example' { ... }` method.
40
40
  # https://api.rubyonrails.org/classes/ActiveSupport/Testing/Declarative.html
41
- test_blocks = class_node.each_descendant(:block).select { |block_node| block_node.method?(:test) }
41
+ test_blocks = class_node.each_descendant(:block).select { |block| block.method?(:test) || block.method?(:it) }
42
42
 
43
43
  test_cases + test_blocks
44
44
  end
@@ -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.23.2'
7
+ STRING = '0.25.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.23.2
4
+ version: 0.25.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: 2022-11-11 00:00:00.000000000 Z
13
+ date: 2022-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -97,6 +97,7 @@ files:
97
97
  - lib/rubocop/cop/minitest/refute_predicate.rb
98
98
  - lib/rubocop/cop/minitest/refute_respond_to.rb
99
99
  - lib/rubocop/cop/minitest/skip_ensure.rb
100
+ - lib/rubocop/cop/minitest/skip_without_reason.rb
100
101
  - lib/rubocop/cop/minitest/test_method_name.rb
101
102
  - lib/rubocop/cop/minitest/unreachable_assertion.rb
102
103
  - lib/rubocop/cop/minitest/unspecified_exception.rb
@@ -119,7 +120,7 @@ metadata:
119
120
  homepage_uri: https://docs.rubocop.org/rubocop-minitest/
120
121
  changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
121
122
  source_code_uri: https://github.com/rubocop/rubocop-minitest
122
- documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.23
123
+ documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.25
123
124
  bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
124
125
  rubygems_mfa_required: 'true'
125
126
  post_install_message:
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  requirements: []
140
- rubygems_version: 3.3.7
141
+ rubygems_version: 3.3.26
141
142
  signing_key:
142
143
  specification_version: 4
143
144
  summary: Automatic Minitest code style checking tool.