rubocop-minitest 0.20.1 → 0.22.0
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/config/default.yml +11 -0
- data/lib/rubocop/cop/generator.rb +1 -7
- data/lib/rubocop/cop/minitest/assert_in_delta.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_match.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_predicate.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_raises_compound_body.rb +45 -0
- data/lib/rubocop/cop/minitest/assert_raises_with_regexp_argument.rb +36 -0
- data/lib/rubocop/cop/minitest/assert_silent.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_equal.rb +1 -2
- data/lib/rubocop/cop/minitest/refute_in_delta.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_predicate.rb +1 -1
- data/lib/rubocop/cop/minitest/unreachable_assertion.rb +1 -1
- data/lib/rubocop/cop/minitest_cops.rb +2 -0
- data/lib/rubocop/cop/mixin/argument_range_helper.rb +4 -12
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +1 -0
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +11 -4
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +1 -0
- data/lib/rubocop/cop/mixin/nil_assertion_handleable.rb +1 -0
- data/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb +2 -5
- data/lib/rubocop/minitest/assert_offense.rb +1 -1
- data/lib/rubocop/minitest/version.rb +1 -1
- metadata +5 -79
- data/.circleci/config.yml +0 -55
- data/.gitattributes +0 -1
- data/.github/FUNDING.yml +0 -7
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -43
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -17
- data/.github/workflows/linting.yml +0 -15
- data/.github/workflows/spell_checking.yml +0 -33
- data/.gitignore +0 -61
- data/.rubocop.yml +0 -101
- data/.rubocop_todo.yml +0 -19
- data/.yamllint.yml +0 -9
- data/.yardopts +0 -3
- data/CHANGELOG.md +0 -323
- data/CONTRIBUTING.md +0 -69
- data/Gemfile +0 -16
- data/Rakefile +0 -60
- data/bin/console +0 -11
- data/bin/setup +0 -8
- data/codespell.txt +0 -0
- data/docs/antora.yml +0 -7
- data/docs/modules/ROOT/nav.adoc +0 -6
- data/docs/modules/ROOT/pages/cops.adoc +0 -55
- data/docs/modules/ROOT/pages/cops_minitest.adoc +0 -1412
- data/docs/modules/ROOT/pages/index.adoc +0 -5
- data/docs/modules/ROOT/pages/installation.adoc +0 -15
- data/docs/modules/ROOT/pages/usage.adoc +0 -32
- data/legacy-docs/cops.md +0 -23
- data/legacy-docs/cops_minitest.md +0 -448
- data/legacy-docs/index.md +0 -1
- data/legacy-docs/installation.md +0 -11
- data/legacy-docs/usage.md +0 -27
- data/mkdocs.yml +0 -13
- data/readthedocs.yml +0 -5
- data/relnotes/v0.1.0.md +0 -7
- data/relnotes/v0.10.0.md +0 -21
- data/relnotes/v0.10.1.md +0 -5
- data/relnotes/v0.10.2.md +0 -5
- data/relnotes/v0.10.3.md +0 -5
- data/relnotes/v0.11.0.md +0 -16
- data/relnotes/v0.11.1.md +0 -5
- data/relnotes/v0.12.0.md +0 -10
- data/relnotes/v0.12.1.md +0 -5
- data/relnotes/v0.13.0.md +0 -5
- data/relnotes/v0.14.0.md +0 -5
- data/relnotes/v0.15.0.md +0 -5
- data/relnotes/v0.15.1.md +0 -5
- data/relnotes/v0.15.2.md +0 -5
- data/relnotes/v0.16.0.md +0 -11
- data/relnotes/v0.17.0.md +0 -5
- data/relnotes/v0.17.1.md +0 -5
- data/relnotes/v0.17.2.md +0 -5
- data/relnotes/v0.18.0.md +0 -9
- data/relnotes/v0.19.0.md +0 -5
- data/relnotes/v0.19.1.md +0 -5
- data/relnotes/v0.2.0.md +0 -9
- data/relnotes/v0.2.1.md +0 -5
- data/relnotes/v0.20.0.md +0 -13
- data/relnotes/v0.20.1.md +0 -5
- data/relnotes/v0.3.0.md +0 -16
- data/relnotes/v0.4.0.md +0 -14
- data/relnotes/v0.4.1.md +0 -5
- data/relnotes/v0.5.0.md +0 -5
- data/relnotes/v0.5.1.md +0 -5
- data/relnotes/v0.6.0.md +0 -5
- data/relnotes/v0.6.1.md +0 -6
- data/relnotes/v0.6.2.md +0 -5
- data/relnotes/v0.7.0.md +0 -13
- data/relnotes/v0.8.0.md +0 -12
- data/relnotes/v0.8.1.md +0 -5
- data/relnotes/v0.9.0.md +0 -10
- data/rubocop-minitest.gemspec +0 -40
- data/tasks/changelog.rake +0 -34
- data/tasks/changelog.rb +0 -166
- data/tasks/cops_documentation.rake +0 -50
- data/tasks/cut_release.rake +0 -91
@@ -1,1412 +0,0 @@
|
|
1
|
-
= Minitest
|
2
|
-
|
3
|
-
== Minitest/AssertEmpty
|
4
|
-
|
5
|
-
|===
|
6
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
7
|
-
|
8
|
-
| Enabled
|
9
|
-
| Yes
|
10
|
-
| Yes
|
11
|
-
| 0.2
|
12
|
-
| -
|
13
|
-
|===
|
14
|
-
|
15
|
-
Enforces the test to use `assert_empty` instead of using `assert(object.empty?)`.
|
16
|
-
|
17
|
-
=== Examples
|
18
|
-
|
19
|
-
[source,ruby]
|
20
|
-
----
|
21
|
-
# bad
|
22
|
-
assert(object.empty?)
|
23
|
-
assert(object.empty?, 'message')
|
24
|
-
|
25
|
-
# good
|
26
|
-
assert_empty(object)
|
27
|
-
assert_empty(object, 'message')
|
28
|
-
----
|
29
|
-
|
30
|
-
=== References
|
31
|
-
|
32
|
-
* https://minitest.rubystyle.guide#assert-empty
|
33
|
-
|
34
|
-
== Minitest/AssertEmptyLiteral
|
35
|
-
|
36
|
-
|===
|
37
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
38
|
-
|
39
|
-
| Enabled
|
40
|
-
| Yes
|
41
|
-
| Yes
|
42
|
-
| 0.5
|
43
|
-
| 0.11
|
44
|
-
|===
|
45
|
-
|
46
|
-
Enforces the test to use `assert_empty`
|
47
|
-
instead of using `assert_equal([], object)` or `assert_equal({}, object)`.
|
48
|
-
|
49
|
-
=== Examples
|
50
|
-
|
51
|
-
[source,ruby]
|
52
|
-
----
|
53
|
-
# bad
|
54
|
-
assert_equal([], object)
|
55
|
-
assert_equal({}, object)
|
56
|
-
|
57
|
-
# good
|
58
|
-
assert_empty(object)
|
59
|
-
----
|
60
|
-
|
61
|
-
== Minitest/AssertEqual
|
62
|
-
|
63
|
-
|===
|
64
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
65
|
-
|
66
|
-
| Enabled
|
67
|
-
| Yes
|
68
|
-
| Yes
|
69
|
-
| 0.4
|
70
|
-
| -
|
71
|
-
|===
|
72
|
-
|
73
|
-
Enforces the use of `assert_equal(expected, actual)`
|
74
|
-
over `assert(expected == actual)`.
|
75
|
-
|
76
|
-
=== Examples
|
77
|
-
|
78
|
-
[source,ruby]
|
79
|
-
----
|
80
|
-
# bad
|
81
|
-
assert("rubocop-minitest" == actual)
|
82
|
-
|
83
|
-
# good
|
84
|
-
assert_equal("rubocop-minitest", actual)
|
85
|
-
----
|
86
|
-
|
87
|
-
=== References
|
88
|
-
|
89
|
-
* https://minitest.rubystyle.guide#assert-equal-arguments-order
|
90
|
-
|
91
|
-
== Minitest/AssertInDelta
|
92
|
-
|
93
|
-
|===
|
94
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
95
|
-
|
96
|
-
| Pending
|
97
|
-
| Yes
|
98
|
-
| Yes
|
99
|
-
| 0.10
|
100
|
-
| -
|
101
|
-
|===
|
102
|
-
|
103
|
-
Enforces the test to use `assert_in_delta`
|
104
|
-
instead of using `assert_equal` to compare floats.
|
105
|
-
|
106
|
-
=== Examples
|
107
|
-
|
108
|
-
[source,ruby]
|
109
|
-
----
|
110
|
-
# bad
|
111
|
-
assert_equal(0.2, actual)
|
112
|
-
assert_equal(0.2, actual, 'message')
|
113
|
-
|
114
|
-
# good
|
115
|
-
assert_in_delta(0.2, actual)
|
116
|
-
assert_in_delta(0.2, actual, 0.001, 'message')
|
117
|
-
----
|
118
|
-
|
119
|
-
=== References
|
120
|
-
|
121
|
-
* https://minitest.rubystyle.guide/#assert-in-delta
|
122
|
-
|
123
|
-
== Minitest/AssertIncludes
|
124
|
-
|
125
|
-
|===
|
126
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
127
|
-
|
128
|
-
| Enabled
|
129
|
-
| Yes
|
130
|
-
| Yes
|
131
|
-
| 0.2
|
132
|
-
| -
|
133
|
-
|===
|
134
|
-
|
135
|
-
Enforces the test to use `assert_includes`
|
136
|
-
instead of using `assert(collection.include?(object))`.
|
137
|
-
|
138
|
-
=== Examples
|
139
|
-
|
140
|
-
[source,ruby]
|
141
|
-
----
|
142
|
-
# bad
|
143
|
-
assert(collection.include?(object))
|
144
|
-
assert(collection.include?(object), 'message')
|
145
|
-
|
146
|
-
# good
|
147
|
-
assert_includes(collection, object)
|
148
|
-
assert_includes(collection, object, 'message')
|
149
|
-
----
|
150
|
-
|
151
|
-
=== References
|
152
|
-
|
153
|
-
* https://minitest.rubystyle.guide#assert-includes
|
154
|
-
|
155
|
-
== Minitest/AssertInstanceOf
|
156
|
-
|
157
|
-
|===
|
158
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
159
|
-
|
160
|
-
| Enabled
|
161
|
-
| Yes
|
162
|
-
| Yes
|
163
|
-
| 0.4
|
164
|
-
| -
|
165
|
-
|===
|
166
|
-
|
167
|
-
Enforces the test to use `assert_instance_of(Class, object)`
|
168
|
-
over `assert(object.instance_of?(Class))`.
|
169
|
-
|
170
|
-
=== Examples
|
171
|
-
|
172
|
-
[source,ruby]
|
173
|
-
----
|
174
|
-
# bad
|
175
|
-
assert(object.instance_of?(Class))
|
176
|
-
assert(object.instance_of?(Class), 'message')
|
177
|
-
|
178
|
-
# good
|
179
|
-
assert_instance_of(Class, object)
|
180
|
-
assert_instance_of(Class, object, 'message')
|
181
|
-
----
|
182
|
-
|
183
|
-
=== References
|
184
|
-
|
185
|
-
* https://minitest.rubystyle.guide#assert-instance-of
|
186
|
-
|
187
|
-
== Minitest/AssertKindOf
|
188
|
-
|
189
|
-
|===
|
190
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
191
|
-
|
192
|
-
| Pending
|
193
|
-
| Yes
|
194
|
-
| Yes
|
195
|
-
| 0.10
|
196
|
-
| -
|
197
|
-
|===
|
198
|
-
|
199
|
-
Enforces the test to use `assert_kind_of(Class, object)`
|
200
|
-
over `assert(object.kind_of?(Class))`.
|
201
|
-
|
202
|
-
=== Examples
|
203
|
-
|
204
|
-
[source,ruby]
|
205
|
-
----
|
206
|
-
# bad
|
207
|
-
assert(object.kind_of?(Class))
|
208
|
-
assert(object.kind_of?(Class), 'message')
|
209
|
-
|
210
|
-
# good
|
211
|
-
assert_kind_of(Class, object)
|
212
|
-
assert_kind_of(Class, object, 'message')
|
213
|
-
----
|
214
|
-
|
215
|
-
=== References
|
216
|
-
|
217
|
-
* https://github.com/rubocop/minitest-style-guide#assert-kind-of
|
218
|
-
|
219
|
-
== Minitest/AssertMatch
|
220
|
-
|
221
|
-
|===
|
222
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
223
|
-
|
224
|
-
| Enabled
|
225
|
-
| Yes
|
226
|
-
| Yes
|
227
|
-
| 0.6
|
228
|
-
| -
|
229
|
-
|===
|
230
|
-
|
231
|
-
Enforces the test to use `assert_match`
|
232
|
-
instead of using `assert(matcher.match(string))`.
|
233
|
-
|
234
|
-
=== Examples
|
235
|
-
|
236
|
-
[source,ruby]
|
237
|
-
----
|
238
|
-
# bad
|
239
|
-
assert(matcher.match(string))
|
240
|
-
assert(matcher.match(string), 'message')
|
241
|
-
|
242
|
-
# good
|
243
|
-
assert_match(regex, string)
|
244
|
-
assert_match(matcher, string, 'message')
|
245
|
-
----
|
246
|
-
|
247
|
-
=== References
|
248
|
-
|
249
|
-
* https://minitest.rubystyle.guide#assert-match
|
250
|
-
|
251
|
-
== Minitest/AssertNil
|
252
|
-
|
253
|
-
|===
|
254
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
255
|
-
|
256
|
-
| Enabled
|
257
|
-
| Yes
|
258
|
-
| Yes
|
259
|
-
| 0.1
|
260
|
-
| -
|
261
|
-
|===
|
262
|
-
|
263
|
-
Enforces the test to use `assert_nil` instead of using
|
264
|
-
`assert_equal(nil, something)`, `assert(something.nil?)`, or `assert_predicate(something, :nil?)`.
|
265
|
-
|
266
|
-
=== Examples
|
267
|
-
|
268
|
-
[source,ruby]
|
269
|
-
----
|
270
|
-
# bad
|
271
|
-
assert_equal(nil, actual)
|
272
|
-
assert_equal(nil, actual, 'message')
|
273
|
-
assert(object.nil?)
|
274
|
-
assert(object.nil?, 'message')
|
275
|
-
assert_predicate(object, :nil?)
|
276
|
-
assert_predicate(object, :nil?, 'message')
|
277
|
-
|
278
|
-
# good
|
279
|
-
assert_nil(actual)
|
280
|
-
assert_nil(actual, 'message')
|
281
|
-
----
|
282
|
-
|
283
|
-
=== References
|
284
|
-
|
285
|
-
* https://minitest.rubystyle.guide#assert-nil
|
286
|
-
|
287
|
-
== Minitest/AssertOutput
|
288
|
-
|
289
|
-
|===
|
290
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
291
|
-
|
292
|
-
| Pending
|
293
|
-
| Yes
|
294
|
-
| No
|
295
|
-
| 0.10
|
296
|
-
| -
|
297
|
-
|===
|
298
|
-
|
299
|
-
Checks for opportunities to use `assert_output`.
|
300
|
-
|
301
|
-
=== Examples
|
302
|
-
|
303
|
-
[source,ruby]
|
304
|
-
----
|
305
|
-
# bad
|
306
|
-
$stdout = StringIO.new
|
307
|
-
puts object.method
|
308
|
-
$stdout.rewind
|
309
|
-
assert_match expected, $stdout.read
|
310
|
-
|
311
|
-
# good
|
312
|
-
assert_output(expected) { puts object.method }
|
313
|
-
----
|
314
|
-
|
315
|
-
=== References
|
316
|
-
|
317
|
-
* https://minitest.rubystyle.guide/#assert-output
|
318
|
-
|
319
|
-
== Minitest/AssertPathExists
|
320
|
-
|
321
|
-
|===
|
322
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
323
|
-
|
324
|
-
| Pending
|
325
|
-
| Yes
|
326
|
-
| Yes
|
327
|
-
| 0.10
|
328
|
-
| -
|
329
|
-
|===
|
330
|
-
|
331
|
-
Enforces the test to use `assert_path_exists` instead of using `assert(File.exist?(path))`.
|
332
|
-
|
333
|
-
=== Examples
|
334
|
-
|
335
|
-
[source,ruby]
|
336
|
-
----
|
337
|
-
# bad
|
338
|
-
assert(File.exist?(path))
|
339
|
-
assert(File.exist?(path), 'message')
|
340
|
-
|
341
|
-
# good
|
342
|
-
assert_path_exists(path)
|
343
|
-
assert_path_exists(path, 'message')
|
344
|
-
----
|
345
|
-
|
346
|
-
=== References
|
347
|
-
|
348
|
-
* https://minitest.rubystyle.guide/#assert-path-exists
|
349
|
-
|
350
|
-
== Minitest/AssertPredicate
|
351
|
-
|
352
|
-
|===
|
353
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
354
|
-
|
355
|
-
| Pending
|
356
|
-
| Yes
|
357
|
-
| Yes
|
358
|
-
| 0.18
|
359
|
-
| -
|
360
|
-
|===
|
361
|
-
|
362
|
-
Enforces the test to use `assert_predicate`
|
363
|
-
instead of using `assert(obj.a_predicate_method?)`.
|
364
|
-
|
365
|
-
=== Examples
|
366
|
-
|
367
|
-
[source,ruby]
|
368
|
-
----
|
369
|
-
# bad
|
370
|
-
assert(obj.one?)
|
371
|
-
assert(obj.one?, 'message')
|
372
|
-
|
373
|
-
# good
|
374
|
-
assert_predicate(obj, :one?)
|
375
|
-
assert_predicate(obj, :one?, 'message')
|
376
|
-
----
|
377
|
-
|
378
|
-
=== References
|
379
|
-
|
380
|
-
* https://minitest.rubystyle.guide/#assert-predicate
|
381
|
-
|
382
|
-
== Minitest/AssertRespondTo
|
383
|
-
|
384
|
-
|===
|
385
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
386
|
-
|
387
|
-
| Enabled
|
388
|
-
| Yes
|
389
|
-
| Yes
|
390
|
-
| 0.3
|
391
|
-
| -
|
392
|
-
|===
|
393
|
-
|
394
|
-
Enforces the use of `assert_respond_to(object, :do_something)`
|
395
|
-
over `assert(object.respond_to?(:do_something))`.
|
396
|
-
|
397
|
-
=== Examples
|
398
|
-
|
399
|
-
[source,ruby]
|
400
|
-
----
|
401
|
-
# bad
|
402
|
-
assert(object.respond_to?(:do_something))
|
403
|
-
assert(object.respond_to?(:do_something), 'message')
|
404
|
-
assert(respond_to?(:do_something))
|
405
|
-
|
406
|
-
# good
|
407
|
-
assert_respond_to(object, :do_something)
|
408
|
-
assert_respond_to(object, :do_something, 'message')
|
409
|
-
assert_respond_to(self, :do_something)
|
410
|
-
----
|
411
|
-
|
412
|
-
=== References
|
413
|
-
|
414
|
-
* https://minitest.rubystyle.guide#assert-responds-to-method
|
415
|
-
|
416
|
-
== Minitest/AssertSilent
|
417
|
-
|
418
|
-
|===
|
419
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
420
|
-
|
421
|
-
| Pending
|
422
|
-
| Yes
|
423
|
-
| Yes
|
424
|
-
| 0.10
|
425
|
-
| -
|
426
|
-
|===
|
427
|
-
|
428
|
-
Enforces the test to use `assert_silent { ... }`
|
429
|
-
instead of using `assert_output('', '') { ... }`.
|
430
|
-
|
431
|
-
=== Examples
|
432
|
-
|
433
|
-
[source,ruby]
|
434
|
-
----
|
435
|
-
# bad
|
436
|
-
assert_output('', '') { puts object.do_something }
|
437
|
-
|
438
|
-
# good
|
439
|
-
assert_silent { puts object.do_something }
|
440
|
-
----
|
441
|
-
|
442
|
-
=== References
|
443
|
-
|
444
|
-
* https://github.com/rubocop/minitest-style-guide#assert-silent
|
445
|
-
|
446
|
-
== Minitest/AssertTruthy
|
447
|
-
|
448
|
-
|===
|
449
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
450
|
-
|
451
|
-
| Enabled
|
452
|
-
| Yes
|
453
|
-
| Yes
|
454
|
-
| 0.2
|
455
|
-
| -
|
456
|
-
|===
|
457
|
-
|
458
|
-
Enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.
|
459
|
-
|
460
|
-
=== Examples
|
461
|
-
|
462
|
-
[source,ruby]
|
463
|
-
----
|
464
|
-
# bad
|
465
|
-
assert_equal(true, actual)
|
466
|
-
assert_equal(true, actual, 'message')
|
467
|
-
|
468
|
-
# good
|
469
|
-
assert(actual)
|
470
|
-
assert(actual, 'message')
|
471
|
-
----
|
472
|
-
|
473
|
-
=== References
|
474
|
-
|
475
|
-
* https://minitest.rubystyle.guide#assert-truthy
|
476
|
-
|
477
|
-
== Minitest/AssertWithExpectedArgument
|
478
|
-
|
479
|
-
|===
|
480
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
481
|
-
|
482
|
-
| Pending
|
483
|
-
| No
|
484
|
-
| No
|
485
|
-
| 0.11
|
486
|
-
| -
|
487
|
-
|===
|
488
|
-
|
489
|
-
Tries to detect when a user accidentally used
|
490
|
-
`assert` when they meant to use `assert_equal`.
|
491
|
-
|
492
|
-
=== Safety
|
493
|
-
|
494
|
-
This cop is unsafe because it is not possible to determine
|
495
|
-
whether the second argument of `assert` is a message or not.
|
496
|
-
|
497
|
-
=== Examples
|
498
|
-
|
499
|
-
[source,ruby]
|
500
|
-
----
|
501
|
-
# bad
|
502
|
-
assert(3, my_list.length)
|
503
|
-
assert(expected, actual)
|
504
|
-
|
505
|
-
# good
|
506
|
-
assert_equal(3, my_list.length)
|
507
|
-
assert_equal(expected, actual)
|
508
|
-
assert(foo, 'message')
|
509
|
-
----
|
510
|
-
|
511
|
-
== Minitest/AssertionInLifecycleHook
|
512
|
-
|
513
|
-
|===
|
514
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
515
|
-
|
516
|
-
| Pending
|
517
|
-
| Yes
|
518
|
-
| No
|
519
|
-
| 0.10
|
520
|
-
| -
|
521
|
-
|===
|
522
|
-
|
523
|
-
Checks for usage of assertions in lifecycle hooks.
|
524
|
-
|
525
|
-
=== Examples
|
526
|
-
|
527
|
-
[source,ruby]
|
528
|
-
----
|
529
|
-
# bad
|
530
|
-
class FooTest < Minitest::Test
|
531
|
-
def setup
|
532
|
-
assert_equal(foo, bar)
|
533
|
-
end
|
534
|
-
end
|
535
|
-
|
536
|
-
# good
|
537
|
-
class FooTest < Minitest::Test
|
538
|
-
def test_something
|
539
|
-
assert_equal(foo, bar)
|
540
|
-
end
|
541
|
-
end
|
542
|
-
----
|
543
|
-
|
544
|
-
== Minitest/DuplicateTestRun
|
545
|
-
|
546
|
-
|===
|
547
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
548
|
-
|
549
|
-
| Pending
|
550
|
-
| Yes
|
551
|
-
| No
|
552
|
-
| 0.19
|
553
|
-
| -
|
554
|
-
|===
|
555
|
-
|
556
|
-
If a Minitest class inherits from another class,
|
557
|
-
it will also inherit its methods causing Minitest to run the parent's tests methods twice.
|
558
|
-
|
559
|
-
This cop detects when there are two tests classes, one inherits from the other, and both have tests methods.
|
560
|
-
This cop will add an offense to the Child class in such a case.
|
561
|
-
|
562
|
-
=== Examples
|
563
|
-
|
564
|
-
[source,ruby]
|
565
|
-
----
|
566
|
-
# bad
|
567
|
-
class ParentTest < Minitest::Test
|
568
|
-
def test_parent # it will run this test twice.
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
class ChildTest < ParentTest
|
573
|
-
def test_child
|
574
|
-
end
|
575
|
-
end
|
576
|
-
|
577
|
-
# good
|
578
|
-
class ParentTest < Minitest::Test
|
579
|
-
def test_parent
|
580
|
-
end
|
581
|
-
end
|
582
|
-
|
583
|
-
class ChildTest < Minitest::Test
|
584
|
-
def test_child
|
585
|
-
end
|
586
|
-
end
|
587
|
-
|
588
|
-
# good
|
589
|
-
class ParentTest < Minitest::Test
|
590
|
-
end
|
591
|
-
|
592
|
-
class ChildTest
|
593
|
-
def test_child
|
594
|
-
end
|
595
|
-
|
596
|
-
def test_parent
|
597
|
-
end
|
598
|
-
end
|
599
|
-
----
|
600
|
-
|
601
|
-
=== References
|
602
|
-
|
603
|
-
* https://minitest.rubystyle.guide/#subclassing-test-cases
|
604
|
-
|
605
|
-
== Minitest/GlobalExpectations
|
606
|
-
|
607
|
-
|===
|
608
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
609
|
-
|
610
|
-
| Enabled
|
611
|
-
| Yes
|
612
|
-
| Yes
|
613
|
-
| 0.7
|
614
|
-
| 0.16
|
615
|
-
|===
|
616
|
-
|
617
|
-
Checks for deprecated global expectations
|
618
|
-
and autocorrects them to use expect format.
|
619
|
-
|
620
|
-
=== Examples
|
621
|
-
|
622
|
-
==== EnforcedStyle: any (default)
|
623
|
-
|
624
|
-
[source,ruby]
|
625
|
-
----
|
626
|
-
# bad
|
627
|
-
musts.must_equal expected_musts
|
628
|
-
wonts.wont_match expected_wonts
|
629
|
-
musts.must_raise TypeError
|
630
|
-
|
631
|
-
# good
|
632
|
-
_(musts).must_equal expected_musts
|
633
|
-
_(wonts).wont_match expected_wonts
|
634
|
-
_ { musts }.must_raise TypeError
|
635
|
-
|
636
|
-
expect(musts).must_equal expected_musts
|
637
|
-
expect(wonts).wont_match expected_wonts
|
638
|
-
expect { musts }.must_raise TypeError
|
639
|
-
|
640
|
-
value(musts).must_equal expected_musts
|
641
|
-
value(wonts).wont_match expected_wonts
|
642
|
-
value { musts }.must_raise TypeError
|
643
|
-
----
|
644
|
-
|
645
|
-
==== EnforcedStyle: _
|
646
|
-
|
647
|
-
[source,ruby]
|
648
|
-
----
|
649
|
-
# bad
|
650
|
-
musts.must_equal expected_musts
|
651
|
-
wonts.wont_match expected_wonts
|
652
|
-
musts.must_raise TypeError
|
653
|
-
|
654
|
-
expect(musts).must_equal expected_musts
|
655
|
-
expect(wonts).wont_match expected_wonts
|
656
|
-
expect { musts }.must_raise TypeError
|
657
|
-
|
658
|
-
value(musts).must_equal expected_musts
|
659
|
-
value(wonts).wont_match expected_wonts
|
660
|
-
value { musts }.must_raise TypeError
|
661
|
-
|
662
|
-
# good
|
663
|
-
_(musts).must_equal expected_musts
|
664
|
-
_(wonts).wont_match expected_wonts
|
665
|
-
_ { musts }.must_raise TypeError
|
666
|
-
----
|
667
|
-
|
668
|
-
==== EnforcedStyle: expect
|
669
|
-
|
670
|
-
[source,ruby]
|
671
|
-
----
|
672
|
-
# bad
|
673
|
-
musts.must_equal expected_musts
|
674
|
-
wonts.wont_match expected_wonts
|
675
|
-
musts.must_raise TypeError
|
676
|
-
|
677
|
-
_(musts).must_equal expected_musts
|
678
|
-
_(wonts).wont_match expected_wonts
|
679
|
-
_ { musts }.must_raise TypeError
|
680
|
-
|
681
|
-
value(musts).must_equal expected_musts
|
682
|
-
value(wonts).wont_match expected_wonts
|
683
|
-
value { musts }.must_raise TypeError
|
684
|
-
|
685
|
-
# good
|
686
|
-
expect(musts).must_equal expected_musts
|
687
|
-
expect(wonts).wont_match expected_wonts
|
688
|
-
expect { musts }.must_raise TypeError
|
689
|
-
----
|
690
|
-
|
691
|
-
==== EnforcedStyle: value
|
692
|
-
|
693
|
-
[source,ruby]
|
694
|
-
----
|
695
|
-
# bad
|
696
|
-
musts.must_equal expected_musts
|
697
|
-
wonts.wont_match expected_wonts
|
698
|
-
musts.must_raise TypeError
|
699
|
-
|
700
|
-
_(musts).must_equal expected_musts
|
701
|
-
_(wonts).wont_match expected_wonts
|
702
|
-
_ { musts }.must_raise TypeError
|
703
|
-
|
704
|
-
expect(musts).must_equal expected_musts
|
705
|
-
expect(wonts).wont_match expected_wonts
|
706
|
-
expect { musts }.must_raise TypeError
|
707
|
-
|
708
|
-
# good
|
709
|
-
value(musts).must_equal expected_musts
|
710
|
-
value(wonts).wont_match expected_wonts
|
711
|
-
value { musts }.must_raise TypeError
|
712
|
-
----
|
713
|
-
|
714
|
-
=== Configurable attributes
|
715
|
-
|
716
|
-
|===
|
717
|
-
| Name | Default value | Configurable values
|
718
|
-
|
719
|
-
| EnforcedStyle
|
720
|
-
| `any`
|
721
|
-
| `_`, `any`, `expect`, `value`
|
722
|
-
|
723
|
-
| Include
|
724
|
-
| `+**/test/**/*+`, `+**/*_test.rb+`, `+**/spec/**/*+`, `+**/*_spec.rb+`
|
725
|
-
| Array
|
726
|
-
|===
|
727
|
-
|
728
|
-
=== References
|
729
|
-
|
730
|
-
* https://minitest.rubystyle.guide#global-expectations
|
731
|
-
|
732
|
-
== Minitest/LiteralAsActualArgument
|
733
|
-
|
734
|
-
|===
|
735
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
736
|
-
|
737
|
-
| Pending
|
738
|
-
| Yes
|
739
|
-
| Yes
|
740
|
-
| 0.10
|
741
|
-
| -
|
742
|
-
|===
|
743
|
-
|
744
|
-
Enforces correct order of expected and
|
745
|
-
actual arguments for `assert_equal`.
|
746
|
-
|
747
|
-
=== Examples
|
748
|
-
|
749
|
-
[source,ruby]
|
750
|
-
----
|
751
|
-
# bad
|
752
|
-
assert_equal foo, 2
|
753
|
-
assert_equal foo, [1, 2]
|
754
|
-
assert_equal foo, [1, 2], 'message'
|
755
|
-
|
756
|
-
# good
|
757
|
-
assert_equal 2, foo
|
758
|
-
assert_equal [1, 2], foo
|
759
|
-
assert_equal [1, 2], foo, 'message'
|
760
|
-
----
|
761
|
-
|
762
|
-
=== References
|
763
|
-
|
764
|
-
* https://minitest.rubystyle.guide/#assert-equal-arguments-order
|
765
|
-
|
766
|
-
== Minitest/MultipleAssertions
|
767
|
-
|
768
|
-
|===
|
769
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
770
|
-
|
771
|
-
| Pending
|
772
|
-
| Yes
|
773
|
-
| No
|
774
|
-
| 0.10
|
775
|
-
| -
|
776
|
-
|===
|
777
|
-
|
778
|
-
Checks if test cases contain too many assertion calls.
|
779
|
-
The maximum allowed assertion calls is configurable.
|
780
|
-
|
781
|
-
=== Examples
|
782
|
-
|
783
|
-
==== Max: 1
|
784
|
-
|
785
|
-
[source,ruby]
|
786
|
-
----
|
787
|
-
# bad
|
788
|
-
class FooTest < Minitest::Test
|
789
|
-
def test_asserts_twice
|
790
|
-
assert_equal(42, do_something)
|
791
|
-
assert_empty(array)
|
792
|
-
end
|
793
|
-
end
|
794
|
-
|
795
|
-
# good
|
796
|
-
class FooTest < Minitest::Test
|
797
|
-
def test_asserts_once
|
798
|
-
assert_equal(42, do_something)
|
799
|
-
end
|
800
|
-
|
801
|
-
def test_another_asserts_once
|
802
|
-
assert_empty(array)
|
803
|
-
end
|
804
|
-
end
|
805
|
-
----
|
806
|
-
|
807
|
-
=== Configurable attributes
|
808
|
-
|
809
|
-
|===
|
810
|
-
| Name | Default value | Configurable values
|
811
|
-
|
812
|
-
| Max
|
813
|
-
| `3`
|
814
|
-
| Integer
|
815
|
-
|===
|
816
|
-
|
817
|
-
== Minitest/NoAssertions
|
818
|
-
|
819
|
-
|===
|
820
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
821
|
-
|
822
|
-
| Disabled
|
823
|
-
| Yes
|
824
|
-
| No
|
825
|
-
| 0.12
|
826
|
-
| -
|
827
|
-
|===
|
828
|
-
|
829
|
-
Checks if test cases contain any assertion calls.
|
830
|
-
|
831
|
-
=== Examples
|
832
|
-
|
833
|
-
[source,ruby]
|
834
|
-
----
|
835
|
-
# bad
|
836
|
-
class FooTest < Minitest::Test
|
837
|
-
def test_the_truth
|
838
|
-
end
|
839
|
-
end
|
840
|
-
|
841
|
-
# good
|
842
|
-
class FooTest < Minitest::Test
|
843
|
-
def test_the_truth
|
844
|
-
assert true
|
845
|
-
end
|
846
|
-
end
|
847
|
-
----
|
848
|
-
|
849
|
-
== Minitest/RefuteEmpty
|
850
|
-
|
851
|
-
|===
|
852
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
853
|
-
|
854
|
-
| Enabled
|
855
|
-
| Yes
|
856
|
-
| Yes
|
857
|
-
| 0.3
|
858
|
-
| -
|
859
|
-
|===
|
860
|
-
|
861
|
-
Enforces to use `refute_empty` instead of using `refute(object.empty?)`.
|
862
|
-
|
863
|
-
=== Examples
|
864
|
-
|
865
|
-
[source,ruby]
|
866
|
-
----
|
867
|
-
# bad
|
868
|
-
refute(object.empty?)
|
869
|
-
refute(object.empty?, 'message')
|
870
|
-
|
871
|
-
# good
|
872
|
-
refute_empty(object)
|
873
|
-
refute_empty(object, 'message')
|
874
|
-
----
|
875
|
-
|
876
|
-
=== References
|
877
|
-
|
878
|
-
* https://minitest.rubystyle.guide#refute-empty
|
879
|
-
|
880
|
-
== Minitest/RefuteEqual
|
881
|
-
|
882
|
-
|===
|
883
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
884
|
-
|
885
|
-
| Enabled
|
886
|
-
| Yes
|
887
|
-
| Yes
|
888
|
-
| 0.3
|
889
|
-
| -
|
890
|
-
|===
|
891
|
-
|
892
|
-
Enforces the use of `refute_equal(expected, object)`
|
893
|
-
over `assert(expected != actual)` or `assert(! expected == actual)`.
|
894
|
-
|
895
|
-
=== Examples
|
896
|
-
|
897
|
-
[source,ruby]
|
898
|
-
----
|
899
|
-
# bad
|
900
|
-
assert("rubocop-minitest" != actual)
|
901
|
-
assert(! "rubocop-minitest" == actual)
|
902
|
-
|
903
|
-
# good
|
904
|
-
refute_equal("rubocop-minitest", actual)
|
905
|
-
----
|
906
|
-
|
907
|
-
=== References
|
908
|
-
|
909
|
-
* https://minitest.rubystyle.guide#refute-equal
|
910
|
-
|
911
|
-
== Minitest/RefuteFalse
|
912
|
-
|
913
|
-
|===
|
914
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
915
|
-
|
916
|
-
| Enabled
|
917
|
-
| Yes
|
918
|
-
| Yes
|
919
|
-
| 0.3
|
920
|
-
| -
|
921
|
-
|===
|
922
|
-
|
923
|
-
Enforces the use of `refute(object)` over `assert_equal(false, object)`.
|
924
|
-
|
925
|
-
=== Examples
|
926
|
-
|
927
|
-
[source,ruby]
|
928
|
-
----
|
929
|
-
# bad
|
930
|
-
assert_equal(false, actual)
|
931
|
-
assert_equal(false, actual, 'message')
|
932
|
-
|
933
|
-
assert(!test)
|
934
|
-
assert(!test, 'message')
|
935
|
-
|
936
|
-
# good
|
937
|
-
refute(actual)
|
938
|
-
refute(actual, 'message')
|
939
|
-
----
|
940
|
-
|
941
|
-
=== References
|
942
|
-
|
943
|
-
* https://minitest.rubystyle.guide#refute-false
|
944
|
-
|
945
|
-
== Minitest/RefuteInDelta
|
946
|
-
|
947
|
-
|===
|
948
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
949
|
-
|
950
|
-
| Pending
|
951
|
-
| Yes
|
952
|
-
| Yes
|
953
|
-
| 0.10
|
954
|
-
| -
|
955
|
-
|===
|
956
|
-
|
957
|
-
Enforces the test to use `refute_in_delta`
|
958
|
-
instead of using `refute_equal` to compare floats.
|
959
|
-
|
960
|
-
=== Examples
|
961
|
-
|
962
|
-
[source,ruby]
|
963
|
-
----
|
964
|
-
# bad
|
965
|
-
refute_equal(0.2, actual)
|
966
|
-
refute_equal(0.2, actual, 'message')
|
967
|
-
|
968
|
-
# good
|
969
|
-
refute_in_delta(0.2, actual)
|
970
|
-
refute_in_delta(0.2, actual, 0.001, 'message')
|
971
|
-
----
|
972
|
-
|
973
|
-
=== References
|
974
|
-
|
975
|
-
* https://minitest.rubystyle.guide/#refute-in-delta
|
976
|
-
|
977
|
-
== Minitest/RefuteIncludes
|
978
|
-
|
979
|
-
|===
|
980
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
981
|
-
|
982
|
-
| Enabled
|
983
|
-
| Yes
|
984
|
-
| Yes
|
985
|
-
| 0.3
|
986
|
-
| -
|
987
|
-
|===
|
988
|
-
|
989
|
-
Enforces the test to use `refute_includes`
|
990
|
-
instead of using `refute(collection.include?(object))`.
|
991
|
-
|
992
|
-
=== Examples
|
993
|
-
|
994
|
-
[source,ruby]
|
995
|
-
----
|
996
|
-
# bad
|
997
|
-
refute(collection.include?(object))
|
998
|
-
refute(collection.include?(object), 'message')
|
999
|
-
|
1000
|
-
# good
|
1001
|
-
refute_includes(collection, object)
|
1002
|
-
refute_includes(collection, object, 'message')
|
1003
|
-
----
|
1004
|
-
|
1005
|
-
=== References
|
1006
|
-
|
1007
|
-
* https://minitest.rubystyle.guide#refute-includes
|
1008
|
-
|
1009
|
-
== Minitest/RefuteInstanceOf
|
1010
|
-
|
1011
|
-
|===
|
1012
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1013
|
-
|
1014
|
-
| Enabled
|
1015
|
-
| Yes
|
1016
|
-
| Yes
|
1017
|
-
| 0.4
|
1018
|
-
| -
|
1019
|
-
|===
|
1020
|
-
|
1021
|
-
Enforces the use of `refute_instance_of(Class, object)`
|
1022
|
-
over `refute(object.instance_of?(Class))`.
|
1023
|
-
|
1024
|
-
=== Examples
|
1025
|
-
|
1026
|
-
[source,ruby]
|
1027
|
-
----
|
1028
|
-
# bad
|
1029
|
-
refute(object.instance_of?(Class))
|
1030
|
-
refute(object.instance_of?(Class), 'message')
|
1031
|
-
|
1032
|
-
# good
|
1033
|
-
refute_instance_of(Class, object)
|
1034
|
-
refute_instance_of(Class, object, 'message')
|
1035
|
-
----
|
1036
|
-
|
1037
|
-
=== References
|
1038
|
-
|
1039
|
-
* https://minitest.rubystyle.guide#refute-instance-of
|
1040
|
-
|
1041
|
-
== Minitest/RefuteKindOf
|
1042
|
-
|
1043
|
-
|===
|
1044
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1045
|
-
|
1046
|
-
| Pending
|
1047
|
-
| Yes
|
1048
|
-
| Yes
|
1049
|
-
| 0.10
|
1050
|
-
| -
|
1051
|
-
|===
|
1052
|
-
|
1053
|
-
Enforces the use of `refute_kind_of(Class, object)`
|
1054
|
-
over `refute(object.kind_of?(Class))`.
|
1055
|
-
|
1056
|
-
=== Examples
|
1057
|
-
|
1058
|
-
[source,ruby]
|
1059
|
-
----
|
1060
|
-
# bad
|
1061
|
-
refute(object.kind_of?(Class))
|
1062
|
-
refute(object.kind_of?(Class), 'message')
|
1063
|
-
|
1064
|
-
# good
|
1065
|
-
refute_kind_of(Class, object)
|
1066
|
-
refute_kind_of(Class, object, 'message')
|
1067
|
-
----
|
1068
|
-
|
1069
|
-
=== References
|
1070
|
-
|
1071
|
-
* https://github.com/rubocop/minitest-style-guide#refute-kind-of
|
1072
|
-
|
1073
|
-
== Minitest/RefuteMatch
|
1074
|
-
|
1075
|
-
|===
|
1076
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1077
|
-
|
1078
|
-
| Enabled
|
1079
|
-
| Yes
|
1080
|
-
| Yes
|
1081
|
-
| 0.6
|
1082
|
-
| -
|
1083
|
-
|===
|
1084
|
-
|
1085
|
-
Enforces the test to use `refute_match`
|
1086
|
-
instead of using `refute(matcher.match(string))`.
|
1087
|
-
|
1088
|
-
=== Examples
|
1089
|
-
|
1090
|
-
[source,ruby]
|
1091
|
-
----
|
1092
|
-
# bad
|
1093
|
-
refute(matcher.match(string))
|
1094
|
-
refute(matcher.match(string), 'message')
|
1095
|
-
|
1096
|
-
# good
|
1097
|
-
refute_match(matcher, string)
|
1098
|
-
refute_match(matcher, string, 'message')
|
1099
|
-
----
|
1100
|
-
|
1101
|
-
=== References
|
1102
|
-
|
1103
|
-
* https://minitest.rubystyle.guide#refute-match
|
1104
|
-
|
1105
|
-
== Minitest/RefuteNil
|
1106
|
-
|
1107
|
-
|===
|
1108
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1109
|
-
|
1110
|
-
| Enabled
|
1111
|
-
| Yes
|
1112
|
-
| Yes
|
1113
|
-
| 0.2
|
1114
|
-
| -
|
1115
|
-
|===
|
1116
|
-
|
1117
|
-
Enforces the test to use `refute_nil` instead of using
|
1118
|
-
`refute_equal(nil, something)`, `refute(something.nil?)`, or `refute_predicate(something, :nil?)`.
|
1119
|
-
|
1120
|
-
=== Examples
|
1121
|
-
|
1122
|
-
[source,ruby]
|
1123
|
-
----
|
1124
|
-
# bad
|
1125
|
-
refute_equal(nil, actual)
|
1126
|
-
refute_equal(nil, actual, 'message')
|
1127
|
-
refute(actual.nil?)
|
1128
|
-
refute(actual.nil?, 'message')
|
1129
|
-
refute_predicate(object, :nil?)
|
1130
|
-
refute_predicate(object, :nil?, 'message')
|
1131
|
-
|
1132
|
-
# good
|
1133
|
-
refute_nil(actual)
|
1134
|
-
refute_nil(actual, 'message')
|
1135
|
-
----
|
1136
|
-
|
1137
|
-
=== References
|
1138
|
-
|
1139
|
-
* https://minitest.rubystyle.guide#refute-nil
|
1140
|
-
|
1141
|
-
== Minitest/RefutePathExists
|
1142
|
-
|
1143
|
-
|===
|
1144
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1145
|
-
|
1146
|
-
| Pending
|
1147
|
-
| Yes
|
1148
|
-
| Yes
|
1149
|
-
| 0.10
|
1150
|
-
| -
|
1151
|
-
|===
|
1152
|
-
|
1153
|
-
Enforces the test to use `refute_path_exists` instead of using `refute(File.exist?(path))`.
|
1154
|
-
|
1155
|
-
=== Examples
|
1156
|
-
|
1157
|
-
[source,ruby]
|
1158
|
-
----
|
1159
|
-
# bad
|
1160
|
-
refute(File.exist?(path))
|
1161
|
-
refute(File.exist?(path), 'message')
|
1162
|
-
|
1163
|
-
# good
|
1164
|
-
refute_path_exists(path)
|
1165
|
-
refute_path_exists(path, 'message')
|
1166
|
-
----
|
1167
|
-
|
1168
|
-
=== References
|
1169
|
-
|
1170
|
-
* https://minitest.rubystyle.guide/#refute-path-exists
|
1171
|
-
|
1172
|
-
== Minitest/RefutePredicate
|
1173
|
-
|
1174
|
-
|===
|
1175
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1176
|
-
|
1177
|
-
| Pending
|
1178
|
-
| Yes
|
1179
|
-
| Yes
|
1180
|
-
| 0.18
|
1181
|
-
| -
|
1182
|
-
|===
|
1183
|
-
|
1184
|
-
Enforces the test to use `refute_predicate`
|
1185
|
-
instead of using `refute(obj.a_predicate_method?)`.
|
1186
|
-
|
1187
|
-
=== Examples
|
1188
|
-
|
1189
|
-
[source,ruby]
|
1190
|
-
----
|
1191
|
-
# bad
|
1192
|
-
refute(obj.one?)
|
1193
|
-
refute(obj.one?, 'message')
|
1194
|
-
|
1195
|
-
# good
|
1196
|
-
refute_predicate(obj, :one?)
|
1197
|
-
refute_predicate(obj, :one?, 'message')
|
1198
|
-
----
|
1199
|
-
|
1200
|
-
=== References
|
1201
|
-
|
1202
|
-
* https://minitest.rubystyle.guide/#refute-predicate
|
1203
|
-
|
1204
|
-
== Minitest/RefuteRespondTo
|
1205
|
-
|
1206
|
-
|===
|
1207
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1208
|
-
|
1209
|
-
| Enabled
|
1210
|
-
| Yes
|
1211
|
-
| Yes
|
1212
|
-
| 0.4
|
1213
|
-
| -
|
1214
|
-
|===
|
1215
|
-
|
1216
|
-
Enforces the test to use `refute_respond_to(object, :do_something)`
|
1217
|
-
over `refute(object.respond_to?(:do_something))`.
|
1218
|
-
|
1219
|
-
=== Examples
|
1220
|
-
|
1221
|
-
[source,ruby]
|
1222
|
-
----
|
1223
|
-
# bad
|
1224
|
-
refute(object.respond_to?(:do_something))
|
1225
|
-
refute(object.respond_to?(:do_something), 'message')
|
1226
|
-
refute(respond_to?(:do_something))
|
1227
|
-
|
1228
|
-
# good
|
1229
|
-
refute_respond_to(object, :do_something)
|
1230
|
-
refute_respond_to(object, :do_something, 'message')
|
1231
|
-
refute_respond_to(self, :do_something)
|
1232
|
-
----
|
1233
|
-
|
1234
|
-
=== References
|
1235
|
-
|
1236
|
-
* https://minitest.rubystyle.guide#refute-respond-to
|
1237
|
-
|
1238
|
-
== Minitest/SkipEnsure
|
1239
|
-
|
1240
|
-
|===
|
1241
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1242
|
-
|
1243
|
-
| Pending
|
1244
|
-
| Yes
|
1245
|
-
| No
|
1246
|
-
| 0.20
|
1247
|
-
| -
|
1248
|
-
|===
|
1249
|
-
|
1250
|
-
Checks that `ensure` call even if `skip`. It is unexpected that `ensure` will be called when skipping test.
|
1251
|
-
If conditional `skip` is used, it checks that `ensure` is also called conditionally.
|
1252
|
-
|
1253
|
-
On the other hand, it accepts `skip` used in `rescue` because `ensure` may be teardown process to `begin`
|
1254
|
-
setup process.
|
1255
|
-
|
1256
|
-
=== Examples
|
1257
|
-
|
1258
|
-
[source,ruby]
|
1259
|
-
----
|
1260
|
-
# bad
|
1261
|
-
def test_skip
|
1262
|
-
skip 'This test is skipped.'
|
1263
|
-
|
1264
|
-
assert 'foo'.present?
|
1265
|
-
ensure
|
1266
|
-
do_something
|
1267
|
-
end
|
1268
|
-
|
1269
|
-
# bad
|
1270
|
-
def test_conditional_skip
|
1271
|
-
skip 'This test is skipped.' if condition
|
1272
|
-
|
1273
|
-
assert do_something
|
1274
|
-
ensure
|
1275
|
-
do_teardown
|
1276
|
-
end
|
1277
|
-
|
1278
|
-
# good
|
1279
|
-
def test_skip
|
1280
|
-
skip 'This test is skipped.'
|
1281
|
-
|
1282
|
-
begin
|
1283
|
-
assert 'foo'.present?
|
1284
|
-
ensure
|
1285
|
-
do_something
|
1286
|
-
end
|
1287
|
-
end
|
1288
|
-
|
1289
|
-
# good
|
1290
|
-
def test_conditional_skip
|
1291
|
-
skip 'This test is skipped.' if condition
|
1292
|
-
|
1293
|
-
assert do_something
|
1294
|
-
ensure
|
1295
|
-
if condition
|
1296
|
-
do_teardown
|
1297
|
-
end
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
# good
|
1301
|
-
def test_skip_is_used_in_rescue
|
1302
|
-
do_setup
|
1303
|
-
assert do_something
|
1304
|
-
rescue
|
1305
|
-
skip 'This test is skipped.'
|
1306
|
-
ensure
|
1307
|
-
do_teardown
|
1308
|
-
end
|
1309
|
-
----
|
1310
|
-
|
1311
|
-
== Minitest/TestMethodName
|
1312
|
-
|
1313
|
-
|===
|
1314
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1315
|
-
|
1316
|
-
| Pending
|
1317
|
-
| Yes
|
1318
|
-
| Yes
|
1319
|
-
| 0.10
|
1320
|
-
| -
|
1321
|
-
|===
|
1322
|
-
|
1323
|
-
Enforces that test method names start with `test_` prefix.
|
1324
|
-
It aims to prevent tests that aren't executed by forgetting to start test method name with `test_`.
|
1325
|
-
|
1326
|
-
=== Examples
|
1327
|
-
|
1328
|
-
[source,ruby]
|
1329
|
-
----
|
1330
|
-
# bad
|
1331
|
-
class FooTest < Minitest::Test
|
1332
|
-
def does_something
|
1333
|
-
assert_equal 42, do_something
|
1334
|
-
end
|
1335
|
-
end
|
1336
|
-
|
1337
|
-
# good
|
1338
|
-
class FooTest < Minitest::Test
|
1339
|
-
def test_does_something
|
1340
|
-
assert_equal 42, do_something
|
1341
|
-
end
|
1342
|
-
end
|
1343
|
-
|
1344
|
-
# good
|
1345
|
-
class FooTest < Minitest::Test
|
1346
|
-
def helper_method(argument)
|
1347
|
-
end
|
1348
|
-
end
|
1349
|
-
----
|
1350
|
-
|
1351
|
-
== Minitest/UnreachableAssertion
|
1352
|
-
|
1353
|
-
|===
|
1354
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1355
|
-
|
1356
|
-
| Pending
|
1357
|
-
| Yes
|
1358
|
-
| No
|
1359
|
-
| 0.14
|
1360
|
-
| -
|
1361
|
-
|===
|
1362
|
-
|
1363
|
-
Checks for `assert_raises` has an assertion method at
|
1364
|
-
the bottom of block because the assertion will be never reached.
|
1365
|
-
|
1366
|
-
=== Examples
|
1367
|
-
|
1368
|
-
[source,ruby]
|
1369
|
-
----
|
1370
|
-
# bad
|
1371
|
-
assert_raises FooError do
|
1372
|
-
obj.occur_error
|
1373
|
-
assert_equal('foo', obj.bar) # Never asserted.
|
1374
|
-
end
|
1375
|
-
|
1376
|
-
# good
|
1377
|
-
assert_raises FooError do
|
1378
|
-
obj.occur_error
|
1379
|
-
end
|
1380
|
-
assert_equal('foo', obj.bar)
|
1381
|
-
----
|
1382
|
-
|
1383
|
-
== Minitest/UnspecifiedException
|
1384
|
-
|
1385
|
-
|===
|
1386
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1387
|
-
|
1388
|
-
| Pending
|
1389
|
-
| Yes
|
1390
|
-
| No
|
1391
|
-
| 0.10
|
1392
|
-
| -
|
1393
|
-
|===
|
1394
|
-
|
1395
|
-
Checks for a specified error in `assert_raises`.
|
1396
|
-
|
1397
|
-
=== Examples
|
1398
|
-
|
1399
|
-
[source,ruby]
|
1400
|
-
----
|
1401
|
-
# bad
|
1402
|
-
assert_raises { raise FooException }
|
1403
|
-
assert_raises('This should have raised') { raise FooException }
|
1404
|
-
|
1405
|
-
# good
|
1406
|
-
assert_raises(FooException) { raise FooException }
|
1407
|
-
assert_raises(FooException, 'This should have raised') { raise FooException }
|
1408
|
-
----
|
1409
|
-
|
1410
|
-
=== References
|
1411
|
-
|
1412
|
-
* https://minitest.rubystyle.guide#unspecified-exception
|