rubocop-minitest 0.38.0 → 0.38.1
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 +21 -5
- 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: 8f227146807c3a2a605338af21d7ebda21c753f90037b4a2d17a7e121d82668d
|
4
|
+
data.tar.gz: e540c97b3e0dba5992ea5257ffe30a940436f13adee3bda167bcbc02d7ee61e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9adc1ad2fb810eaff597344640b4a7173cb4c1f242fc971de9b7b9aa40027c4949cc71322f32ecad67ecfc4bdc8671820f3dc3af25b878622d05fdfef5a80fbf
|
7
|
+
data.tar.gz: 19107bec023fa27d15af5f31ae1be4adeb3aba5facf8d4a7f5cc2fd12a7e31b62ce96d685d9451bbd8075cb7a14a2267215515a28714d265cc8ef5d4e275674e
|
@@ -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
|
@@ -99,17 +114,18 @@ module RuboCop
|
|
99
114
|
end
|
100
115
|
end
|
101
116
|
|
117
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
102
118
|
def assertion_method?(node)
|
103
119
|
return false unless node
|
104
120
|
return assertion_method?(node.expression) if node.assignment? && node.respond_to?(:expression)
|
105
121
|
return false unless node.type?(:send, :any_block)
|
106
122
|
|
107
|
-
|
108
|
-
|
123
|
+
method_name = node.method_name
|
124
|
+
assertion_method = ASSERTION_PREFIXES.any? { |prefix| method_name.start_with?(prefix.to_s) }
|
109
125
|
|
110
|
-
|
111
|
-
end
|
126
|
+
assertion_method || node.method?(:flunk) || MATCHER_METHODS.include?(method_name)
|
112
127
|
end
|
128
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
113
129
|
|
114
130
|
def lifecycle_hook_method?(node)
|
115
131
|
node.def_type? && LIFECYCLE_HOOK_METHODS.include?(node.method_name)
|
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.1
|
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.7
|
178
173
|
specification_version: 4
|
179
174
|
summary: Automatic Minitest code style checking tool.
|
180
175
|
test_files: []
|