rubocop-minitest 0.38.0 → 0.38.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/lib/rubocop/cop/minitest/global_expectations.rb +4 -14
- data/lib/rubocop/cop/minitest/no_assertions.rb +19 -0
- data/lib/rubocop/cop/{generator.rb → minitest_generator.rb} +5 -1
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +24 -6
- data/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb +1 -1
- data/lib/rubocop/minitest/version.rb +1 -1
- metadata +4 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9b5ea8a4137a723a3fa2dd0a77f58667f3c91f64dc2396e7db1c80865415bc4
|
4
|
+
data.tar.gz: 61a9a98f38a54140e137ae6c87e846305f1c2c015d4bc5a17207693623babca1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d9fc8561127373fc7d3d344192042e8ea6fb69137b9d6cb30589aa15ba625369709b415ce115a92d152d284d1da3f848be7c54052a71caf547d6342d3a263b0
|
7
|
+
data.tar.gz: 8ba825723997d2cbd9f84287eb32b7bd82c47a501b074674dc929ecb6b5646b3d18d5335f170eae7766c388d59ee3b16c95d04598ed547ec3111293ebe38b7ec
|
@@ -87,20 +87,10 @@ module RuboCop
|
|
87
87
|
|
88
88
|
MSG = 'Use `%<preferred>s` instead.'
|
89
89
|
|
90
|
-
VALUE_MATCHERS =
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
path_must_exist path_wont_exist wont_be_empty wont_equal wont_be_close_to
|
95
|
-
wont_be_within_delta wont_be_within_epsilon wont_include wont_be_instance_of
|
96
|
-
wont_be_kind_of wont_match wont_be_nil wont_be wont_respond_to wont_be_same_as
|
97
|
-
].freeze
|
98
|
-
|
99
|
-
BLOCK_MATCHERS = %i[
|
100
|
-
must_output must_pattern_match must_raise must_be_silent must_throw wont_pattern_match
|
101
|
-
].freeze
|
102
|
-
|
103
|
-
RESTRICT_ON_SEND = VALUE_MATCHERS + BLOCK_MATCHERS
|
90
|
+
VALUE_MATCHERS = MinitestExplorationHelpers::VALUE_MATCHERS
|
91
|
+
BLOCK_MATCHERS = MinitestExplorationHelpers::BLOCK_MATCHERS
|
92
|
+
|
93
|
+
RESTRICT_ON_SEND = MinitestExplorationHelpers::MATCHER_METHODS
|
104
94
|
|
105
95
|
# There are aliases for the `_` method - `expect` and `value`
|
106
96
|
DSL_METHODS = %i[_ expect value].freeze
|
@@ -5,6 +5,8 @@ module RuboCop
|
|
5
5
|
module Minitest
|
6
6
|
# Checks if test cases contain any assertion calls.
|
7
7
|
#
|
8
|
+
# Matchers such as `must_equal` and `wont_match` are also treated as assertion methods.
|
9
|
+
#
|
8
10
|
# @example
|
9
11
|
# # bad
|
10
12
|
# class FooTest < Minitest::Test
|
@@ -19,6 +21,23 @@ module RuboCop
|
|
19
21
|
# end
|
20
22
|
# end
|
21
23
|
#
|
24
|
+
# # bad
|
25
|
+
# class FooTest < ActiveSupport::TestCase
|
26
|
+
# describe 'foo' do
|
27
|
+
# it 'test equal' do
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # good
|
33
|
+
# class FooTest < ActiveSupport::TestCase
|
34
|
+
# describe 'foo' do
|
35
|
+
# it 'test equal' do
|
36
|
+
# musts.must_equal expected_musts
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
22
41
|
class NoAssertions < Base
|
23
42
|
include MinitestExplorationHelpers
|
24
43
|
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'rubocop/cop/generator'
|
4
|
+
|
3
5
|
module RuboCop
|
4
6
|
module Cop
|
5
7
|
# Source and test generator for new cops
|
6
8
|
#
|
7
9
|
# This generator will take a cop name and generate a source file
|
8
10
|
# and test file when given a valid qualified cop name.
|
9
|
-
|
11
|
+
module MinitestGenerator
|
10
12
|
TEST_TEMPLATE = <<~TEST
|
11
13
|
# frozen_string_literal: true
|
12
14
|
|
@@ -48,3 +50,5 @@ module RuboCop
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
53
|
+
|
54
|
+
RuboCop::Cop::Generator.include(RuboCop::Cop::MinitestGenerator)
|
@@ -10,7 +10,22 @@ module RuboCop
|
|
10
10
|
include DefNode
|
11
11
|
extend NodePattern::Macros
|
12
12
|
|
13
|
-
|
13
|
+
VALUE_MATCHERS = %i[
|
14
|
+
must_be_empty must_equal must_be_close_to must_be_within_delta
|
15
|
+
must_be_within_epsilon must_include must_be_instance_of must_be_kind_of
|
16
|
+
must_match must_be_nil must_be must_respond_to must_be_same_as
|
17
|
+
path_must_exist path_wont_exist wont_be_empty wont_equal wont_be_close_to
|
18
|
+
wont_be_within_delta wont_be_within_epsilon wont_include wont_be_instance_of
|
19
|
+
wont_be_kind_of wont_match wont_be_nil wont_be wont_respond_to wont_be_same_as
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
BLOCK_MATCHERS = %i[
|
23
|
+
must_output must_pattern_match must_raise must_be_silent must_throw wont_pattern_match
|
24
|
+
].freeze
|
25
|
+
|
26
|
+
MATCHER_METHODS = VALUE_MATCHERS + BLOCK_MATCHERS
|
27
|
+
|
28
|
+
ASSERTION_PREFIXES = %i[assert refute].freeze
|
14
29
|
|
15
30
|
LIFECYCLE_HOOK_METHODS_IN_ORDER = %i[
|
16
31
|
before_setup
|
@@ -104,16 +119,19 @@ module RuboCop
|
|
104
119
|
return assertion_method?(node.expression) if node.assignment? && node.respond_to?(:expression)
|
105
120
|
return false unless node.type?(:send, :any_block)
|
106
121
|
|
107
|
-
|
108
|
-
method_name = node.method_name
|
109
|
-
|
110
|
-
method_name.start_with?(prefix) || node.method?(:flunk)
|
111
|
-
end
|
122
|
+
assertion_prefix_method?(node) || node.method?(:flunk) || MATCHER_METHODS.include?(node.method_name)
|
112
123
|
end
|
113
124
|
|
114
125
|
def lifecycle_hook_method?(node)
|
115
126
|
node.def_type? && LIFECYCLE_HOOK_METHODS.include?(node.method_name)
|
116
127
|
end
|
128
|
+
|
129
|
+
def assertion_prefix_method?(node)
|
130
|
+
return false if node.receiver
|
131
|
+
|
132
|
+
method_name = node.method_name
|
133
|
+
ASSERTION_PREFIXES.any? { |prefix| method_name.start_with?(prefix.to_s) }
|
134
|
+
end
|
117
135
|
end
|
118
136
|
end
|
119
137
|
end
|
@@ -11,7 +11,7 @@ module RuboCop
|
|
11
11
|
def on_send(node)
|
12
12
|
return if node.first_argument&.any_block_type?
|
13
13
|
return unless predicate_method?(node.first_argument)
|
14
|
-
return unless node.first_argument.arguments.
|
14
|
+
return unless node.first_argument.arguments.none?
|
15
15
|
|
16
16
|
add_offense(node, message: offense_message(node.arguments)) do |corrector|
|
17
17
|
autocorrect(corrector, node, node.arguments)
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.38.
|
4
|
+
version: 0.38.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
8
8
|
- Jonas Arvidsson
|
9
9
|
- Koichi ITO
|
10
|
-
autorequire:
|
11
10
|
bindir: exe
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: lint_roller
|
@@ -69,7 +68,6 @@ dependencies:
|
|
69
68
|
description: |
|
70
69
|
Automatic Minitest code style checking tool.
|
71
70
|
A RuboCop extension focused on enforcing Minitest best practices and coding conventions.
|
72
|
-
email:
|
73
71
|
executables: []
|
74
72
|
extensions: []
|
75
73
|
extra_rdoc_files: []
|
@@ -78,7 +76,6 @@ files:
|
|
78
76
|
- README.md
|
79
77
|
- config/default.yml
|
80
78
|
- lib/rubocop-minitest.rb
|
81
|
-
- lib/rubocop/cop/generator.rb
|
82
79
|
- lib/rubocop/cop/minitest/assert_empty.rb
|
83
80
|
- lib/rubocop/cop/minitest/assert_empty_literal.rb
|
84
81
|
- lib/rubocop/cop/minitest/assert_equal.rb
|
@@ -135,6 +132,7 @@ files:
|
|
135
132
|
- lib/rubocop/cop/minitest/unspecified_exception.rb
|
136
133
|
- lib/rubocop/cop/minitest/useless_assertion.rb
|
137
134
|
- lib/rubocop/cop/minitest_cops.rb
|
135
|
+
- lib/rubocop/cop/minitest_generator.rb
|
138
136
|
- lib/rubocop/cop/mixin/argument_range_helper.rb
|
139
137
|
- lib/rubocop/cop/mixin/in_delta_mixin.rb
|
140
138
|
- lib/rubocop/cop/mixin/instance_of_assertion_handleable.rb
|
@@ -147,7 +145,6 @@ files:
|
|
147
145
|
- lib/rubocop/minitest/plugin.rb
|
148
146
|
- lib/rubocop/minitest/support.rb
|
149
147
|
- lib/rubocop/minitest/version.rb
|
150
|
-
homepage:
|
151
148
|
licenses:
|
152
149
|
- MIT
|
153
150
|
metadata:
|
@@ -158,7 +155,6 @@ metadata:
|
|
158
155
|
bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
|
159
156
|
rubygems_mfa_required: 'true'
|
160
157
|
default_lint_roller_plugin: RuboCop::Minitest::Plugin
|
161
|
-
post_install_message:
|
162
158
|
rdoc_options: []
|
163
159
|
require_paths:
|
164
160
|
- lib
|
@@ -173,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
169
|
- !ruby/object:Gem::Version
|
174
170
|
version: '0'
|
175
171
|
requirements: []
|
176
|
-
rubygems_version: 3.
|
177
|
-
signing_key:
|
172
|
+
rubygems_version: 3.6.9
|
178
173
|
specification_version: 4
|
179
174
|
summary: Automatic Minitest code style checking tool.
|
180
175
|
test_files: []
|