rubocop-minitest 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -3
- data/CHANGELOG.md +22 -0
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/Rakefile +29 -0
- data/config/default.yml +95 -16
- data/docs/antora.yml +7 -0
- data/docs/modules/ROOT/nav.adoc +6 -0
- data/docs/modules/ROOT/pages/cops.adoc +37 -0
- data/docs/modules/ROOT/pages/cops_minitest.adoc +1014 -0
- data/docs/modules/ROOT/pages/index.adoc +5 -0
- data/docs/modules/ROOT/pages/installation.adoc +15 -0
- data/docs/modules/ROOT/pages/usage.adoc +32 -0
- data/{manual → legacy-docs}/cops.md +0 -0
- data/{manual → legacy-docs}/cops_minitest.md +0 -0
- data/{manual → legacy-docs}/index.md +0 -0
- data/{manual → legacy-docs}/installation.md +0 -0
- data/{manual → legacy-docs}/usage.md +0 -0
- data/lib/rubocop/cop/generator.rb +56 -0
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +15 -0
- data/lib/rubocop/cop/minitest/assert_in_delta.rb +27 -0
- data/lib/rubocop/cop/minitest/assert_kind_of.rb +25 -0
- data/lib/rubocop/cop/minitest/assert_output.rb +49 -0
- data/lib/rubocop/cop/minitest/assert_path_exists.rb +58 -0
- data/lib/rubocop/cop/minitest/assert_silent.rb +45 -0
- data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +43 -0
- data/lib/rubocop/cop/minitest/global_expectations.rb +2 -4
- data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +52 -0
- data/lib/rubocop/cop/minitest/multiple_assertions.rb +63 -0
- data/lib/rubocop/cop/minitest/refute_in_delta.rb +27 -0
- data/lib/rubocop/cop/minitest/refute_kind_of.rb +25 -0
- data/lib/rubocop/cop/minitest/refute_path_exists.rb +58 -0
- data/lib/rubocop/cop/minitest/test_method_name.rb +70 -0
- data/lib/rubocop/cop/minitest/unspecified_exception.rb +36 -0
- data/lib/rubocop/cop/minitest_cops.rb +15 -0
- data/lib/rubocop/cop/mixin/argument_range_helper.rb +10 -0
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +50 -0
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +84 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- data/mkdocs.yml +2 -2
- data/relnotes/v0.10.0.md +21 -0
- data/rubocop-minitest.gemspec +3 -3
- data/tasks/cops_documentation.rake +83 -52
- data/tasks/cut_release.rake +16 -0
- metadata +35 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba38b8b45ed71a06486486456dbda0e2d833f58ccf59fc7e22ecb3a1d4ec2dd7
|
4
|
+
data.tar.gz: 5f5260b7699852144213e044386662b3168eff83068ee88257df478fd79c7314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: accc29f0bf8c2c80404a0777122446bea1ed7a6d57809b68b4ca21f66aedecdc161c3f29dd0777a61a2bccda158da3cb20892470994d335a4da63a2c09fbc80a
|
7
|
+
data.tar.gz: 8c3c5b4f73bd953c7ced000471c3e91645e36c240d7e73f04631487344c3a9e14152b2c83b3d6dccdf3530936007deb4e3dbc819c6b28e86a34ef5b821802375
|
data/.rubocop.yml
CHANGED
@@ -8,6 +8,7 @@ require:
|
|
8
8
|
- rubocop-minitest
|
9
9
|
|
10
10
|
AllCops:
|
11
|
+
NewCops: enable
|
11
12
|
TargetRubyVersion: 2.4
|
12
13
|
|
13
14
|
Naming/PredicateName:
|
@@ -47,9 +48,6 @@ Layout/ClassStructure:
|
|
47
48
|
- protected_methods
|
48
49
|
- private_methods
|
49
50
|
|
50
|
-
Layout/LineLength:
|
51
|
-
Max: 120
|
52
|
-
|
53
51
|
# Trailing white space is meaningful in code examples
|
54
52
|
Layout/TrailingWhitespace:
|
55
53
|
AllowInHeredoc: true
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,26 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.10.0 (2020-07-12)
|
6
|
+
|
7
|
+
### New features
|
8
|
+
|
9
|
+
* [#92](https://github.com/rubocop-hq/rubocop-minitest/pull/92): Add new `Minitest/LiteralAsActualArgument` cop. ([@fatkodima][], [@tsmmark][])
|
10
|
+
* [#95](https://github.com/rubocop-hq/rubocop-minitest/pull/95): Add new `Minitest/AssertionInLifecycleHook` cop. ([@fatkodima][])
|
11
|
+
* [#91](https://github.com/rubocop-hq/rubocop-minitest/pull/91): Add new `Minitest/AssertInDelta` and `Minitest/RefuteInDelta` cops. ([@fatkodima][])
|
12
|
+
* [#89](https://github.com/rubocop-hq/rubocop-minitest/pull/89): Add new `Minitest/TestMethodName` cop. ([@fatkodima][])
|
13
|
+
* [#83](https://github.com/rubocop-hq/rubocop-minitest/pull/83): New cops `AssertPathExists` and `RefutePathExists` check for use of `assert_path_exists`/`refute_path_exists` instead of `assert(File.exist?(path))`/`refute(File.exist?(path))`. ([@fatkodima][])
|
14
|
+
* [#88](https://github.com/rubocop-hq/rubocop-minitest/pull/88): Add new `Minitest/MultipleAssertions` cop. ([@fatkodima][])
|
15
|
+
* [#87](https://github.com/rubocop-hq/rubocop-minitest/pull/87): Add new `Minitest/AssertSilent` cop. ([@fatkodima][])
|
16
|
+
* [#96](https://github.com/rubocop-hq/rubocop-minitest/pull/96): Add new `Minitest/UnspecifiedException` cop. ([@fatkodima][])
|
17
|
+
* [#98](https://github.com/rubocop-hq/rubocop-minitest/pull/98): Add new `Minitest/AssertOutput` cop. ([@fatkodima][])
|
18
|
+
* [#84](https://github.com/rubocop-hq/rubocop-minitest/pull/84): New cops `AssertKindOf` and `RefuteKindOf` check for use of `assert_kind_of`/`refute_kind_of` instead of `assert(foo.kind_of?(Class))`/`refute(foo.kind_of?(Class))`. ([@fatkodima][])
|
19
|
+
* [#85](https://github.com/rubocop-hq/rubocop-minitest/pull/85): Add autocorrect to `Rails/AssertEmptyLiteral` cop. ([@fatkodima][])
|
20
|
+
|
21
|
+
### Changes
|
22
|
+
|
23
|
+
* [#104](https://github.com/rubocop-hq/rubocop-minitest/pull/104): Require RuboCop 0.87 or higher. ([@koic][])
|
24
|
+
|
5
25
|
## 0.9.0 (2020-04-13)
|
6
26
|
|
7
27
|
### Bug fixes
|
@@ -137,3 +157,5 @@
|
|
137
157
|
[@herwinw]: https://github.com/herwinw
|
138
158
|
[@fsateler]: https://github.com/fsateler
|
139
159
|
[@andrykonchin]: https://github.com/andrykonchin
|
160
|
+
[@fatkodima]: https://github.com/fatkodima
|
161
|
+
[@tsmmark]: https://github.com/tsmmark
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -62,7 +62,7 @@ end
|
|
62
62
|
|
63
63
|
All cops are located under
|
64
64
|
[`lib/rubocop/cop/minitest`](lib/rubocop/cop/minitest), and contain
|
65
|
-
examples/documentation. The documentation is published [here](https://docs.rubocop.org/
|
65
|
+
examples/documentation. The documentation is published [here](https://docs.rubocop.org/rubocop-minitest/).
|
66
66
|
|
67
67
|
In your `.rubocop.yml`, you may treat the Minitest cops just like any other
|
68
68
|
cop. For example:
|
@@ -75,7 +75,7 @@ Minitest/AssertNil:
|
|
75
75
|
|
76
76
|
## Documentation
|
77
77
|
|
78
|
-
You can read a lot more about RuboCop Minitest in its [official docs](https://docs.rubocop.org/
|
78
|
+
You can read a lot more about RuboCop Minitest in its [official docs](https://docs.rubocop.org/rubocop-minitest/).
|
79
79
|
|
80
80
|
## Contributing
|
81
81
|
|
data/Rakefile
CHANGED
@@ -15,6 +15,7 @@ end
|
|
15
15
|
|
16
16
|
require 'rubocop/rake_task'
|
17
17
|
require 'rake/testtask'
|
18
|
+
require_relative 'lib/rubocop/cop/generator'
|
18
19
|
|
19
20
|
Rake::TestTask.new do |t|
|
20
21
|
t.libs << 'test'
|
@@ -36,3 +37,31 @@ task default: %i[
|
|
36
37
|
test
|
37
38
|
internal_investigation
|
38
39
|
]
|
40
|
+
|
41
|
+
desc 'Generate a new cop template'
|
42
|
+
task :new_cop, [:cop] do |_task, args|
|
43
|
+
require 'rubocop'
|
44
|
+
|
45
|
+
cop_name = args.fetch(:cop) do
|
46
|
+
warn 'usage: bundle exec rake new_cop[Department/Name]'
|
47
|
+
exit!
|
48
|
+
end
|
49
|
+
|
50
|
+
github_user = `git config github.user`.chop
|
51
|
+
github_user = 'your_id' if github_user.empty?
|
52
|
+
|
53
|
+
generator = RuboCop::Cop::Generator.new(cop_name, github_user)
|
54
|
+
|
55
|
+
generator.write_source
|
56
|
+
generator.write_test
|
57
|
+
generator.inject_require(root_file_path: 'lib/rubocop/cop/minitest_cops.rb')
|
58
|
+
generator.inject_config(config_file_path: 'config/default.yml', version_added: bump_minor_version)
|
59
|
+
|
60
|
+
puts generator.todo
|
61
|
+
end
|
62
|
+
|
63
|
+
def bump_minor_version
|
64
|
+
major, minor, _patch = RuboCop::Minitest::VERSION.split('.')
|
65
|
+
|
66
|
+
"#{major}.#{minor.succ}"
|
67
|
+
end
|
data/config/default.yml
CHANGED
@@ -6,106 +6,185 @@ Minitest:
|
|
6
6
|
|
7
7
|
Minitest/AssertEmpty:
|
8
8
|
Description: 'This cop enforces the test to use `assert_empty` instead of using `assert(object.empty?)`.'
|
9
|
-
StyleGuide: 'https://
|
9
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-empty'
|
10
10
|
Enabled: true
|
11
11
|
VersionAdded: '0.2'
|
12
12
|
|
13
13
|
Minitest/AssertEmptyLiteral:
|
14
14
|
Description: 'This cop enforces the test to use `assert_empty` instead of using `assert([], object)` or `assert({}, object)`.'
|
15
15
|
Enabled: true
|
16
|
+
SafeAutoCorrect: false
|
16
17
|
VersionAdded: '0.5'
|
18
|
+
VersionChanged: '0.10'
|
17
19
|
|
18
20
|
Minitest/AssertEqual:
|
19
21
|
Description: 'This cop enforces the test to use `assert_equal` instead of using `assert(expected == actual)`.'
|
20
|
-
StyleGuide: 'https://
|
22
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-equal-arguments-order'
|
21
23
|
Enabled: true
|
22
24
|
VersionAdded: '0.4'
|
23
25
|
|
26
|
+
Minitest/AssertInDelta:
|
27
|
+
Description: 'This cop enforces the test to use `assert_in_delta` instead of using `assert_equal` to compare floats.'
|
28
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#assert-in-delta'
|
29
|
+
Enabled: 'pending'
|
30
|
+
VersionAdded: '0.10'
|
31
|
+
|
32
|
+
Minitest/AssertionInLifecycleHook:
|
33
|
+
Description: 'This cop checks for usage of assertions in lifecycle hooks.'
|
34
|
+
Enabled: 'pending'
|
35
|
+
VersionAdded: '0.10'
|
36
|
+
|
24
37
|
Minitest/AssertMatch:
|
25
38
|
Description: 'This cop enforces the test to use `assert_match` instead of using `assert(matcher.match(object))`.'
|
26
|
-
StyleGuide: 'https://
|
39
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-match'
|
27
40
|
Enabled: true
|
28
41
|
VersionAdded: '0.6'
|
29
42
|
|
30
43
|
Minitest/AssertIncludes:
|
31
44
|
Description: 'This cop enforces the test to use `assert_includes` instead of using `assert(collection.include?(object))`.'
|
32
|
-
StyleGuide: 'https://
|
45
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-includes'
|
33
46
|
Enabled: true
|
34
47
|
VersionAdded: '0.2'
|
35
48
|
|
36
49
|
Minitest/AssertInstanceOf:
|
37
50
|
Description: 'This cop enforces the test to use `assert_instance_of(Class, object)` over `assert(object.instance_of?(Class))`'
|
38
|
-
StyleGuide: 'https://
|
51
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-instance-of'
|
39
52
|
Enabled: true
|
40
53
|
VersionAdded: '0.4'
|
41
54
|
|
55
|
+
Minitest/AssertKindOf:
|
56
|
+
Description: 'This cop enforces the test to use `assert_kind_of(Class, object)` over `assert(object.kind_of?(Class))`'
|
57
|
+
StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-kind-of'
|
58
|
+
Enabled: 'pending'
|
59
|
+
VersionAdded: '0.10'
|
60
|
+
|
42
61
|
Minitest/AssertNil:
|
43
62
|
Description: 'This cop enforces the test to use `assert_nil` instead of using `assert_equal(nil, something)`.'
|
44
|
-
StyleGuide: 'https://
|
63
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-nil'
|
45
64
|
Enabled: true
|
46
65
|
VersionAdded: '0.1'
|
47
66
|
|
67
|
+
Minitest/AssertOutput:
|
68
|
+
Description: 'This cop checks for opportunities to use `assert_output`.'
|
69
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#assert-output'
|
70
|
+
Enabled: 'pending'
|
71
|
+
VersionAdded: '0.10'
|
72
|
+
|
73
|
+
Minitest/AssertPathExists:
|
74
|
+
Description: 'This cop enforces the test to use `assert_path_exists` instead of using `assert(File.exist?(path))`.'
|
75
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#assert-path-exists'
|
76
|
+
Enabled: 'pending'
|
77
|
+
VersionAdded: '0.10'
|
78
|
+
|
48
79
|
Minitest/AssertRespondTo:
|
49
80
|
Description: 'This cop enforces the test to use `assert_respond_to(object, :do_something)` over `assert(object.respond_to?(:do_something))`.'
|
50
|
-
StyleGuide: 'https://
|
81
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-responds-to-method'
|
51
82
|
Enabled: true
|
52
83
|
VersionAdded: '0.3'
|
53
84
|
|
85
|
+
Minitest/AssertSilent:
|
86
|
+
Description: "This cop enforces the test to use `assert_silent { ... }` instead of using `assert_output('', '') { ... }`."
|
87
|
+
StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-silent'
|
88
|
+
Enabled: 'pending'
|
89
|
+
VersionAdded: '0.10'
|
90
|
+
|
54
91
|
Minitest/AssertTruthy:
|
55
92
|
Description: 'This cop enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.'
|
56
|
-
StyleGuide: 'https://
|
93
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-truthy'
|
57
94
|
Enabled: true
|
58
95
|
VersionAdded: '0.2'
|
59
96
|
|
60
97
|
Minitest/GlobalExpectations:
|
61
98
|
Description: 'This cop checks for deprecated global expectations.'
|
99
|
+
StyleGuide: 'https://minitest.rubystyle.guide#global-expectations'
|
62
100
|
Enabled: true
|
63
101
|
VersionAdded: '0.7'
|
64
102
|
|
103
|
+
Minitest/LiteralAsActualArgument:
|
104
|
+
Description: 'This cop enforces correct order of `expected` and `actual` arguments for `assert_equal`.'
|
105
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#assert-equal-arguments-order'
|
106
|
+
Enabled: 'pending'
|
107
|
+
VersionAdded: '0.10'
|
108
|
+
|
109
|
+
Minitest/MultipleAssertions:
|
110
|
+
Description: 'This cop checks if test cases contain too many assertion calls.'
|
111
|
+
Enabled: 'pending'
|
112
|
+
VersionAdded: '0.10'
|
113
|
+
Max: 3
|
114
|
+
|
65
115
|
Minitest/RefuteEmpty:
|
66
116
|
Description: 'This cop enforces to use `refute_empty` instead of using `refute(object.empty?)`.'
|
67
|
-
StyleGuide: 'https://
|
117
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-empty'
|
68
118
|
Enabled: true
|
69
119
|
VersionAdded: '0.3'
|
70
120
|
|
71
121
|
Minitest/RefuteEqual:
|
72
122
|
Description: 'Check if your test uses `refute_equal` instead of `assert(expected != object)` or `assert(! expected == object))`.'
|
73
|
-
StyleGuide: 'https://
|
123
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-equal'
|
74
124
|
Enabled: true
|
75
125
|
VersionAdded: '0.3'
|
76
126
|
|
77
127
|
Minitest/RefuteFalse:
|
78
128
|
Description: 'Check if your test uses `refute(actual)` instead of `assert_equal(false, actual)`.'
|
79
|
-
StyleGuide: 'https://
|
129
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-false'
|
80
130
|
Enabled: true
|
81
131
|
VersionAdded: '0.3'
|
82
132
|
|
133
|
+
Minitest/RefuteInDelta:
|
134
|
+
Description: 'This cop enforces the test to use `refute_in_delta` instead of using `refute_equal` to compare floats.'
|
135
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#refute-in-delta'
|
136
|
+
Enabled: 'pending'
|
137
|
+
VersionAdded: '0.10'
|
138
|
+
|
83
139
|
Minitest/RefuteIncludes:
|
84
140
|
Description: 'This cop enforces the test to use `refute_includes` instead of using `refute(collection.include?(object))`.'
|
85
|
-
StyleGuide: 'https://
|
141
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-includes'
|
86
142
|
Enabled: true
|
87
143
|
VersionAdded: '0.3'
|
88
144
|
|
89
145
|
Minitest/RefuteMatch:
|
90
146
|
Description: 'This cop enforces the test to use `refute_match` instead of using `refute(matcher.match(object))`.'
|
91
|
-
StyleGuide: 'https://
|
147
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-match'
|
92
148
|
Enabled: true
|
93
149
|
VersionAdded: '0.6'
|
94
150
|
|
95
151
|
Minitest/RefuteInstanceOf:
|
96
152
|
Description: 'This cop enforces the test to use `refute_instance_of(Class, object)` over `refute(object.instance_of?(Class))`.'
|
97
|
-
StyleGuide: 'https://
|
153
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-instance-of'
|
98
154
|
Enabled: true
|
99
155
|
VersionAdded: '0.4'
|
100
156
|
|
157
|
+
Minitest/RefuteKindOf:
|
158
|
+
Description: 'This cop enforces the test to use `refute_kind_of(Class, object)` over `refute(object.kind_of?(Class))`.'
|
159
|
+
StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-kind-of'
|
160
|
+
Enabled: 'pending'
|
161
|
+
VersionAdded: '0.10'
|
162
|
+
|
101
163
|
Minitest/RefuteNil:
|
102
164
|
Description: 'This cop enforces the test to use `refute_nil` instead of using `refute_equal(nil, something)`.'
|
103
|
-
StyleGuide: 'https://
|
165
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-nil'
|
104
166
|
Enabled: true
|
105
167
|
VersionAdded: '0.2'
|
106
168
|
|
169
|
+
Minitest/RefutePathExists:
|
170
|
+
Description: 'This cop enforces the test to use `refute_path_exists` instead of using `refute(File.exist?(path))`.'
|
171
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#refute-path-exists'
|
172
|
+
Enabled: 'pending'
|
173
|
+
VersionAdded: '0.10'
|
174
|
+
|
107
175
|
Minitest/RefuteRespondTo:
|
108
176
|
Description: 'This cop enforces the test to use `refute_respond_to(object, :do_something)` over `refute(object.respond_to?(:do_something))`.'
|
109
|
-
StyleGuide: 'https://
|
177
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-respond-to'
|
110
178
|
Enabled: true
|
111
179
|
VersionAdded: '0.4'
|
180
|
+
|
181
|
+
Minitest/TestMethodName:
|
182
|
+
Description: 'This cop enforces that test method names start with `test_` prefix.'
|
183
|
+
Enabled: 'pending'
|
184
|
+
VersionAdded: '0.10'
|
185
|
+
|
186
|
+
Minitest/UnspecifiedException:
|
187
|
+
Description: 'This cop checks for a specified error in `assert_raises`.'
|
188
|
+
StyleGuide: 'https://minitest.rubystyle.guide#unspecified-exception'
|
189
|
+
Enabled: 'pending'
|
190
|
+
VersionAdded: '0.10'
|
data/docs/antora.yml
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
// START_COP_LIST
|
2
|
+
|
3
|
+
= Department xref:cops_minitest.adoc[Minitest]
|
4
|
+
|
5
|
+
* xref:cops_minitest.adoc#minitestassertempty[Minitest/AssertEmpty]
|
6
|
+
* xref:cops_minitest.adoc#minitestassertemptyliteral[Minitest/AssertEmptyLiteral]
|
7
|
+
* xref:cops_minitest.adoc#minitestassertequal[Minitest/AssertEqual]
|
8
|
+
* xref:cops_minitest.adoc#minitestassertindelta[Minitest/AssertInDelta]
|
9
|
+
* xref:cops_minitest.adoc#minitestassertincludes[Minitest/AssertIncludes]
|
10
|
+
* xref:cops_minitest.adoc#minitestassertinstanceof[Minitest/AssertInstanceOf]
|
11
|
+
* xref:cops_minitest.adoc#minitestassertkindof[Minitest/AssertKindOf]
|
12
|
+
* xref:cops_minitest.adoc#minitestassertmatch[Minitest/AssertMatch]
|
13
|
+
* xref:cops_minitest.adoc#minitestassertnil[Minitest/AssertNil]
|
14
|
+
* xref:cops_minitest.adoc#minitestassertoutput[Minitest/AssertOutput]
|
15
|
+
* xref:cops_minitest.adoc#minitestassertpathexists[Minitest/AssertPathExists]
|
16
|
+
* xref:cops_minitest.adoc#minitestassertrespondto[Minitest/AssertRespondTo]
|
17
|
+
* xref:cops_minitest.adoc#minitestassertsilent[Minitest/AssertSilent]
|
18
|
+
* xref:cops_minitest.adoc#minitestasserttruthy[Minitest/AssertTruthy]
|
19
|
+
* xref:cops_minitest.adoc#minitestassertioninlifecyclehook[Minitest/AssertionInLifecycleHook]
|
20
|
+
* xref:cops_minitest.adoc#minitestglobalexpectations[Minitest/GlobalExpectations]
|
21
|
+
* xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument]
|
22
|
+
* xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions]
|
23
|
+
* xref:cops_minitest.adoc#minitestrefuteempty[Minitest/RefuteEmpty]
|
24
|
+
* xref:cops_minitest.adoc#minitestrefuteequal[Minitest/RefuteEqual]
|
25
|
+
* xref:cops_minitest.adoc#minitestrefutefalse[Minitest/RefuteFalse]
|
26
|
+
* xref:cops_minitest.adoc#minitestrefuteindelta[Minitest/RefuteInDelta]
|
27
|
+
* xref:cops_minitest.adoc#minitestrefuteincludes[Minitest/RefuteIncludes]
|
28
|
+
* xref:cops_minitest.adoc#minitestrefuteinstanceof[Minitest/RefuteInstanceOf]
|
29
|
+
* xref:cops_minitest.adoc#minitestrefutekindof[Minitest/RefuteKindOf]
|
30
|
+
* xref:cops_minitest.adoc#minitestrefutematch[Minitest/RefuteMatch]
|
31
|
+
* xref:cops_minitest.adoc#minitestrefutenil[Minitest/RefuteNil]
|
32
|
+
* xref:cops_minitest.adoc#minitestrefutepathexists[Minitest/RefutePathExists]
|
33
|
+
* xref:cops_minitest.adoc#minitestrefuterespondto[Minitest/RefuteRespondTo]
|
34
|
+
* xref:cops_minitest.adoc#minitesttestmethodname[Minitest/TestMethodName]
|
35
|
+
* xref:cops_minitest.adoc#minitestunspecifiedexception[Minitest/UnspecifiedException]
|
36
|
+
|
37
|
+
// END_COP_LIST
|
@@ -0,0 +1,1014 @@
|
|
1
|
+
= Minitest
|
2
|
+
|
3
|
+
== Minitest/AssertEmpty
|
4
|
+
|
5
|
+
|===
|
6
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
7
|
+
|
8
|
+
| Enabled
|
9
|
+
| Yes
|
10
|
+
| Yes
|
11
|
+
| 0.2
|
12
|
+
| -
|
13
|
+
|===
|
14
|
+
|
15
|
+
This cop enforces the test to use `assert_empty`
|
16
|
+
instead of using `assert(object.empty?)`.
|
17
|
+
|
18
|
+
=== Examples
|
19
|
+
|
20
|
+
[source,ruby]
|
21
|
+
----
|
22
|
+
# bad
|
23
|
+
assert(object.empty?)
|
24
|
+
assert(object.empty?, 'message')
|
25
|
+
|
26
|
+
# good
|
27
|
+
assert_empty(object)
|
28
|
+
assert_empty(object, 'message')
|
29
|
+
----
|
30
|
+
|
31
|
+
=== References
|
32
|
+
|
33
|
+
* https://minitest.rubystyle.guide#assert-empty
|
34
|
+
|
35
|
+
== Minitest/AssertEmptyLiteral
|
36
|
+
|
37
|
+
|===
|
38
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
39
|
+
|
40
|
+
| Enabled
|
41
|
+
| Yes
|
42
|
+
| Yes (Unsafe)
|
43
|
+
| 0.5
|
44
|
+
| 0.10
|
45
|
+
|===
|
46
|
+
|
47
|
+
This cop enforces the test to use `assert_empty`
|
48
|
+
instead of using `assert([], object)`.
|
49
|
+
|
50
|
+
=== Examples
|
51
|
+
|
52
|
+
[source,ruby]
|
53
|
+
----
|
54
|
+
# bad
|
55
|
+
assert([], object)
|
56
|
+
assert({}, object)
|
57
|
+
|
58
|
+
# good
|
59
|
+
assert_empty(object)
|
60
|
+
----
|
61
|
+
|
62
|
+
== Minitest/AssertEqual
|
63
|
+
|
64
|
+
|===
|
65
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
66
|
+
|
67
|
+
| Enabled
|
68
|
+
| Yes
|
69
|
+
| Yes
|
70
|
+
| 0.4
|
71
|
+
| -
|
72
|
+
|===
|
73
|
+
|
74
|
+
This cop enforces the use of `assert_equal(expected, actual)`
|
75
|
+
over `assert(expected == actual)`.
|
76
|
+
|
77
|
+
=== Examples
|
78
|
+
|
79
|
+
[source,ruby]
|
80
|
+
----
|
81
|
+
# bad
|
82
|
+
assert("rubocop-minitest" == actual)
|
83
|
+
|
84
|
+
# good
|
85
|
+
assert_equal("rubocop-minitest", actual)
|
86
|
+
----
|
87
|
+
|
88
|
+
=== References
|
89
|
+
|
90
|
+
* https://minitest.rubystyle.guide#assert-equal-arguments-order
|
91
|
+
|
92
|
+
== Minitest/AssertInDelta
|
93
|
+
|
94
|
+
|===
|
95
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
96
|
+
|
97
|
+
| Pending
|
98
|
+
| Yes
|
99
|
+
| Yes
|
100
|
+
| 0.10
|
101
|
+
| -
|
102
|
+
|===
|
103
|
+
|
104
|
+
This cop enforces the test to use `assert_in_delta`
|
105
|
+
instead of using `assert_equal` to compare floats.
|
106
|
+
|
107
|
+
=== Examples
|
108
|
+
|
109
|
+
[source,ruby]
|
110
|
+
----
|
111
|
+
# bad
|
112
|
+
assert_equal(0.2, actual)
|
113
|
+
assert_equal(0.2, actual, 'message')
|
114
|
+
|
115
|
+
# good
|
116
|
+
assert_in_delta(0.2, actual)
|
117
|
+
assert_in_delta(0.2, actual, 0.001, 'message')
|
118
|
+
----
|
119
|
+
|
120
|
+
=== References
|
121
|
+
|
122
|
+
* https://minitest.rubystyle.guide/#assert-in-delta
|
123
|
+
|
124
|
+
== Minitest/AssertIncludes
|
125
|
+
|
126
|
+
|===
|
127
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
128
|
+
|
129
|
+
| Enabled
|
130
|
+
| Yes
|
131
|
+
| Yes
|
132
|
+
| 0.2
|
133
|
+
| -
|
134
|
+
|===
|
135
|
+
|
136
|
+
This cop enforces the test to use `assert_includes`
|
137
|
+
instead of using `assert(collection.include?(object))`.
|
138
|
+
|
139
|
+
=== Examples
|
140
|
+
|
141
|
+
[source,ruby]
|
142
|
+
----
|
143
|
+
# bad
|
144
|
+
assert(collection.include?(object))
|
145
|
+
assert(collection.include?(object), 'message')
|
146
|
+
|
147
|
+
# good
|
148
|
+
assert_includes(collection, object)
|
149
|
+
assert_includes(collection, object, 'message')
|
150
|
+
----
|
151
|
+
|
152
|
+
=== References
|
153
|
+
|
154
|
+
* https://minitest.rubystyle.guide#assert-includes
|
155
|
+
|
156
|
+
== Minitest/AssertInstanceOf
|
157
|
+
|
158
|
+
|===
|
159
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
160
|
+
|
161
|
+
| Enabled
|
162
|
+
| Yes
|
163
|
+
| Yes
|
164
|
+
| 0.4
|
165
|
+
| -
|
166
|
+
|===
|
167
|
+
|
168
|
+
This cop enforces the test to use `assert_instance_of(Class, object)`
|
169
|
+
over `assert(object.instance_of?(Class))`.
|
170
|
+
|
171
|
+
=== Examples
|
172
|
+
|
173
|
+
[source,ruby]
|
174
|
+
----
|
175
|
+
# bad
|
176
|
+
assert(object.instance_of?(Class))
|
177
|
+
assert(object.instance_of?(Class), 'message')
|
178
|
+
|
179
|
+
# good
|
180
|
+
assert_instance_of(Class, object)
|
181
|
+
assert_instance_of(Class, object, 'message')
|
182
|
+
----
|
183
|
+
|
184
|
+
=== References
|
185
|
+
|
186
|
+
* https://minitest.rubystyle.guide#assert-instance-of
|
187
|
+
|
188
|
+
== Minitest/AssertKindOf
|
189
|
+
|
190
|
+
|===
|
191
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
192
|
+
|
193
|
+
| Pending
|
194
|
+
| Yes
|
195
|
+
| Yes
|
196
|
+
| 0.10
|
197
|
+
| -
|
198
|
+
|===
|
199
|
+
|
200
|
+
This cop enforces the test to use `assert_kind_of(Class, object)`
|
201
|
+
over `assert(object.kind_of?(Class))`.
|
202
|
+
|
203
|
+
=== Examples
|
204
|
+
|
205
|
+
[source,ruby]
|
206
|
+
----
|
207
|
+
# bad
|
208
|
+
assert(object.kind_of?(Class))
|
209
|
+
assert(object.kind_of?(Class), 'message')
|
210
|
+
|
211
|
+
# good
|
212
|
+
assert_kind_of(Class, object)
|
213
|
+
assert_kind_of(Class, object, 'message')
|
214
|
+
----
|
215
|
+
|
216
|
+
=== References
|
217
|
+
|
218
|
+
* https://github.com/rubocop-hq/minitest-style-guide#assert-kind-of
|
219
|
+
|
220
|
+
== Minitest/AssertMatch
|
221
|
+
|
222
|
+
|===
|
223
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
224
|
+
|
225
|
+
| Enabled
|
226
|
+
| Yes
|
227
|
+
| Yes
|
228
|
+
| 0.6
|
229
|
+
| -
|
230
|
+
|===
|
231
|
+
|
232
|
+
This cop enforces the test to use `assert_match`
|
233
|
+
instead of using `assert(matcher.match(string))`.
|
234
|
+
|
235
|
+
=== Examples
|
236
|
+
|
237
|
+
[source,ruby]
|
238
|
+
----
|
239
|
+
# bad
|
240
|
+
assert(matcher.match(string))
|
241
|
+
assert(matcher.match(string), 'message')
|
242
|
+
|
243
|
+
# good
|
244
|
+
assert_match(regex, string)
|
245
|
+
assert_match(matcher, string, 'message')
|
246
|
+
----
|
247
|
+
|
248
|
+
=== References
|
249
|
+
|
250
|
+
* https://minitest.rubystyle.guide#assert-match
|
251
|
+
|
252
|
+
== Minitest/AssertNil
|
253
|
+
|
254
|
+
|===
|
255
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
256
|
+
|
257
|
+
| Enabled
|
258
|
+
| Yes
|
259
|
+
| Yes
|
260
|
+
| 0.1
|
261
|
+
| -
|
262
|
+
|===
|
263
|
+
|
264
|
+
This cop enforces the test to use `assert_nil`
|
265
|
+
instead of using `assert_equal(nil, something)`.
|
266
|
+
|
267
|
+
=== Examples
|
268
|
+
|
269
|
+
[source,ruby]
|
270
|
+
----
|
271
|
+
# bad
|
272
|
+
assert_equal(nil, actual)
|
273
|
+
assert_equal(nil, actual, 'message')
|
274
|
+
|
275
|
+
# good
|
276
|
+
assert_nil(actual)
|
277
|
+
assert_nil(actual, 'message')
|
278
|
+
----
|
279
|
+
|
280
|
+
=== References
|
281
|
+
|
282
|
+
* https://minitest.rubystyle.guide#assert-nil
|
283
|
+
|
284
|
+
== Minitest/AssertOutput
|
285
|
+
|
286
|
+
|===
|
287
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
288
|
+
|
289
|
+
| Pending
|
290
|
+
| Yes
|
291
|
+
| No
|
292
|
+
| 0.10
|
293
|
+
| -
|
294
|
+
|===
|
295
|
+
|
296
|
+
This cop checks for opportunities to use `assert_output`.
|
297
|
+
|
298
|
+
=== Examples
|
299
|
+
|
300
|
+
[source,ruby]
|
301
|
+
----
|
302
|
+
# bad
|
303
|
+
$stdout = StringIO.new
|
304
|
+
puts object.method
|
305
|
+
$stdout.rewind
|
306
|
+
assert_match expected, $stdout.read
|
307
|
+
|
308
|
+
# good
|
309
|
+
assert_output(expected) { puts object.method }
|
310
|
+
----
|
311
|
+
|
312
|
+
=== References
|
313
|
+
|
314
|
+
* https://minitest.rubystyle.guide/#assert-output
|
315
|
+
|
316
|
+
== Minitest/AssertPathExists
|
317
|
+
|
318
|
+
|===
|
319
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
320
|
+
|
321
|
+
| Pending
|
322
|
+
| Yes
|
323
|
+
| Yes
|
324
|
+
| 0.10
|
325
|
+
| -
|
326
|
+
|===
|
327
|
+
|
328
|
+
This cop enforces the test to use `assert_path_exists`
|
329
|
+
instead of using `assert(File.exist?(path))`.
|
330
|
+
|
331
|
+
=== Examples
|
332
|
+
|
333
|
+
[source,ruby]
|
334
|
+
----
|
335
|
+
# bad
|
336
|
+
assert(File.exist?(path))
|
337
|
+
assert(File.exist?(path), 'message')
|
338
|
+
|
339
|
+
# good
|
340
|
+
assert_path_exists(path)
|
341
|
+
assert_path_exists(path, 'message')
|
342
|
+
----
|
343
|
+
|
344
|
+
=== References
|
345
|
+
|
346
|
+
* https://minitest.rubystyle.guide/#assert-path-exists
|
347
|
+
|
348
|
+
== Minitest/AssertRespondTo
|
349
|
+
|
350
|
+
|===
|
351
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
352
|
+
|
353
|
+
| Enabled
|
354
|
+
| Yes
|
355
|
+
| Yes
|
356
|
+
| 0.3
|
357
|
+
| -
|
358
|
+
|===
|
359
|
+
|
360
|
+
This cop enforces the use of `assert_respond_to(object, :do_something)`
|
361
|
+
over `assert(object.respond_to?(:do_something))`.
|
362
|
+
|
363
|
+
=== Examples
|
364
|
+
|
365
|
+
[source,ruby]
|
366
|
+
----
|
367
|
+
# bad
|
368
|
+
assert(object.respond_to?(:do_something))
|
369
|
+
assert(object.respond_to?(:do_something), 'message')
|
370
|
+
assert(respond_to?(:do_something))
|
371
|
+
|
372
|
+
# good
|
373
|
+
assert_respond_to(object, :do_something)
|
374
|
+
assert_respond_to(object, :do_something, 'message')
|
375
|
+
assert_respond_to(self, :do_something)
|
376
|
+
----
|
377
|
+
|
378
|
+
=== References
|
379
|
+
|
380
|
+
* https://minitest.rubystyle.guide#assert-responds-to-method
|
381
|
+
|
382
|
+
== Minitest/AssertSilent
|
383
|
+
|
384
|
+
|===
|
385
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
386
|
+
|
387
|
+
| Pending
|
388
|
+
| Yes
|
389
|
+
| Yes
|
390
|
+
| 0.10
|
391
|
+
| -
|
392
|
+
|===
|
393
|
+
|
394
|
+
This cop enforces the test to use `assert_silent { ... }`
|
395
|
+
instead of using `assert_output('', '') { ... }`.
|
396
|
+
|
397
|
+
=== Examples
|
398
|
+
|
399
|
+
[source,ruby]
|
400
|
+
----
|
401
|
+
# bad
|
402
|
+
assert_output('', '') { puts object.do_something }
|
403
|
+
|
404
|
+
# good
|
405
|
+
assert_silent { puts object.do_something }
|
406
|
+
----
|
407
|
+
|
408
|
+
=== References
|
409
|
+
|
410
|
+
* https://github.com/rubocop-hq/minitest-style-guide#assert-silent
|
411
|
+
|
412
|
+
== Minitest/AssertTruthy
|
413
|
+
|
414
|
+
|===
|
415
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
416
|
+
|
417
|
+
| Enabled
|
418
|
+
| Yes
|
419
|
+
| Yes
|
420
|
+
| 0.2
|
421
|
+
| -
|
422
|
+
|===
|
423
|
+
|
424
|
+
This cop enforces the test to use `assert(actual)`
|
425
|
+
instead of using `assert_equal(true, actual)`.
|
426
|
+
|
427
|
+
=== Examples
|
428
|
+
|
429
|
+
[source,ruby]
|
430
|
+
----
|
431
|
+
# bad
|
432
|
+
assert_equal(true, actual)
|
433
|
+
assert_equal(true, actual, 'message')
|
434
|
+
|
435
|
+
# good
|
436
|
+
assert(actual)
|
437
|
+
assert(actual, 'message')
|
438
|
+
----
|
439
|
+
|
440
|
+
=== References
|
441
|
+
|
442
|
+
* https://minitest.rubystyle.guide#assert-truthy
|
443
|
+
|
444
|
+
== Minitest/AssertionInLifecycleHook
|
445
|
+
|
446
|
+
|===
|
447
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
448
|
+
|
449
|
+
| Pending
|
450
|
+
| Yes
|
451
|
+
| No
|
452
|
+
| 0.10
|
453
|
+
| -
|
454
|
+
|===
|
455
|
+
|
456
|
+
This cop checks for usage of assertions in lifecycle hooks.
|
457
|
+
|
458
|
+
=== Examples
|
459
|
+
|
460
|
+
[source,ruby]
|
461
|
+
----
|
462
|
+
# bad
|
463
|
+
class FooTest < Minitest::Test
|
464
|
+
def setup
|
465
|
+
assert_equal(foo, bar)
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
# good
|
470
|
+
class FooTest < Minitest::Test
|
471
|
+
def test_something
|
472
|
+
assert_equal(foo, bar)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
----
|
476
|
+
|
477
|
+
== Minitest/GlobalExpectations
|
478
|
+
|
479
|
+
|===
|
480
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
481
|
+
|
482
|
+
| Enabled
|
483
|
+
| Yes
|
484
|
+
| Yes
|
485
|
+
| 0.7
|
486
|
+
| -
|
487
|
+
|===
|
488
|
+
|
489
|
+
This cop checks for deprecated global expectations
|
490
|
+
and autocorrects them to use expect format.
|
491
|
+
|
492
|
+
=== Examples
|
493
|
+
|
494
|
+
[source,ruby]
|
495
|
+
----
|
496
|
+
# bad
|
497
|
+
musts.must_equal expected_musts
|
498
|
+
wonts.wont_match expected_wonts
|
499
|
+
musts.must_raise TypeError
|
500
|
+
|
501
|
+
# good
|
502
|
+
_(musts).must_equal expected_musts
|
503
|
+
_(wonts).wont_match expected_wonts
|
504
|
+
_ { musts }.must_raise TypeError
|
505
|
+
----
|
506
|
+
|
507
|
+
=== References
|
508
|
+
|
509
|
+
* https://minitest.rubystyle.guide#global-expectations
|
510
|
+
|
511
|
+
== Minitest/LiteralAsActualArgument
|
512
|
+
|
513
|
+
|===
|
514
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
515
|
+
|
516
|
+
| Pending
|
517
|
+
| Yes
|
518
|
+
| Yes
|
519
|
+
| 0.10
|
520
|
+
| -
|
521
|
+
|===
|
522
|
+
|
523
|
+
This cop enforces correct order of expected and
|
524
|
+
actual arguments for `assert_equal`.
|
525
|
+
|
526
|
+
=== Examples
|
527
|
+
|
528
|
+
[source,ruby]
|
529
|
+
----
|
530
|
+
# bad
|
531
|
+
assert_equal foo, 2
|
532
|
+
assert_equal foo, [1, 2]
|
533
|
+
assert_equal foo, [1, 2], 'message'
|
534
|
+
|
535
|
+
# good
|
536
|
+
assert_equal 2, foo
|
537
|
+
assert_equal [1, 2], foo
|
538
|
+
assert_equal [1, 2], foo, 'message'
|
539
|
+
----
|
540
|
+
|
541
|
+
=== References
|
542
|
+
|
543
|
+
* https://minitest.rubystyle.guide/#assert-equal-arguments-order
|
544
|
+
|
545
|
+
== Minitest/MultipleAssertions
|
546
|
+
|
547
|
+
|===
|
548
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
549
|
+
|
550
|
+
| Pending
|
551
|
+
| Yes
|
552
|
+
| No
|
553
|
+
| 0.10
|
554
|
+
| -
|
555
|
+
|===
|
556
|
+
|
557
|
+
This cop checks if test cases contain too many assertion calls.
|
558
|
+
The maximum allowed assertion calls is configurable.
|
559
|
+
|
560
|
+
=== Examples
|
561
|
+
|
562
|
+
==== Max: 1
|
563
|
+
|
564
|
+
[source,ruby]
|
565
|
+
----
|
566
|
+
# bad
|
567
|
+
class FooTest < Minitest::Test
|
568
|
+
def test_asserts_twice
|
569
|
+
assert_equal(42, do_something)
|
570
|
+
assert_empty(array)
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
# good
|
575
|
+
class FooTest < Minitest::Test
|
576
|
+
def test_asserts_once
|
577
|
+
assert_equal(42, do_something)
|
578
|
+
end
|
579
|
+
|
580
|
+
def test_another_asserts_once
|
581
|
+
assert_empty(array)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
----
|
585
|
+
|
586
|
+
=== Configurable attributes
|
587
|
+
|
588
|
+
|===
|
589
|
+
| Name | Default value | Configurable values
|
590
|
+
|
591
|
+
| Max
|
592
|
+
| `3`
|
593
|
+
| Integer
|
594
|
+
|===
|
595
|
+
|
596
|
+
== Minitest/RefuteEmpty
|
597
|
+
|
598
|
+
|===
|
599
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
600
|
+
|
601
|
+
| Enabled
|
602
|
+
| Yes
|
603
|
+
| Yes
|
604
|
+
| 0.3
|
605
|
+
| -
|
606
|
+
|===
|
607
|
+
|
608
|
+
This cop enforces to use `refute_empty` instead of
|
609
|
+
using `refute(object.empty?)`.
|
610
|
+
|
611
|
+
=== Examples
|
612
|
+
|
613
|
+
[source,ruby]
|
614
|
+
----
|
615
|
+
# bad
|
616
|
+
refute(object.empty?)
|
617
|
+
refute(object.empty?, 'message')
|
618
|
+
|
619
|
+
# good
|
620
|
+
refute_empty(object)
|
621
|
+
refute_empty(object, 'message')
|
622
|
+
----
|
623
|
+
|
624
|
+
=== References
|
625
|
+
|
626
|
+
* https://minitest.rubystyle.guide#refute-empty
|
627
|
+
|
628
|
+
== Minitest/RefuteEqual
|
629
|
+
|
630
|
+
|===
|
631
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
632
|
+
|
633
|
+
| Enabled
|
634
|
+
| Yes
|
635
|
+
| Yes
|
636
|
+
| 0.3
|
637
|
+
| -
|
638
|
+
|===
|
639
|
+
|
640
|
+
This cop enforces the use of `refute_equal(expected, object)`
|
641
|
+
over `assert_equal(expected != actual)` or `assert(! expected == actual)`.
|
642
|
+
|
643
|
+
=== Examples
|
644
|
+
|
645
|
+
[source,ruby]
|
646
|
+
----
|
647
|
+
# bad
|
648
|
+
assert("rubocop-minitest" != actual)
|
649
|
+
assert(! "rubocop-minitest" == actual)
|
650
|
+
|
651
|
+
# good
|
652
|
+
refute_equal("rubocop-minitest", actual)
|
653
|
+
----
|
654
|
+
|
655
|
+
=== References
|
656
|
+
|
657
|
+
* https://minitest.rubystyle.guide#refute-equal
|
658
|
+
|
659
|
+
== Minitest/RefuteFalse
|
660
|
+
|
661
|
+
|===
|
662
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
663
|
+
|
664
|
+
| Enabled
|
665
|
+
| Yes
|
666
|
+
| Yes
|
667
|
+
| 0.3
|
668
|
+
| -
|
669
|
+
|===
|
670
|
+
|
671
|
+
This cop enforces the use of `refute(object)`
|
672
|
+
over `assert_equal(false, object)`.
|
673
|
+
|
674
|
+
=== Examples
|
675
|
+
|
676
|
+
[source,ruby]
|
677
|
+
----
|
678
|
+
# bad
|
679
|
+
assert_equal(false, actual)
|
680
|
+
assert_equal(false, actual, 'message')
|
681
|
+
|
682
|
+
assert(!test)
|
683
|
+
assert(!test, 'message')
|
684
|
+
|
685
|
+
# good
|
686
|
+
refute(actual)
|
687
|
+
refute(actual, 'message')
|
688
|
+
----
|
689
|
+
|
690
|
+
=== References
|
691
|
+
|
692
|
+
* https://minitest.rubystyle.guide#refute-false
|
693
|
+
|
694
|
+
== Minitest/RefuteInDelta
|
695
|
+
|
696
|
+
|===
|
697
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
698
|
+
|
699
|
+
| Pending
|
700
|
+
| Yes
|
701
|
+
| Yes
|
702
|
+
| 0.10
|
703
|
+
| -
|
704
|
+
|===
|
705
|
+
|
706
|
+
This cop enforces the test to use `refute_in_delta`
|
707
|
+
instead of using `refute_equal` to compare floats.
|
708
|
+
|
709
|
+
=== Examples
|
710
|
+
|
711
|
+
[source,ruby]
|
712
|
+
----
|
713
|
+
# bad
|
714
|
+
refute_equal(0.2, actual)
|
715
|
+
refute_equal(0.2, actual, 'message')
|
716
|
+
|
717
|
+
# good
|
718
|
+
refute_in_delta(0.2, actual)
|
719
|
+
refute_in_delta(0.2, actual, 0.001, 'message')
|
720
|
+
----
|
721
|
+
|
722
|
+
=== References
|
723
|
+
|
724
|
+
* https://minitest.rubystyle.guide/#refute-in-delta
|
725
|
+
|
726
|
+
== Minitest/RefuteIncludes
|
727
|
+
|
728
|
+
|===
|
729
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
730
|
+
|
731
|
+
| Enabled
|
732
|
+
| Yes
|
733
|
+
| Yes
|
734
|
+
| 0.3
|
735
|
+
| -
|
736
|
+
|===
|
737
|
+
|
738
|
+
This cop enforces the test to use `refute_includes`
|
739
|
+
instead of using `refute(collection.include?(object))`.
|
740
|
+
|
741
|
+
=== Examples
|
742
|
+
|
743
|
+
[source,ruby]
|
744
|
+
----
|
745
|
+
# bad
|
746
|
+
refute(collection.include?(object))
|
747
|
+
refute(collection.include?(object), 'message')
|
748
|
+
|
749
|
+
# good
|
750
|
+
refute_includes(collection, object)
|
751
|
+
refute_includes(collection, object, 'message')
|
752
|
+
----
|
753
|
+
|
754
|
+
=== References
|
755
|
+
|
756
|
+
* https://minitest.rubystyle.guide#refute-includes
|
757
|
+
|
758
|
+
== Minitest/RefuteInstanceOf
|
759
|
+
|
760
|
+
|===
|
761
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
762
|
+
|
763
|
+
| Enabled
|
764
|
+
| Yes
|
765
|
+
| Yes
|
766
|
+
| 0.4
|
767
|
+
| -
|
768
|
+
|===
|
769
|
+
|
770
|
+
This cop enforces the use of `refute_instance_of(Class, object)`
|
771
|
+
over `refute(object.instance_of?(Class))`.
|
772
|
+
|
773
|
+
=== Examples
|
774
|
+
|
775
|
+
[source,ruby]
|
776
|
+
----
|
777
|
+
# bad
|
778
|
+
refute(object.instance_of?(Class))
|
779
|
+
refute(object.instance_of?(Class), 'message')
|
780
|
+
|
781
|
+
# good
|
782
|
+
refute_instance_of(Class, object)
|
783
|
+
refute_instance_of(Class, object, 'message')
|
784
|
+
----
|
785
|
+
|
786
|
+
=== References
|
787
|
+
|
788
|
+
* https://minitest.rubystyle.guide#refute-instance-of
|
789
|
+
|
790
|
+
== Minitest/RefuteKindOf
|
791
|
+
|
792
|
+
|===
|
793
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
794
|
+
|
795
|
+
| Pending
|
796
|
+
| Yes
|
797
|
+
| Yes
|
798
|
+
| 0.10
|
799
|
+
| -
|
800
|
+
|===
|
801
|
+
|
802
|
+
This cop enforces the use of `refute_kind_of(Class, object)`
|
803
|
+
over `refute(object.kind_of?(Class))`.
|
804
|
+
|
805
|
+
=== Examples
|
806
|
+
|
807
|
+
[source,ruby]
|
808
|
+
----
|
809
|
+
# bad
|
810
|
+
refute(object.kind_of?(Class))
|
811
|
+
refute(object.kind_of?(Class), 'message')
|
812
|
+
|
813
|
+
# good
|
814
|
+
refute_kind_of(Class, object)
|
815
|
+
refute_kind_of(Class, object, 'message')
|
816
|
+
----
|
817
|
+
|
818
|
+
=== References
|
819
|
+
|
820
|
+
* https://github.com/rubocop-hq/minitest-style-guide#refute-kind-of
|
821
|
+
|
822
|
+
== Minitest/RefuteMatch
|
823
|
+
|
824
|
+
|===
|
825
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
826
|
+
|
827
|
+
| Enabled
|
828
|
+
| Yes
|
829
|
+
| Yes
|
830
|
+
| 0.6
|
831
|
+
| -
|
832
|
+
|===
|
833
|
+
|
834
|
+
This cop enforces the test to use `refute_match`
|
835
|
+
instead of using `refute(matcher.match(string))`.
|
836
|
+
|
837
|
+
=== Examples
|
838
|
+
|
839
|
+
[source,ruby]
|
840
|
+
----
|
841
|
+
# bad
|
842
|
+
refute(matcher.match(string))
|
843
|
+
refute(matcher.match(string), 'message')
|
844
|
+
|
845
|
+
# good
|
846
|
+
refute_match(matcher, string)
|
847
|
+
refute_match(matcher, string, 'message')
|
848
|
+
----
|
849
|
+
|
850
|
+
=== References
|
851
|
+
|
852
|
+
* https://minitest.rubystyle.guide#refute-match
|
853
|
+
|
854
|
+
== Minitest/RefuteNil
|
855
|
+
|
856
|
+
|===
|
857
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
858
|
+
|
859
|
+
| Enabled
|
860
|
+
| Yes
|
861
|
+
| Yes
|
862
|
+
| 0.2
|
863
|
+
| -
|
864
|
+
|===
|
865
|
+
|
866
|
+
This cop enforces the test to use `refute_nil`
|
867
|
+
instead of using `refute_equal(nil, something)`.
|
868
|
+
|
869
|
+
=== Examples
|
870
|
+
|
871
|
+
[source,ruby]
|
872
|
+
----
|
873
|
+
# bad
|
874
|
+
refute_equal(nil, actual)
|
875
|
+
refute_equal(nil, actual, 'message')
|
876
|
+
|
877
|
+
# good
|
878
|
+
refute_nil(actual)
|
879
|
+
refute_nil(actual, 'message')
|
880
|
+
----
|
881
|
+
|
882
|
+
=== References
|
883
|
+
|
884
|
+
* https://minitest.rubystyle.guide#refute-nil
|
885
|
+
|
886
|
+
== Minitest/RefutePathExists
|
887
|
+
|
888
|
+
|===
|
889
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
890
|
+
|
891
|
+
| Pending
|
892
|
+
| Yes
|
893
|
+
| Yes
|
894
|
+
| 0.10
|
895
|
+
| -
|
896
|
+
|===
|
897
|
+
|
898
|
+
This cop enforces the test to use `refute_path_exists`
|
899
|
+
instead of using `refute(File.exist?(path))`.
|
900
|
+
|
901
|
+
=== Examples
|
902
|
+
|
903
|
+
[source,ruby]
|
904
|
+
----
|
905
|
+
# bad
|
906
|
+
refute(File.exist?(path))
|
907
|
+
refute(File.exist?(path), 'message')
|
908
|
+
|
909
|
+
# good
|
910
|
+
refute_path_exists(path)
|
911
|
+
refute_path_exists(path, 'message')
|
912
|
+
----
|
913
|
+
|
914
|
+
=== References
|
915
|
+
|
916
|
+
* https://minitest.rubystyle.guide/#refute-path-exists
|
917
|
+
|
918
|
+
== Minitest/RefuteRespondTo
|
919
|
+
|
920
|
+
|===
|
921
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
922
|
+
|
923
|
+
| Enabled
|
924
|
+
| Yes
|
925
|
+
| Yes
|
926
|
+
| 0.4
|
927
|
+
| -
|
928
|
+
|===
|
929
|
+
|
930
|
+
This cop enforces the test to use `refute_respond_to(object, :do_something)`
|
931
|
+
over `refute(object.respond_to?(:do_something))`.
|
932
|
+
|
933
|
+
=== Examples
|
934
|
+
|
935
|
+
[source,ruby]
|
936
|
+
----
|
937
|
+
# bad
|
938
|
+
refute(object.respond_to?(:do_something))
|
939
|
+
refute(object.respond_to?(:do_something), 'message')
|
940
|
+
refute(respond_to?(:do_something))
|
941
|
+
|
942
|
+
# good
|
943
|
+
refute_respond_to(object, :do_something)
|
944
|
+
refute_respond_to(object, :do_something, 'message')
|
945
|
+
refute_respond_to(self, :do_something)
|
946
|
+
----
|
947
|
+
|
948
|
+
=== References
|
949
|
+
|
950
|
+
* https://minitest.rubystyle.guide#refute-respond-to
|
951
|
+
|
952
|
+
== Minitest/TestMethodName
|
953
|
+
|
954
|
+
|===
|
955
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
956
|
+
|
957
|
+
| Pending
|
958
|
+
| Yes
|
959
|
+
| Yes
|
960
|
+
| 0.10
|
961
|
+
| -
|
962
|
+
|===
|
963
|
+
|
964
|
+
This cop enforces that test method names start with `test_` prefix.
|
965
|
+
|
966
|
+
=== Examples
|
967
|
+
|
968
|
+
[source,ruby]
|
969
|
+
----
|
970
|
+
# bad
|
971
|
+
class FooTest < Minitest::Test
|
972
|
+
def does_something
|
973
|
+
assert_equal 42, do_something
|
974
|
+
end
|
975
|
+
end
|
976
|
+
|
977
|
+
# good
|
978
|
+
class FooTest < Minitest::Test
|
979
|
+
def test_does_something
|
980
|
+
assert_equal 42, do_something
|
981
|
+
end
|
982
|
+
end
|
983
|
+
----
|
984
|
+
|
985
|
+
== Minitest/UnspecifiedException
|
986
|
+
|
987
|
+
|===
|
988
|
+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
989
|
+
|
990
|
+
| Pending
|
991
|
+
| Yes
|
992
|
+
| No
|
993
|
+
| 0.10
|
994
|
+
| -
|
995
|
+
|===
|
996
|
+
|
997
|
+
This cop checks for a specified error in `assert_raises`.
|
998
|
+
|
999
|
+
=== Examples
|
1000
|
+
|
1001
|
+
[source,ruby]
|
1002
|
+
----
|
1003
|
+
# bad
|
1004
|
+
assert_raises { raise FooException }
|
1005
|
+
assert_raises('This should have raised') { raise FooException }
|
1006
|
+
|
1007
|
+
# good
|
1008
|
+
assert_raises(FooException) { raise FooException }
|
1009
|
+
assert_raises(FooException, 'This should have raised') { raise FooException }
|
1010
|
+
----
|
1011
|
+
|
1012
|
+
=== References
|
1013
|
+
|
1014
|
+
* https://minitest.rubystyle.guide#unspecified-exception
|