rubocop-minitest 0.21.1 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +5 -0
- data/lib/rubocop/cop/minitest/assert_match.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_raises_with_regexp_argument.rb +36 -0
- data/lib/rubocop/cop/minitest_cops.rb +1 -0
- data/lib/rubocop/cop/mixin/argument_range_helper.rb +1 -0
- 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 +1 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- metadata +4 -81
- 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 -110
- data/.rubocop_todo.yml +0 -19
- data/.yamllint.yml +0 -9
- data/.yardopts +0 -3
- data/CHANGELOG.md +0 -336
- data/CONTRIBUTING.md +0 -69
- data/Gemfile +0 -16
- data/Rakefile +0 -56
- 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 -56
- data/docs/modules/ROOT/pages/cops_minitest.adoc +0 -1450
- 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.21.0.md +0 -5
- data/relnotes/v0.21.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 -86
@@ -1,1450 +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/AssertRaisesCompoundBody
|
383
|
-
|
384
|
-
|===
|
385
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
386
|
-
|
387
|
-
| Pending
|
388
|
-
| Yes
|
389
|
-
| No
|
390
|
-
| 0.21
|
391
|
-
| -
|
392
|
-
|===
|
393
|
-
|
394
|
-
Enforces the block body of `assert_raises { ... }` to be reduced to only the raising code.
|
395
|
-
|
396
|
-
=== Examples
|
397
|
-
|
398
|
-
[source,ruby]
|
399
|
-
----
|
400
|
-
# bad
|
401
|
-
assert_raises(MyError) do
|
402
|
-
foo
|
403
|
-
bar
|
404
|
-
end
|
405
|
-
|
406
|
-
# good
|
407
|
-
assert_raises(MyError) do
|
408
|
-
foo
|
409
|
-
end
|
410
|
-
|
411
|
-
# good
|
412
|
-
assert_raises(MyError) do
|
413
|
-
foo do
|
414
|
-
bar
|
415
|
-
baz
|
416
|
-
end
|
417
|
-
end
|
418
|
-
----
|
419
|
-
|
420
|
-
== Minitest/AssertRespondTo
|
421
|
-
|
422
|
-
|===
|
423
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
424
|
-
|
425
|
-
| Enabled
|
426
|
-
| Yes
|
427
|
-
| Yes
|
428
|
-
| 0.3
|
429
|
-
| -
|
430
|
-
|===
|
431
|
-
|
432
|
-
Enforces the use of `assert_respond_to(object, :do_something)`
|
433
|
-
over `assert(object.respond_to?(:do_something))`.
|
434
|
-
|
435
|
-
=== Examples
|
436
|
-
|
437
|
-
[source,ruby]
|
438
|
-
----
|
439
|
-
# bad
|
440
|
-
assert(object.respond_to?(:do_something))
|
441
|
-
assert(object.respond_to?(:do_something), 'message')
|
442
|
-
assert(respond_to?(:do_something))
|
443
|
-
|
444
|
-
# good
|
445
|
-
assert_respond_to(object, :do_something)
|
446
|
-
assert_respond_to(object, :do_something, 'message')
|
447
|
-
assert_respond_to(self, :do_something)
|
448
|
-
----
|
449
|
-
|
450
|
-
=== References
|
451
|
-
|
452
|
-
* https://minitest.rubystyle.guide#assert-responds-to-method
|
453
|
-
|
454
|
-
== Minitest/AssertSilent
|
455
|
-
|
456
|
-
|===
|
457
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
458
|
-
|
459
|
-
| Pending
|
460
|
-
| Yes
|
461
|
-
| Yes
|
462
|
-
| 0.10
|
463
|
-
| -
|
464
|
-
|===
|
465
|
-
|
466
|
-
Enforces the test to use `assert_silent { ... }`
|
467
|
-
instead of using `assert_output('', '') { ... }`.
|
468
|
-
|
469
|
-
=== Examples
|
470
|
-
|
471
|
-
[source,ruby]
|
472
|
-
----
|
473
|
-
# bad
|
474
|
-
assert_output('', '') { puts object.do_something }
|
475
|
-
|
476
|
-
# good
|
477
|
-
assert_silent { puts object.do_something }
|
478
|
-
----
|
479
|
-
|
480
|
-
=== References
|
481
|
-
|
482
|
-
* https://github.com/rubocop/minitest-style-guide#assert-silent
|
483
|
-
|
484
|
-
== Minitest/AssertTruthy
|
485
|
-
|
486
|
-
|===
|
487
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
488
|
-
|
489
|
-
| Enabled
|
490
|
-
| Yes
|
491
|
-
| Yes
|
492
|
-
| 0.2
|
493
|
-
| -
|
494
|
-
|===
|
495
|
-
|
496
|
-
Enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.
|
497
|
-
|
498
|
-
=== Examples
|
499
|
-
|
500
|
-
[source,ruby]
|
501
|
-
----
|
502
|
-
# bad
|
503
|
-
assert_equal(true, actual)
|
504
|
-
assert_equal(true, actual, 'message')
|
505
|
-
|
506
|
-
# good
|
507
|
-
assert(actual)
|
508
|
-
assert(actual, 'message')
|
509
|
-
----
|
510
|
-
|
511
|
-
=== References
|
512
|
-
|
513
|
-
* https://minitest.rubystyle.guide#assert-truthy
|
514
|
-
|
515
|
-
== Minitest/AssertWithExpectedArgument
|
516
|
-
|
517
|
-
|===
|
518
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
519
|
-
|
520
|
-
| Pending
|
521
|
-
| No
|
522
|
-
| No
|
523
|
-
| 0.11
|
524
|
-
| -
|
525
|
-
|===
|
526
|
-
|
527
|
-
Tries to detect when a user accidentally used
|
528
|
-
`assert` when they meant to use `assert_equal`.
|
529
|
-
|
530
|
-
=== Safety
|
531
|
-
|
532
|
-
This cop is unsafe because it is not possible to determine
|
533
|
-
whether the second argument of `assert` is a message or not.
|
534
|
-
|
535
|
-
=== Examples
|
536
|
-
|
537
|
-
[source,ruby]
|
538
|
-
----
|
539
|
-
# bad
|
540
|
-
assert(3, my_list.length)
|
541
|
-
assert(expected, actual)
|
542
|
-
|
543
|
-
# good
|
544
|
-
assert_equal(3, my_list.length)
|
545
|
-
assert_equal(expected, actual)
|
546
|
-
assert(foo, 'message')
|
547
|
-
----
|
548
|
-
|
549
|
-
== Minitest/AssertionInLifecycleHook
|
550
|
-
|
551
|
-
|===
|
552
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
553
|
-
|
554
|
-
| Pending
|
555
|
-
| Yes
|
556
|
-
| No
|
557
|
-
| 0.10
|
558
|
-
| -
|
559
|
-
|===
|
560
|
-
|
561
|
-
Checks for usage of assertions in lifecycle hooks.
|
562
|
-
|
563
|
-
=== Examples
|
564
|
-
|
565
|
-
[source,ruby]
|
566
|
-
----
|
567
|
-
# bad
|
568
|
-
class FooTest < Minitest::Test
|
569
|
-
def setup
|
570
|
-
assert_equal(foo, bar)
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
# good
|
575
|
-
class FooTest < Minitest::Test
|
576
|
-
def test_something
|
577
|
-
assert_equal(foo, bar)
|
578
|
-
end
|
579
|
-
end
|
580
|
-
----
|
581
|
-
|
582
|
-
== Minitest/DuplicateTestRun
|
583
|
-
|
584
|
-
|===
|
585
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
586
|
-
|
587
|
-
| Pending
|
588
|
-
| Yes
|
589
|
-
| No
|
590
|
-
| 0.19
|
591
|
-
| -
|
592
|
-
|===
|
593
|
-
|
594
|
-
If a Minitest class inherits from another class,
|
595
|
-
it will also inherit its methods causing Minitest to run the parent's tests methods twice.
|
596
|
-
|
597
|
-
This cop detects when there are two tests classes, one inherits from the other, and both have tests methods.
|
598
|
-
This cop will add an offense to the Child class in such a case.
|
599
|
-
|
600
|
-
=== Examples
|
601
|
-
|
602
|
-
[source,ruby]
|
603
|
-
----
|
604
|
-
# bad
|
605
|
-
class ParentTest < Minitest::Test
|
606
|
-
def test_parent # it will run this test twice.
|
607
|
-
end
|
608
|
-
end
|
609
|
-
|
610
|
-
class ChildTest < ParentTest
|
611
|
-
def test_child
|
612
|
-
end
|
613
|
-
end
|
614
|
-
|
615
|
-
# good
|
616
|
-
class ParentTest < Minitest::Test
|
617
|
-
def test_parent
|
618
|
-
end
|
619
|
-
end
|
620
|
-
|
621
|
-
class ChildTest < Minitest::Test
|
622
|
-
def test_child
|
623
|
-
end
|
624
|
-
end
|
625
|
-
|
626
|
-
# good
|
627
|
-
class ParentTest < Minitest::Test
|
628
|
-
end
|
629
|
-
|
630
|
-
class ChildTest
|
631
|
-
def test_child
|
632
|
-
end
|
633
|
-
|
634
|
-
def test_parent
|
635
|
-
end
|
636
|
-
end
|
637
|
-
----
|
638
|
-
|
639
|
-
=== References
|
640
|
-
|
641
|
-
* https://minitest.rubystyle.guide/#subclassing-test-cases
|
642
|
-
|
643
|
-
== Minitest/GlobalExpectations
|
644
|
-
|
645
|
-
|===
|
646
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
647
|
-
|
648
|
-
| Enabled
|
649
|
-
| Yes
|
650
|
-
| Yes
|
651
|
-
| 0.7
|
652
|
-
| 0.16
|
653
|
-
|===
|
654
|
-
|
655
|
-
Checks for deprecated global expectations
|
656
|
-
and autocorrects them to use expect format.
|
657
|
-
|
658
|
-
=== Examples
|
659
|
-
|
660
|
-
==== EnforcedStyle: any (default)
|
661
|
-
|
662
|
-
[source,ruby]
|
663
|
-
----
|
664
|
-
# bad
|
665
|
-
musts.must_equal expected_musts
|
666
|
-
wonts.wont_match expected_wonts
|
667
|
-
musts.must_raise TypeError
|
668
|
-
|
669
|
-
# good
|
670
|
-
_(musts).must_equal expected_musts
|
671
|
-
_(wonts).wont_match expected_wonts
|
672
|
-
_ { musts }.must_raise TypeError
|
673
|
-
|
674
|
-
expect(musts).must_equal expected_musts
|
675
|
-
expect(wonts).wont_match expected_wonts
|
676
|
-
expect { musts }.must_raise TypeError
|
677
|
-
|
678
|
-
value(musts).must_equal expected_musts
|
679
|
-
value(wonts).wont_match expected_wonts
|
680
|
-
value { musts }.must_raise TypeError
|
681
|
-
----
|
682
|
-
|
683
|
-
==== EnforcedStyle: _
|
684
|
-
|
685
|
-
[source,ruby]
|
686
|
-
----
|
687
|
-
# bad
|
688
|
-
musts.must_equal expected_musts
|
689
|
-
wonts.wont_match expected_wonts
|
690
|
-
musts.must_raise TypeError
|
691
|
-
|
692
|
-
expect(musts).must_equal expected_musts
|
693
|
-
expect(wonts).wont_match expected_wonts
|
694
|
-
expect { musts }.must_raise TypeError
|
695
|
-
|
696
|
-
value(musts).must_equal expected_musts
|
697
|
-
value(wonts).wont_match expected_wonts
|
698
|
-
value { musts }.must_raise TypeError
|
699
|
-
|
700
|
-
# good
|
701
|
-
_(musts).must_equal expected_musts
|
702
|
-
_(wonts).wont_match expected_wonts
|
703
|
-
_ { musts }.must_raise TypeError
|
704
|
-
----
|
705
|
-
|
706
|
-
==== EnforcedStyle: expect
|
707
|
-
|
708
|
-
[source,ruby]
|
709
|
-
----
|
710
|
-
# bad
|
711
|
-
musts.must_equal expected_musts
|
712
|
-
wonts.wont_match expected_wonts
|
713
|
-
musts.must_raise TypeError
|
714
|
-
|
715
|
-
_(musts).must_equal expected_musts
|
716
|
-
_(wonts).wont_match expected_wonts
|
717
|
-
_ { musts }.must_raise TypeError
|
718
|
-
|
719
|
-
value(musts).must_equal expected_musts
|
720
|
-
value(wonts).wont_match expected_wonts
|
721
|
-
value { musts }.must_raise TypeError
|
722
|
-
|
723
|
-
# good
|
724
|
-
expect(musts).must_equal expected_musts
|
725
|
-
expect(wonts).wont_match expected_wonts
|
726
|
-
expect { musts }.must_raise TypeError
|
727
|
-
----
|
728
|
-
|
729
|
-
==== EnforcedStyle: value
|
730
|
-
|
731
|
-
[source,ruby]
|
732
|
-
----
|
733
|
-
# bad
|
734
|
-
musts.must_equal expected_musts
|
735
|
-
wonts.wont_match expected_wonts
|
736
|
-
musts.must_raise TypeError
|
737
|
-
|
738
|
-
_(musts).must_equal expected_musts
|
739
|
-
_(wonts).wont_match expected_wonts
|
740
|
-
_ { musts }.must_raise TypeError
|
741
|
-
|
742
|
-
expect(musts).must_equal expected_musts
|
743
|
-
expect(wonts).wont_match expected_wonts
|
744
|
-
expect { musts }.must_raise TypeError
|
745
|
-
|
746
|
-
# good
|
747
|
-
value(musts).must_equal expected_musts
|
748
|
-
value(wonts).wont_match expected_wonts
|
749
|
-
value { musts }.must_raise TypeError
|
750
|
-
----
|
751
|
-
|
752
|
-
=== Configurable attributes
|
753
|
-
|
754
|
-
|===
|
755
|
-
| Name | Default value | Configurable values
|
756
|
-
|
757
|
-
| EnforcedStyle
|
758
|
-
| `any`
|
759
|
-
| `_`, `any`, `expect`, `value`
|
760
|
-
|
761
|
-
| Include
|
762
|
-
| `+**/test/**/*+`, `+**/*_test.rb+`, `+**/spec/**/*+`, `+**/*_spec.rb+`
|
763
|
-
| Array
|
764
|
-
|===
|
765
|
-
|
766
|
-
=== References
|
767
|
-
|
768
|
-
* https://minitest.rubystyle.guide#global-expectations
|
769
|
-
|
770
|
-
== Minitest/LiteralAsActualArgument
|
771
|
-
|
772
|
-
|===
|
773
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
774
|
-
|
775
|
-
| Pending
|
776
|
-
| Yes
|
777
|
-
| Yes
|
778
|
-
| 0.10
|
779
|
-
| -
|
780
|
-
|===
|
781
|
-
|
782
|
-
Enforces correct order of expected and
|
783
|
-
actual arguments for `assert_equal`.
|
784
|
-
|
785
|
-
=== Examples
|
786
|
-
|
787
|
-
[source,ruby]
|
788
|
-
----
|
789
|
-
# bad
|
790
|
-
assert_equal foo, 2
|
791
|
-
assert_equal foo, [1, 2]
|
792
|
-
assert_equal foo, [1, 2], 'message'
|
793
|
-
|
794
|
-
# good
|
795
|
-
assert_equal 2, foo
|
796
|
-
assert_equal [1, 2], foo
|
797
|
-
assert_equal [1, 2], foo, 'message'
|
798
|
-
----
|
799
|
-
|
800
|
-
=== References
|
801
|
-
|
802
|
-
* https://minitest.rubystyle.guide/#assert-equal-arguments-order
|
803
|
-
|
804
|
-
== Minitest/MultipleAssertions
|
805
|
-
|
806
|
-
|===
|
807
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
808
|
-
|
809
|
-
| Pending
|
810
|
-
| Yes
|
811
|
-
| No
|
812
|
-
| 0.10
|
813
|
-
| -
|
814
|
-
|===
|
815
|
-
|
816
|
-
Checks if test cases contain too many assertion calls.
|
817
|
-
The maximum allowed assertion calls is configurable.
|
818
|
-
|
819
|
-
=== Examples
|
820
|
-
|
821
|
-
==== Max: 1
|
822
|
-
|
823
|
-
[source,ruby]
|
824
|
-
----
|
825
|
-
# bad
|
826
|
-
class FooTest < Minitest::Test
|
827
|
-
def test_asserts_twice
|
828
|
-
assert_equal(42, do_something)
|
829
|
-
assert_empty(array)
|
830
|
-
end
|
831
|
-
end
|
832
|
-
|
833
|
-
# good
|
834
|
-
class FooTest < Minitest::Test
|
835
|
-
def test_asserts_once
|
836
|
-
assert_equal(42, do_something)
|
837
|
-
end
|
838
|
-
|
839
|
-
def test_another_asserts_once
|
840
|
-
assert_empty(array)
|
841
|
-
end
|
842
|
-
end
|
843
|
-
----
|
844
|
-
|
845
|
-
=== Configurable attributes
|
846
|
-
|
847
|
-
|===
|
848
|
-
| Name | Default value | Configurable values
|
849
|
-
|
850
|
-
| Max
|
851
|
-
| `3`
|
852
|
-
| Integer
|
853
|
-
|===
|
854
|
-
|
855
|
-
== Minitest/NoAssertions
|
856
|
-
|
857
|
-
|===
|
858
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
859
|
-
|
860
|
-
| Disabled
|
861
|
-
| Yes
|
862
|
-
| No
|
863
|
-
| 0.12
|
864
|
-
| -
|
865
|
-
|===
|
866
|
-
|
867
|
-
Checks if test cases contain any assertion calls.
|
868
|
-
|
869
|
-
=== Examples
|
870
|
-
|
871
|
-
[source,ruby]
|
872
|
-
----
|
873
|
-
# bad
|
874
|
-
class FooTest < Minitest::Test
|
875
|
-
def test_the_truth
|
876
|
-
end
|
877
|
-
end
|
878
|
-
|
879
|
-
# good
|
880
|
-
class FooTest < Minitest::Test
|
881
|
-
def test_the_truth
|
882
|
-
assert true
|
883
|
-
end
|
884
|
-
end
|
885
|
-
----
|
886
|
-
|
887
|
-
== Minitest/RefuteEmpty
|
888
|
-
|
889
|
-
|===
|
890
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
891
|
-
|
892
|
-
| Enabled
|
893
|
-
| Yes
|
894
|
-
| Yes
|
895
|
-
| 0.3
|
896
|
-
| -
|
897
|
-
|===
|
898
|
-
|
899
|
-
Enforces to use `refute_empty` instead of using `refute(object.empty?)`.
|
900
|
-
|
901
|
-
=== Examples
|
902
|
-
|
903
|
-
[source,ruby]
|
904
|
-
----
|
905
|
-
# bad
|
906
|
-
refute(object.empty?)
|
907
|
-
refute(object.empty?, 'message')
|
908
|
-
|
909
|
-
# good
|
910
|
-
refute_empty(object)
|
911
|
-
refute_empty(object, 'message')
|
912
|
-
----
|
913
|
-
|
914
|
-
=== References
|
915
|
-
|
916
|
-
* https://minitest.rubystyle.guide#refute-empty
|
917
|
-
|
918
|
-
== Minitest/RefuteEqual
|
919
|
-
|
920
|
-
|===
|
921
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
922
|
-
|
923
|
-
| Enabled
|
924
|
-
| Yes
|
925
|
-
| Yes
|
926
|
-
| 0.3
|
927
|
-
| -
|
928
|
-
|===
|
929
|
-
|
930
|
-
Enforces the use of `refute_equal(expected, object)`
|
931
|
-
over `assert(expected != actual)` or `assert(! expected == actual)`.
|
932
|
-
|
933
|
-
=== Examples
|
934
|
-
|
935
|
-
[source,ruby]
|
936
|
-
----
|
937
|
-
# bad
|
938
|
-
assert("rubocop-minitest" != actual)
|
939
|
-
assert(! "rubocop-minitest" == actual)
|
940
|
-
|
941
|
-
# good
|
942
|
-
refute_equal("rubocop-minitest", actual)
|
943
|
-
----
|
944
|
-
|
945
|
-
=== References
|
946
|
-
|
947
|
-
* https://minitest.rubystyle.guide#refute-equal
|
948
|
-
|
949
|
-
== Minitest/RefuteFalse
|
950
|
-
|
951
|
-
|===
|
952
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
953
|
-
|
954
|
-
| Enabled
|
955
|
-
| Yes
|
956
|
-
| Yes
|
957
|
-
| 0.3
|
958
|
-
| -
|
959
|
-
|===
|
960
|
-
|
961
|
-
Enforces the use of `refute(object)` over `assert_equal(false, object)`.
|
962
|
-
|
963
|
-
=== Examples
|
964
|
-
|
965
|
-
[source,ruby]
|
966
|
-
----
|
967
|
-
# bad
|
968
|
-
assert_equal(false, actual)
|
969
|
-
assert_equal(false, actual, 'message')
|
970
|
-
|
971
|
-
assert(!test)
|
972
|
-
assert(!test, 'message')
|
973
|
-
|
974
|
-
# good
|
975
|
-
refute(actual)
|
976
|
-
refute(actual, 'message')
|
977
|
-
----
|
978
|
-
|
979
|
-
=== References
|
980
|
-
|
981
|
-
* https://minitest.rubystyle.guide#refute-false
|
982
|
-
|
983
|
-
== Minitest/RefuteInDelta
|
984
|
-
|
985
|
-
|===
|
986
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
987
|
-
|
988
|
-
| Pending
|
989
|
-
| Yes
|
990
|
-
| Yes
|
991
|
-
| 0.10
|
992
|
-
| -
|
993
|
-
|===
|
994
|
-
|
995
|
-
Enforces the test to use `refute_in_delta`
|
996
|
-
instead of using `refute_equal` to compare floats.
|
997
|
-
|
998
|
-
=== Examples
|
999
|
-
|
1000
|
-
[source,ruby]
|
1001
|
-
----
|
1002
|
-
# bad
|
1003
|
-
refute_equal(0.2, actual)
|
1004
|
-
refute_equal(0.2, actual, 'message')
|
1005
|
-
|
1006
|
-
# good
|
1007
|
-
refute_in_delta(0.2, actual)
|
1008
|
-
refute_in_delta(0.2, actual, 0.001, 'message')
|
1009
|
-
----
|
1010
|
-
|
1011
|
-
=== References
|
1012
|
-
|
1013
|
-
* https://minitest.rubystyle.guide/#refute-in-delta
|
1014
|
-
|
1015
|
-
== Minitest/RefuteIncludes
|
1016
|
-
|
1017
|
-
|===
|
1018
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1019
|
-
|
1020
|
-
| Enabled
|
1021
|
-
| Yes
|
1022
|
-
| Yes
|
1023
|
-
| 0.3
|
1024
|
-
| -
|
1025
|
-
|===
|
1026
|
-
|
1027
|
-
Enforces the test to use `refute_includes`
|
1028
|
-
instead of using `refute(collection.include?(object))`.
|
1029
|
-
|
1030
|
-
=== Examples
|
1031
|
-
|
1032
|
-
[source,ruby]
|
1033
|
-
----
|
1034
|
-
# bad
|
1035
|
-
refute(collection.include?(object))
|
1036
|
-
refute(collection.include?(object), 'message')
|
1037
|
-
|
1038
|
-
# good
|
1039
|
-
refute_includes(collection, object)
|
1040
|
-
refute_includes(collection, object, 'message')
|
1041
|
-
----
|
1042
|
-
|
1043
|
-
=== References
|
1044
|
-
|
1045
|
-
* https://minitest.rubystyle.guide#refute-includes
|
1046
|
-
|
1047
|
-
== Minitest/RefuteInstanceOf
|
1048
|
-
|
1049
|
-
|===
|
1050
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1051
|
-
|
1052
|
-
| Enabled
|
1053
|
-
| Yes
|
1054
|
-
| Yes
|
1055
|
-
| 0.4
|
1056
|
-
| -
|
1057
|
-
|===
|
1058
|
-
|
1059
|
-
Enforces the use of `refute_instance_of(Class, object)`
|
1060
|
-
over `refute(object.instance_of?(Class))`.
|
1061
|
-
|
1062
|
-
=== Examples
|
1063
|
-
|
1064
|
-
[source,ruby]
|
1065
|
-
----
|
1066
|
-
# bad
|
1067
|
-
refute(object.instance_of?(Class))
|
1068
|
-
refute(object.instance_of?(Class), 'message')
|
1069
|
-
|
1070
|
-
# good
|
1071
|
-
refute_instance_of(Class, object)
|
1072
|
-
refute_instance_of(Class, object, 'message')
|
1073
|
-
----
|
1074
|
-
|
1075
|
-
=== References
|
1076
|
-
|
1077
|
-
* https://minitest.rubystyle.guide#refute-instance-of
|
1078
|
-
|
1079
|
-
== Minitest/RefuteKindOf
|
1080
|
-
|
1081
|
-
|===
|
1082
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1083
|
-
|
1084
|
-
| Pending
|
1085
|
-
| Yes
|
1086
|
-
| Yes
|
1087
|
-
| 0.10
|
1088
|
-
| -
|
1089
|
-
|===
|
1090
|
-
|
1091
|
-
Enforces the use of `refute_kind_of(Class, object)`
|
1092
|
-
over `refute(object.kind_of?(Class))`.
|
1093
|
-
|
1094
|
-
=== Examples
|
1095
|
-
|
1096
|
-
[source,ruby]
|
1097
|
-
----
|
1098
|
-
# bad
|
1099
|
-
refute(object.kind_of?(Class))
|
1100
|
-
refute(object.kind_of?(Class), 'message')
|
1101
|
-
|
1102
|
-
# good
|
1103
|
-
refute_kind_of(Class, object)
|
1104
|
-
refute_kind_of(Class, object, 'message')
|
1105
|
-
----
|
1106
|
-
|
1107
|
-
=== References
|
1108
|
-
|
1109
|
-
* https://github.com/rubocop/minitest-style-guide#refute-kind-of
|
1110
|
-
|
1111
|
-
== Minitest/RefuteMatch
|
1112
|
-
|
1113
|
-
|===
|
1114
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1115
|
-
|
1116
|
-
| Enabled
|
1117
|
-
| Yes
|
1118
|
-
| Yes
|
1119
|
-
| 0.6
|
1120
|
-
| -
|
1121
|
-
|===
|
1122
|
-
|
1123
|
-
Enforces the test to use `refute_match`
|
1124
|
-
instead of using `refute(matcher.match(string))`.
|
1125
|
-
|
1126
|
-
=== Examples
|
1127
|
-
|
1128
|
-
[source,ruby]
|
1129
|
-
----
|
1130
|
-
# bad
|
1131
|
-
refute(matcher.match(string))
|
1132
|
-
refute(matcher.match(string), 'message')
|
1133
|
-
|
1134
|
-
# good
|
1135
|
-
refute_match(matcher, string)
|
1136
|
-
refute_match(matcher, string, 'message')
|
1137
|
-
----
|
1138
|
-
|
1139
|
-
=== References
|
1140
|
-
|
1141
|
-
* https://minitest.rubystyle.guide#refute-match
|
1142
|
-
|
1143
|
-
== Minitest/RefuteNil
|
1144
|
-
|
1145
|
-
|===
|
1146
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1147
|
-
|
1148
|
-
| Enabled
|
1149
|
-
| Yes
|
1150
|
-
| Yes
|
1151
|
-
| 0.2
|
1152
|
-
| -
|
1153
|
-
|===
|
1154
|
-
|
1155
|
-
Enforces the test to use `refute_nil` instead of using
|
1156
|
-
`refute_equal(nil, something)`, `refute(something.nil?)`, or `refute_predicate(something, :nil?)`.
|
1157
|
-
|
1158
|
-
=== Examples
|
1159
|
-
|
1160
|
-
[source,ruby]
|
1161
|
-
----
|
1162
|
-
# bad
|
1163
|
-
refute_equal(nil, actual)
|
1164
|
-
refute_equal(nil, actual, 'message')
|
1165
|
-
refute(actual.nil?)
|
1166
|
-
refute(actual.nil?, 'message')
|
1167
|
-
refute_predicate(object, :nil?)
|
1168
|
-
refute_predicate(object, :nil?, 'message')
|
1169
|
-
|
1170
|
-
# good
|
1171
|
-
refute_nil(actual)
|
1172
|
-
refute_nil(actual, 'message')
|
1173
|
-
----
|
1174
|
-
|
1175
|
-
=== References
|
1176
|
-
|
1177
|
-
* https://minitest.rubystyle.guide#refute-nil
|
1178
|
-
|
1179
|
-
== Minitest/RefutePathExists
|
1180
|
-
|
1181
|
-
|===
|
1182
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1183
|
-
|
1184
|
-
| Pending
|
1185
|
-
| Yes
|
1186
|
-
| Yes
|
1187
|
-
| 0.10
|
1188
|
-
| -
|
1189
|
-
|===
|
1190
|
-
|
1191
|
-
Enforces the test to use `refute_path_exists` instead of using `refute(File.exist?(path))`.
|
1192
|
-
|
1193
|
-
=== Examples
|
1194
|
-
|
1195
|
-
[source,ruby]
|
1196
|
-
----
|
1197
|
-
# bad
|
1198
|
-
refute(File.exist?(path))
|
1199
|
-
refute(File.exist?(path), 'message')
|
1200
|
-
|
1201
|
-
# good
|
1202
|
-
refute_path_exists(path)
|
1203
|
-
refute_path_exists(path, 'message')
|
1204
|
-
----
|
1205
|
-
|
1206
|
-
=== References
|
1207
|
-
|
1208
|
-
* https://minitest.rubystyle.guide/#refute-path-exists
|
1209
|
-
|
1210
|
-
== Minitest/RefutePredicate
|
1211
|
-
|
1212
|
-
|===
|
1213
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1214
|
-
|
1215
|
-
| Pending
|
1216
|
-
| Yes
|
1217
|
-
| Yes
|
1218
|
-
| 0.18
|
1219
|
-
| -
|
1220
|
-
|===
|
1221
|
-
|
1222
|
-
Enforces the test to use `refute_predicate`
|
1223
|
-
instead of using `refute(obj.a_predicate_method?)`.
|
1224
|
-
|
1225
|
-
=== Examples
|
1226
|
-
|
1227
|
-
[source,ruby]
|
1228
|
-
----
|
1229
|
-
# bad
|
1230
|
-
refute(obj.one?)
|
1231
|
-
refute(obj.one?, 'message')
|
1232
|
-
|
1233
|
-
# good
|
1234
|
-
refute_predicate(obj, :one?)
|
1235
|
-
refute_predicate(obj, :one?, 'message')
|
1236
|
-
----
|
1237
|
-
|
1238
|
-
=== References
|
1239
|
-
|
1240
|
-
* https://minitest.rubystyle.guide/#refute-predicate
|
1241
|
-
|
1242
|
-
== Minitest/RefuteRespondTo
|
1243
|
-
|
1244
|
-
|===
|
1245
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1246
|
-
|
1247
|
-
| Enabled
|
1248
|
-
| Yes
|
1249
|
-
| Yes
|
1250
|
-
| 0.4
|
1251
|
-
| -
|
1252
|
-
|===
|
1253
|
-
|
1254
|
-
Enforces the test to use `refute_respond_to(object, :do_something)`
|
1255
|
-
over `refute(object.respond_to?(:do_something))`.
|
1256
|
-
|
1257
|
-
=== Examples
|
1258
|
-
|
1259
|
-
[source,ruby]
|
1260
|
-
----
|
1261
|
-
# bad
|
1262
|
-
refute(object.respond_to?(:do_something))
|
1263
|
-
refute(object.respond_to?(:do_something), 'message')
|
1264
|
-
refute(respond_to?(:do_something))
|
1265
|
-
|
1266
|
-
# good
|
1267
|
-
refute_respond_to(object, :do_something)
|
1268
|
-
refute_respond_to(object, :do_something, 'message')
|
1269
|
-
refute_respond_to(self, :do_something)
|
1270
|
-
----
|
1271
|
-
|
1272
|
-
=== References
|
1273
|
-
|
1274
|
-
* https://minitest.rubystyle.guide#refute-respond-to
|
1275
|
-
|
1276
|
-
== Minitest/SkipEnsure
|
1277
|
-
|
1278
|
-
|===
|
1279
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1280
|
-
|
1281
|
-
| Pending
|
1282
|
-
| Yes
|
1283
|
-
| No
|
1284
|
-
| 0.20
|
1285
|
-
| -
|
1286
|
-
|===
|
1287
|
-
|
1288
|
-
Checks that `ensure` call even if `skip`. It is unexpected that `ensure` will be called when skipping test.
|
1289
|
-
If conditional `skip` is used, it checks that `ensure` is also called conditionally.
|
1290
|
-
|
1291
|
-
On the other hand, it accepts `skip` used in `rescue` because `ensure` may be teardown process to `begin`
|
1292
|
-
setup process.
|
1293
|
-
|
1294
|
-
=== Examples
|
1295
|
-
|
1296
|
-
[source,ruby]
|
1297
|
-
----
|
1298
|
-
# bad
|
1299
|
-
def test_skip
|
1300
|
-
skip 'This test is skipped.'
|
1301
|
-
|
1302
|
-
assert 'foo'.present?
|
1303
|
-
ensure
|
1304
|
-
do_something
|
1305
|
-
end
|
1306
|
-
|
1307
|
-
# bad
|
1308
|
-
def test_conditional_skip
|
1309
|
-
skip 'This test is skipped.' if condition
|
1310
|
-
|
1311
|
-
assert do_something
|
1312
|
-
ensure
|
1313
|
-
do_teardown
|
1314
|
-
end
|
1315
|
-
|
1316
|
-
# good
|
1317
|
-
def test_skip
|
1318
|
-
skip 'This test is skipped.'
|
1319
|
-
|
1320
|
-
begin
|
1321
|
-
assert 'foo'.present?
|
1322
|
-
ensure
|
1323
|
-
do_something
|
1324
|
-
end
|
1325
|
-
end
|
1326
|
-
|
1327
|
-
# good
|
1328
|
-
def test_conditional_skip
|
1329
|
-
skip 'This test is skipped.' if condition
|
1330
|
-
|
1331
|
-
assert do_something
|
1332
|
-
ensure
|
1333
|
-
if condition
|
1334
|
-
do_teardown
|
1335
|
-
end
|
1336
|
-
end
|
1337
|
-
|
1338
|
-
# good
|
1339
|
-
def test_skip_is_used_in_rescue
|
1340
|
-
do_setup
|
1341
|
-
assert do_something
|
1342
|
-
rescue
|
1343
|
-
skip 'This test is skipped.'
|
1344
|
-
ensure
|
1345
|
-
do_teardown
|
1346
|
-
end
|
1347
|
-
----
|
1348
|
-
|
1349
|
-
== Minitest/TestMethodName
|
1350
|
-
|
1351
|
-
|===
|
1352
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1353
|
-
|
1354
|
-
| Pending
|
1355
|
-
| Yes
|
1356
|
-
| Yes
|
1357
|
-
| 0.10
|
1358
|
-
| -
|
1359
|
-
|===
|
1360
|
-
|
1361
|
-
Enforces that test method names start with `test_` prefix.
|
1362
|
-
It aims to prevent tests that aren't executed by forgetting to start test method name with `test_`.
|
1363
|
-
|
1364
|
-
=== Examples
|
1365
|
-
|
1366
|
-
[source,ruby]
|
1367
|
-
----
|
1368
|
-
# bad
|
1369
|
-
class FooTest < Minitest::Test
|
1370
|
-
def does_something
|
1371
|
-
assert_equal 42, do_something
|
1372
|
-
end
|
1373
|
-
end
|
1374
|
-
|
1375
|
-
# good
|
1376
|
-
class FooTest < Minitest::Test
|
1377
|
-
def test_does_something
|
1378
|
-
assert_equal 42, do_something
|
1379
|
-
end
|
1380
|
-
end
|
1381
|
-
|
1382
|
-
# good
|
1383
|
-
class FooTest < Minitest::Test
|
1384
|
-
def helper_method(argument)
|
1385
|
-
end
|
1386
|
-
end
|
1387
|
-
----
|
1388
|
-
|
1389
|
-
== Minitest/UnreachableAssertion
|
1390
|
-
|
1391
|
-
|===
|
1392
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1393
|
-
|
1394
|
-
| Pending
|
1395
|
-
| Yes
|
1396
|
-
| No
|
1397
|
-
| 0.14
|
1398
|
-
| -
|
1399
|
-
|===
|
1400
|
-
|
1401
|
-
Checks for `assert_raises` has an assertion method at
|
1402
|
-
the bottom of block because the assertion will be never reached.
|
1403
|
-
|
1404
|
-
=== Examples
|
1405
|
-
|
1406
|
-
[source,ruby]
|
1407
|
-
----
|
1408
|
-
# bad
|
1409
|
-
assert_raises FooError do
|
1410
|
-
obj.occur_error
|
1411
|
-
assert_equal('foo', obj.bar) # Never asserted.
|
1412
|
-
end
|
1413
|
-
|
1414
|
-
# good
|
1415
|
-
assert_raises FooError do
|
1416
|
-
obj.occur_error
|
1417
|
-
end
|
1418
|
-
assert_equal('foo', obj.bar)
|
1419
|
-
----
|
1420
|
-
|
1421
|
-
== Minitest/UnspecifiedException
|
1422
|
-
|
1423
|
-
|===
|
1424
|
-
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1425
|
-
|
1426
|
-
| Pending
|
1427
|
-
| Yes
|
1428
|
-
| No
|
1429
|
-
| 0.10
|
1430
|
-
| -
|
1431
|
-
|===
|
1432
|
-
|
1433
|
-
Checks for a specified error in `assert_raises`.
|
1434
|
-
|
1435
|
-
=== Examples
|
1436
|
-
|
1437
|
-
[source,ruby]
|
1438
|
-
----
|
1439
|
-
# bad
|
1440
|
-
assert_raises { raise FooException }
|
1441
|
-
assert_raises('This should have raised') { raise FooException }
|
1442
|
-
|
1443
|
-
# good
|
1444
|
-
assert_raises(FooException) { raise FooException }
|
1445
|
-
assert_raises(FooException, 'This should have raised') { raise FooException }
|
1446
|
-
----
|
1447
|
-
|
1448
|
-
=== References
|
1449
|
-
|
1450
|
-
* https://minitest.rubystyle.guide#unspecified-exception
|