rubocop-minitest 0.17.2 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linting.yml +15 -0
- data/.github/workflows/spell_checking.yml +2 -2
- data/.rubocop.yml +7 -7
- data/.yamllint.yml +9 -0
- data/CHANGELOG.md +24 -0
- data/config/default.yml +34 -17
- data/docs/antora.yml +2 -2
- data/docs/modules/ROOT/pages/cops.adoc +3 -0
- data/docs/modules/ROOT/pages/cops_minitest.adoc +127 -2
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +1 -2
- data/lib/rubocop/cop/minitest/assert_nil.rb +5 -2
- data/lib/rubocop/cop/minitest/assert_path_exists.rb +2 -2
- data/lib/rubocop/cop/minitest/assert_predicate.rb +34 -0
- data/lib/rubocop/cop/minitest/assert_silent.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_truthy.rb +1 -2
- data/lib/rubocop/cop/minitest/duplicate_test_run.rb +84 -0
- data/lib/rubocop/cop/minitest/refute_equal.rb +9 -11
- data/lib/rubocop/cop/minitest/refute_false.rb +2 -2
- data/lib/rubocop/cop/minitest/refute_nil.rb +5 -2
- data/lib/rubocop/cop/minitest/refute_path_exists.rb +2 -2
- data/lib/rubocop/cop/minitest/refute_predicate.rb +34 -0
- data/lib/rubocop/cop/minitest_cops.rb +4 -0
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +2 -2
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +2 -6
- data/lib/rubocop/cop/mixin/nil_assertion_handleable.rb +5 -10
- data/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb +61 -0
- data/lib/rubocop/minitest/assert_offense.rb +3 -3
- data/lib/rubocop/minitest/version.rb +1 -1
- data/mkdocs.yml +6 -6
- data/relnotes/v0.18.0.md +9 -0
- data/relnotes/v0.19.0.md +5 -0
- data/relnotes/v0.19.1.md +5 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75689600fc3dd6dc4fe96f80dc7c7e8a3b26e59978a15334f58c12421279873f
|
4
|
+
data.tar.gz: afad72a5c22682e4c79fffae91c7f49d25f08d925ed001bec887f8624ad1a391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c3c53d4f3e5915a39babb33862bc7ee9a1aef01e76fa680581723631c6a101a04af01f15fa33047c01f2dd57b99d44ac3da99f66bf5f06b8923e07f5c03f986
|
7
|
+
data.tar.gz: 649292ccae1c3a021f9c72399b03f3b38bf223c78e492e7ec93a5c030a73c920c3e1b7cae305d21b3942a68fe57d5451105e184fd20166f9820878bf077decc1
|
@@ -0,0 +1,15 @@
|
|
1
|
+
name: Linting
|
2
|
+
on:
|
3
|
+
- pull_request
|
4
|
+
jobs:
|
5
|
+
yamllint:
|
6
|
+
name: Yamllint
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v3
|
10
|
+
- name: Yamllint
|
11
|
+
uses: karancode/yamllint-github-action@master
|
12
|
+
with:
|
13
|
+
yamllint_comment: true
|
14
|
+
env:
|
15
|
+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
matrix:
|
11
11
|
python-version: [3.8]
|
12
12
|
steps:
|
13
|
-
- uses: actions/checkout@
|
13
|
+
- uses: actions/checkout@v3
|
14
14
|
- name: Set up Python ${{ matrix.python-version }}
|
15
15
|
uses: actions/setup-python@v2
|
16
16
|
with:
|
@@ -26,7 +26,7 @@ jobs:
|
|
26
26
|
name: Check spelling of all files in commit with misspell
|
27
27
|
runs-on: ubuntu-latest
|
28
28
|
steps:
|
29
|
-
- uses: actions/checkout@
|
29
|
+
- uses: actions/checkout@v3
|
30
30
|
- name: Install
|
31
31
|
run: wget -O - -q https://git.io/misspell | sh -s -- -b .
|
32
32
|
- name: Misspell
|
data/.rubocop.yml
CHANGED
@@ -55,13 +55,13 @@ Layout/ClassStructure:
|
|
55
55
|
- prepend
|
56
56
|
- extend
|
57
57
|
ExpectedOrder:
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
- module_inclusion
|
59
|
+
- constants
|
60
|
+
- public_class_methods
|
61
|
+
- initializer
|
62
|
+
- instance_methods
|
63
|
+
- protected_methods
|
64
|
+
- private_methods
|
65
65
|
|
66
66
|
# Trailing white space is meaningful in code examples
|
67
67
|
Layout/TrailingWhitespace:
|
data/.yamllint.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,28 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.19.1 (2022-04-10)
|
6
|
+
|
7
|
+
### Bug fixes
|
8
|
+
|
9
|
+
* [#167](https://github.com/rubocop/rubocop-minitest/pull/167): Fix potential for valid Ruby code to be unparsable in `Minitest/DuplicateTestRun` cop. ([@gjtorikian][])
|
10
|
+
|
11
|
+
## 0.19.0 (2022-04-05)
|
12
|
+
|
13
|
+
### New features
|
14
|
+
|
15
|
+
* [#164](https://github.com/rubocop/rubocop-minitest/pull/164): Add new `Minitest/DuplicateTestRun` cop. ([@ignacio-chiazzo][])
|
16
|
+
|
17
|
+
## 0.18.0 (2022-03-13)
|
18
|
+
|
19
|
+
### New features
|
20
|
+
|
21
|
+
* [#161](https://github.com/rubocop/rubocop-minitest/pull/161): Add new `Minitest/AssertPredicate` and `Minitest/RefutePredicate` cops. ([@koic][])
|
22
|
+
|
23
|
+
### Changes
|
24
|
+
|
25
|
+
* [#162](https://github.com/rubocop/rubocop-minitest/pull/162): Make `Minitest/AssertNil` (`Minitest/RefuteNil`) aware of `assert_predicate(obj, :nil?)` (`refute_predicate(obj, :nil?)`). ([@koic][])
|
26
|
+
|
5
27
|
## 0.17.2 (2022-02-12)
|
6
28
|
|
7
29
|
### Bug fixes
|
@@ -276,3 +298,5 @@
|
|
276
298
|
[@cstyles]: https://github.com/cstyles
|
277
299
|
[@ghiculescu]: https://github.com/ghiculescu
|
278
300
|
[@gi]: https://github.com/gi
|
301
|
+
[@ignacio-chiazzo]: https://github.com/ignacio-chiazzo
|
302
|
+
[@gjtorikian]: https://github.com/gjtorikian
|
data/config/default.yml
CHANGED
@@ -28,17 +28,6 @@ Minitest/AssertInDelta:
|
|
28
28
|
Enabled: 'pending'
|
29
29
|
VersionAdded: '0.10'
|
30
30
|
|
31
|
-
Minitest/AssertionInLifecycleHook:
|
32
|
-
Description: 'This cop checks for usage of assertions in lifecycle hooks.'
|
33
|
-
Enabled: 'pending'
|
34
|
-
VersionAdded: '0.10'
|
35
|
-
|
36
|
-
Minitest/AssertMatch:
|
37
|
-
Description: 'This cop enforces the test to use `assert_match` instead of using `assert(matcher.match(object))`.'
|
38
|
-
StyleGuide: 'https://minitest.rubystyle.guide#assert-match'
|
39
|
-
Enabled: true
|
40
|
-
VersionAdded: '0.6'
|
41
|
-
|
42
31
|
Minitest/AssertIncludes:
|
43
32
|
Description: 'This cop enforces the test to use `assert_includes` instead of using `assert(collection.include?(object))`.'
|
44
33
|
StyleGuide: 'https://minitest.rubystyle.guide#assert-includes'
|
@@ -57,6 +46,12 @@ Minitest/AssertKindOf:
|
|
57
46
|
Enabled: 'pending'
|
58
47
|
VersionAdded: '0.10'
|
59
48
|
|
49
|
+
Minitest/AssertMatch:
|
50
|
+
Description: 'This cop enforces the test to use `assert_match` instead of using `assert(matcher.match(object))`.'
|
51
|
+
StyleGuide: 'https://minitest.rubystyle.guide#assert-match'
|
52
|
+
Enabled: true
|
53
|
+
VersionAdded: '0.6'
|
54
|
+
|
60
55
|
Minitest/AssertNil:
|
61
56
|
Description: 'This cop enforces the test to use `assert_nil` instead of using `assert_equal(nil, something)` or `assert(something.nil?)`.'
|
62
57
|
StyleGuide: 'https://minitest.rubystyle.guide#assert-nil'
|
@@ -75,6 +70,12 @@ Minitest/AssertPathExists:
|
|
75
70
|
Enabled: 'pending'
|
76
71
|
VersionAdded: '0.10'
|
77
72
|
|
73
|
+
Minitest/AssertPredicate:
|
74
|
+
Description: 'This cop enforces the test to use `assert_predicate` instead of using `assert(obj.a_predicate_method?)`.'
|
75
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#assert-predicate'
|
76
|
+
Enabled: pending
|
77
|
+
VersionAdded: '0.18'
|
78
|
+
|
78
79
|
Minitest/AssertRespondTo:
|
79
80
|
Description: 'This cop enforces the test to use `assert_respond_to(object, :do_something)` over `assert(object.respond_to?(:do_something))`.'
|
80
81
|
StyleGuide: 'https://minitest.rubystyle.guide#assert-responds-to-method'
|
@@ -99,6 +100,16 @@ Minitest/AssertWithExpectedArgument:
|
|
99
100
|
Safe: false
|
100
101
|
VersionAdded: '0.11'
|
101
102
|
|
103
|
+
Minitest/AssertionInLifecycleHook:
|
104
|
+
Description: 'This cop checks for usage of assertions in lifecycle hooks.'
|
105
|
+
Enabled: 'pending'
|
106
|
+
VersionAdded: '0.10'
|
107
|
+
|
108
|
+
Minitest/DuplicateTestRun:
|
109
|
+
Description: 'This cop detects duplicate test runs caused by one test class inheriting from another.'
|
110
|
+
Enabled: pending
|
111
|
+
VersionAdded: '0.19'
|
112
|
+
|
102
113
|
Minitest/GlobalExpectations:
|
103
114
|
Description: 'This cop checks for deprecated global expectations.'
|
104
115
|
StyleGuide: 'https://minitest.rubystyle.guide#global-expectations'
|
@@ -164,12 +175,6 @@ Minitest/RefuteIncludes:
|
|
164
175
|
Enabled: true
|
165
176
|
VersionAdded: '0.3'
|
166
177
|
|
167
|
-
Minitest/RefuteMatch:
|
168
|
-
Description: 'This cop enforces the test to use `refute_match` instead of using `refute(matcher.match(object))`.'
|
169
|
-
StyleGuide: 'https://minitest.rubystyle.guide#refute-match'
|
170
|
-
Enabled: true
|
171
|
-
VersionAdded: '0.6'
|
172
|
-
|
173
178
|
Minitest/RefuteInstanceOf:
|
174
179
|
Description: 'This cop enforces the test to use `refute_instance_of(Class, object)` over `refute(object.instance_of?(Class))`.'
|
175
180
|
StyleGuide: 'https://minitest.rubystyle.guide#refute-instance-of'
|
@@ -182,6 +187,12 @@ Minitest/RefuteKindOf:
|
|
182
187
|
Enabled: 'pending'
|
183
188
|
VersionAdded: '0.10'
|
184
189
|
|
190
|
+
Minitest/RefuteMatch:
|
191
|
+
Description: 'This cop enforces the test to use `refute_match` instead of using `refute(matcher.match(object))`.'
|
192
|
+
StyleGuide: 'https://minitest.rubystyle.guide#refute-match'
|
193
|
+
Enabled: true
|
194
|
+
VersionAdded: '0.6'
|
195
|
+
|
185
196
|
Minitest/RefuteNil:
|
186
197
|
Description: 'This cop enforces the test to use `refute_nil` instead of using `refute_equal(nil, something)` or `refute(something.nil?)`.'
|
187
198
|
StyleGuide: 'https://minitest.rubystyle.guide#refute-nil'
|
@@ -194,6 +205,12 @@ Minitest/RefutePathExists:
|
|
194
205
|
Enabled: 'pending'
|
195
206
|
VersionAdded: '0.10'
|
196
207
|
|
208
|
+
Minitest/RefutePredicate:
|
209
|
+
Description: 'This cop enforces the test to use `refute_predicate` instead of using `refute(obj.a_predicate_method?)`.'
|
210
|
+
StyleGuide: 'https://minitest.rubystyle.guide/#refute-predicate'
|
211
|
+
Enabled: pending
|
212
|
+
VersionAdded: '0.18'
|
213
|
+
|
197
214
|
Minitest/RefuteRespondTo:
|
198
215
|
Description: 'This cop enforces the test to use `refute_respond_to(object, :do_something)` over `refute(object.respond_to?(:do_something))`.'
|
199
216
|
StyleGuide: 'https://minitest.rubystyle.guide#refute-respond-to'
|
data/docs/antora.yml
CHANGED
@@ -24,11 +24,13 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
|
|
24
24
|
* xref:cops_minitest.adoc#minitestassertnil[Minitest/AssertNil]
|
25
25
|
* xref:cops_minitest.adoc#minitestassertoutput[Minitest/AssertOutput]
|
26
26
|
* xref:cops_minitest.adoc#minitestassertpathexists[Minitest/AssertPathExists]
|
27
|
+
* xref:cops_minitest.adoc#minitestassertpredicate[Minitest/AssertPredicate]
|
27
28
|
* xref:cops_minitest.adoc#minitestassertrespondto[Minitest/AssertRespondTo]
|
28
29
|
* xref:cops_minitest.adoc#minitestassertsilent[Minitest/AssertSilent]
|
29
30
|
* xref:cops_minitest.adoc#minitestasserttruthy[Minitest/AssertTruthy]
|
30
31
|
* xref:cops_minitest.adoc#minitestassertwithexpectedargument[Minitest/AssertWithExpectedArgument]
|
31
32
|
* xref:cops_minitest.adoc#minitestassertioninlifecyclehook[Minitest/AssertionInLifecycleHook]
|
33
|
+
* xref:cops_minitest.adoc#minitestduplicatetestrun[Minitest/DuplicateTestRun]
|
32
34
|
* xref:cops_minitest.adoc#minitestglobalexpectations[Minitest/GlobalExpectations]
|
33
35
|
* xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument]
|
34
36
|
* xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions]
|
@@ -43,6 +45,7 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
|
|
43
45
|
* xref:cops_minitest.adoc#minitestrefutematch[Minitest/RefuteMatch]
|
44
46
|
* xref:cops_minitest.adoc#minitestrefutenil[Minitest/RefuteNil]
|
45
47
|
* xref:cops_minitest.adoc#minitestrefutepathexists[Minitest/RefutePathExists]
|
48
|
+
* xref:cops_minitest.adoc#minitestrefutepredicate[Minitest/RefutePredicate]
|
46
49
|
* xref:cops_minitest.adoc#minitestrefuterespondto[Minitest/RefuteRespondTo]
|
47
50
|
* xref:cops_minitest.adoc#minitesttestmethodname[Minitest/TestMethodName]
|
48
51
|
* xref:cops_minitest.adoc#minitestunreachableassertion[Minitest/UnreachableAssertion]
|
@@ -262,7 +262,7 @@ assert_match(matcher, string, 'message')
|
|
262
262
|
|===
|
263
263
|
|
264
264
|
This cop enforces the test to use `assert_nil` instead of using
|
265
|
-
`assert_equal(nil, something)` or `
|
265
|
+
`assert_equal(nil, something)`, `assert(something.nil?)`, or `assert_predicate(something, :nil?)`.
|
266
266
|
|
267
267
|
=== Examples
|
268
268
|
|
@@ -273,6 +273,8 @@ assert_equal(nil, actual)
|
|
273
273
|
assert_equal(nil, actual, 'message')
|
274
274
|
assert(object.nil?)
|
275
275
|
assert(object.nil?, 'message')
|
276
|
+
assert_predicate(object, :nil?)
|
277
|
+
assert_predicate(object, :nil?, 'message')
|
276
278
|
|
277
279
|
# good
|
278
280
|
assert_nil(actual)
|
@@ -347,6 +349,38 @@ assert_path_exists(path, 'message')
|
|
347
349
|
|
348
350
|
* https://minitest.rubystyle.guide/#assert-path-exists
|
349
351
|
|
352
|
+
== Minitest/AssertPredicate
|
353
|
+
|
354
|
+
|===
|
355
|
+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
356
|
+
|
357
|
+
| Pending
|
358
|
+
| Yes
|
359
|
+
| Yes
|
360
|
+
| 0.18
|
361
|
+
| -
|
362
|
+
|===
|
363
|
+
|
364
|
+
This cop enforces the test to use `assert_predicate`
|
365
|
+
instead of using `assert(obj.a_predicate_method?)`.
|
366
|
+
|
367
|
+
=== Examples
|
368
|
+
|
369
|
+
[source,ruby]
|
370
|
+
----
|
371
|
+
# bad
|
372
|
+
assert(obj.one?)
|
373
|
+
assert(obj.one?, 'message')
|
374
|
+
|
375
|
+
# good
|
376
|
+
assert_predicate(obj, :one?)
|
377
|
+
assert_predicate(obj, :one?, 'message')
|
378
|
+
----
|
379
|
+
|
380
|
+
=== References
|
381
|
+
|
382
|
+
* https://minitest.rubystyle.guide/#assert-predicate
|
383
|
+
|
350
384
|
== Minitest/AssertRespondTo
|
351
385
|
|
352
386
|
|===
|
@@ -510,6 +544,63 @@ class FooTest < Minitest::Test
|
|
510
544
|
end
|
511
545
|
----
|
512
546
|
|
547
|
+
== Minitest/DuplicateTestRun
|
548
|
+
|
549
|
+
|===
|
550
|
+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
551
|
+
|
552
|
+
| Pending
|
553
|
+
| Yes
|
554
|
+
| No
|
555
|
+
| 0.19
|
556
|
+
| -
|
557
|
+
|===
|
558
|
+
|
559
|
+
If a Minitest class inherits from another class,
|
560
|
+
it will also inherit its methods causing Minitest to run the parent's tests methods twice.
|
561
|
+
|
562
|
+
This cop detects when there are two tests classes, one inherits from the other, and both have tests methods.
|
563
|
+
This cop will add an offence to the Child class in such a case.
|
564
|
+
|
565
|
+
=== Examples
|
566
|
+
|
567
|
+
[source,ruby]
|
568
|
+
----
|
569
|
+
# bad
|
570
|
+
class ParentTest < Minitest::Test
|
571
|
+
def test_parent # it will run this test twice.
|
572
|
+
end
|
573
|
+
end
|
574
|
+
|
575
|
+
class ChildTest < ParentTest
|
576
|
+
def test_child
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
# good
|
581
|
+
class ParentTest < Minitest::Test
|
582
|
+
def test_parent
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
class ChildTest < Minitest::Test
|
587
|
+
def test_child
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
# good
|
592
|
+
class ParentTest < Minitest::Test
|
593
|
+
end
|
594
|
+
|
595
|
+
class ChildTest
|
596
|
+
def test_child
|
597
|
+
end
|
598
|
+
|
599
|
+
def test_parent
|
600
|
+
end
|
601
|
+
end
|
602
|
+
----
|
603
|
+
|
513
604
|
== Minitest/GlobalExpectations
|
514
605
|
|
515
606
|
|===
|
@@ -1025,7 +1116,7 @@ refute_match(matcher, string, 'message')
|
|
1025
1116
|
|===
|
1026
1117
|
|
1027
1118
|
This cop enforces the test to use `refute_nil` instead of using
|
1028
|
-
`refute_equal(nil, something)` or `
|
1119
|
+
`refute_equal(nil, something)`, `refute(something.nil?)`, or `refute_predicate(something, :nil?)`.
|
1029
1120
|
|
1030
1121
|
=== Examples
|
1031
1122
|
|
@@ -1036,6 +1127,8 @@ refute_equal(nil, actual)
|
|
1036
1127
|
refute_equal(nil, actual, 'message')
|
1037
1128
|
refute(actual.nil?)
|
1038
1129
|
refute(actual.nil?, 'message')
|
1130
|
+
refute_predicate(object, :nil?)
|
1131
|
+
refute_predicate(object, :nil?, 'message')
|
1039
1132
|
|
1040
1133
|
# good
|
1041
1134
|
refute_nil(actual)
|
@@ -1078,6 +1171,38 @@ refute_path_exists(path, 'message')
|
|
1078
1171
|
|
1079
1172
|
* https://minitest.rubystyle.guide/#refute-path-exists
|
1080
1173
|
|
1174
|
+
== Minitest/RefutePredicate
|
1175
|
+
|
1176
|
+
|===
|
1177
|
+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
|
1178
|
+
|
1179
|
+
| Pending
|
1180
|
+
| Yes
|
1181
|
+
| Yes
|
1182
|
+
| 0.18
|
1183
|
+
| -
|
1184
|
+
|===
|
1185
|
+
|
1186
|
+
This cop enforces the test to use `refute_predicate`
|
1187
|
+
instead of using `refute(obj.a_predicate_method?)`.
|
1188
|
+
|
1189
|
+
=== Examples
|
1190
|
+
|
1191
|
+
[source,ruby]
|
1192
|
+
----
|
1193
|
+
# bad
|
1194
|
+
refute(obj.one?)
|
1195
|
+
refute(obj.one?, 'message')
|
1196
|
+
|
1197
|
+
# good
|
1198
|
+
refute_predicate(obj, :one?)
|
1199
|
+
refute_predicate(obj, :one?, 'message')
|
1200
|
+
----
|
1201
|
+
|
1202
|
+
=== References
|
1203
|
+
|
1204
|
+
* https://minitest.rubystyle.guide/#refute-predicate
|
1205
|
+
|
1081
1206
|
== Minitest/RefuteRespondTo
|
1082
1207
|
|
1083
1208
|
|===
|
@@ -18,8 +18,7 @@ module RuboCop
|
|
18
18
|
include ArgumentRangeHelper
|
19
19
|
extend AutoCorrector
|
20
20
|
|
21
|
-
MSG = 'Prefer using `assert_empty(%<arguments>s)
|
22
|
-
'`assert_equal(%<literal>s, %<arguments>s)`.'
|
21
|
+
MSG = 'Prefer using `assert_empty(%<arguments>s)`.'
|
23
22
|
RESTRICT_ON_SEND = %i[assert_equal].freeze
|
24
23
|
|
25
24
|
def_node_matcher :assert_equal_with_empty_literal, <<~PATTERN
|
@@ -4,7 +4,7 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module Minitest
|
6
6
|
# This cop enforces the test to use `assert_nil` instead of using
|
7
|
-
# `assert_equal(nil, something)` or `
|
7
|
+
# `assert_equal(nil, something)`, `assert(something.nil?)`, or `assert_predicate(something, :nil?)`.
|
8
8
|
#
|
9
9
|
# @example
|
10
10
|
# # bad
|
@@ -12,6 +12,8 @@ module RuboCop
|
|
12
12
|
# assert_equal(nil, actual, 'message')
|
13
13
|
# assert(object.nil?)
|
14
14
|
# assert(object.nil?, 'message')
|
15
|
+
# assert_predicate(object, :nil?)
|
16
|
+
# assert_predicate(object, :nil?, 'message')
|
15
17
|
#
|
16
18
|
# # good
|
17
19
|
# assert_nil(actual)
|
@@ -23,12 +25,13 @@ module RuboCop
|
|
23
25
|
extend AutoCorrector
|
24
26
|
|
25
27
|
ASSERTION_TYPE = 'assert'
|
26
|
-
RESTRICT_ON_SEND = %i[assert_equal
|
28
|
+
RESTRICT_ON_SEND = %i[assert assert_equal assert_predicate].freeze
|
27
29
|
|
28
30
|
def_node_matcher :nil_assertion, <<~PATTERN
|
29
31
|
{
|
30
32
|
(send nil? :assert_equal nil $_ $...)
|
31
33
|
(send nil? :assert (send $_ :nil?) $...)
|
34
|
+
(send nil? :assert_predicate $_ (sym :nil?) $...)
|
32
35
|
}
|
33
36
|
PATTERN
|
34
37
|
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
class AssertPathExists < Base
|
19
19
|
extend AutoCorrector
|
20
20
|
|
21
|
-
MSG = 'Prefer using `%<good_method>s
|
21
|
+
MSG = 'Prefer using `%<good_method>s`.'
|
22
22
|
RESTRICT_ON_SEND = %i[assert].freeze
|
23
23
|
|
24
24
|
def_node_matcher :assert_file_exists, <<~PATTERN
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
32
32
|
assert_file_exists(node) do |path, failure_message|
|
33
33
|
failure_message = failure_message.first
|
34
34
|
good_method = build_good_method(path, failure_message)
|
35
|
-
message = format(MSG, good_method: good_method
|
35
|
+
message = format(MSG, good_method: good_method)
|
36
36
|
|
37
37
|
add_offense(node, message: message) do |corrector|
|
38
38
|
corrector.replace(node, good_method)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Minitest
|
6
|
+
# This cop enforces the test to use `assert_predicate`
|
7
|
+
# instead of using `assert(obj.a_predicate_method?)`.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# assert(obj.one?)
|
12
|
+
# assert(obj.one?, 'message')
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# assert_predicate(obj, :one?)
|
16
|
+
# assert_predicate(obj, :one?, 'message')
|
17
|
+
#
|
18
|
+
class AssertPredicate < Base
|
19
|
+
include ArgumentRangeHelper
|
20
|
+
include PredicateAssertionHandleable
|
21
|
+
extend AutoCorrector
|
22
|
+
|
23
|
+
MSG = 'Prefer using `assert_predicate(%<new_arguments>s)`.'
|
24
|
+
RESTRICT_ON_SEND = %i[assert].freeze
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def assertion_type
|
29
|
+
'assert'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -19,8 +19,7 @@ module RuboCop
|
|
19
19
|
include ArgumentRangeHelper
|
20
20
|
extend AutoCorrector
|
21
21
|
|
22
|
-
MSG = 'Prefer using `assert(%<arguments>s)
|
23
|
-
'`assert_equal(true, %<arguments>s)`.'
|
22
|
+
MSG = 'Prefer using `assert(%<arguments>s)`.'
|
24
23
|
RESTRICT_ON_SEND = %i[assert_equal].freeze
|
25
24
|
|
26
25
|
def_node_matcher :assert_equal_with_truthy, <<~PATTERN
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Minitest
|
6
|
+
# If a Minitest class inherits from another class,
|
7
|
+
# it will also inherit its methods causing Minitest to run the parent's tests methods twice.
|
8
|
+
#
|
9
|
+
# This cop detects when there are two tests classes, one inherits from the other, and both have tests methods.
|
10
|
+
# This cop will add an offence to the Child class in such a case.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# # bad
|
14
|
+
# class ParentTest < Minitest::Test
|
15
|
+
# def test_parent # it will run this test twice.
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# class ChildTest < ParentTest
|
20
|
+
# def test_child
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# # good
|
26
|
+
# class ParentTest < Minitest::Test
|
27
|
+
# def test_parent
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# class ChildTest < Minitest::Test
|
32
|
+
# def test_child
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# # good
|
37
|
+
# class ParentTest < Minitest::Test
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# class ChildTest
|
41
|
+
# def test_child
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# def test_parent
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
class DuplicateTestRun < Base
|
49
|
+
include MinitestExplorationHelpers
|
50
|
+
|
51
|
+
MSG = "Subclasses with test methods causes the parent' tests to run them twice."
|
52
|
+
|
53
|
+
def on_class(class_node)
|
54
|
+
return unless test_class?(class_node)
|
55
|
+
return unless test_methods?(class_node)
|
56
|
+
return unless parent_class_has_test_methods?(class_node)
|
57
|
+
|
58
|
+
message = format(MSG)
|
59
|
+
add_offense(class_node, message: message)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def parent_class_has_test_methods?(class_node)
|
65
|
+
parent_class = class_node.parent_class
|
66
|
+
|
67
|
+
return false unless (class_node_parent = class_node.parent)
|
68
|
+
|
69
|
+
parent_class_node = class_node_parent.each_child_node(:class).detect do |klass|
|
70
|
+
klass.identifier == parent_class
|
71
|
+
end
|
72
|
+
|
73
|
+
return false unless parent_class_node
|
74
|
+
|
75
|
+
test_methods?(parent_class_node)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_methods?(class_node)
|
79
|
+
test_cases(class_node).size.positive?
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -18,20 +18,19 @@ module RuboCop
|
|
18
18
|
include ArgumentRangeHelper
|
19
19
|
extend AutoCorrector
|
20
20
|
|
21
|
-
MSG = 'Prefer using `refute_equal(%<preferred>s)
|
22
|
-
'`assert(%<over>s)`.'
|
21
|
+
MSG = 'Prefer using `refute_equal(%<preferred>s)`.'
|
23
22
|
RESTRICT_ON_SEND = %i[assert].freeze
|
24
23
|
|
25
24
|
def_node_matcher :assert_not_equal, <<~PATTERN
|
26
|
-
(send nil? :assert
|
25
|
+
(send nil? :assert {(send $_ :!= $_) (send (send $_ :! ) :== $_) } $... )
|
27
26
|
PATTERN
|
28
27
|
|
29
28
|
def on_send(node)
|
30
|
-
preferred
|
31
|
-
return unless preferred
|
29
|
+
preferred = process_not_equal(node)
|
30
|
+
return unless preferred
|
32
31
|
|
33
|
-
assert_not_equal(node) do |
|
34
|
-
message = format(MSG, preferred: preferred
|
32
|
+
assert_not_equal(node) do |expected, actual|
|
33
|
+
message = format(MSG, preferred: preferred)
|
35
34
|
|
36
35
|
add_offense(node, message: message) do |corrector|
|
37
36
|
corrector.replace(node.loc.selector, 'refute_equal')
|
@@ -54,11 +53,10 @@ module RuboCop
|
|
54
53
|
end
|
55
54
|
|
56
55
|
def process_not_equal(node)
|
57
|
-
assert_not_equal(node) do |
|
56
|
+
assert_not_equal(node) do |first_arg, second_arg, rest_args|
|
58
57
|
custom_message = rest_args.first
|
59
|
-
|
60
|
-
|
61
|
-
return [preferred, over]
|
58
|
+
|
59
|
+
preferred_usage(first_arg, second_arg, custom_message)
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
@@ -22,8 +22,8 @@ module RuboCop
|
|
22
22
|
include ArgumentRangeHelper
|
23
23
|
extend AutoCorrector
|
24
24
|
|
25
|
-
MSG_FOR_ASSERT_EQUAL = 'Prefer using `refute(%<arguments>s)
|
26
|
-
MSG_FOR_ASSERT = 'Prefer using `refute(%<arguments>s)
|
25
|
+
MSG_FOR_ASSERT_EQUAL = 'Prefer using `refute(%<arguments>s)`.'
|
26
|
+
MSG_FOR_ASSERT = 'Prefer using `refute(%<arguments>s)`.'
|
27
27
|
RESTRICT_ON_SEND = %i[assert_equal assert].freeze
|
28
28
|
|
29
29
|
def_node_matcher :assert_equal_with_false, <<~PATTERN
|
@@ -4,7 +4,7 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module Minitest
|
6
6
|
# This cop enforces the test to use `refute_nil` instead of using
|
7
|
-
# `refute_equal(nil, something)` or `
|
7
|
+
# `refute_equal(nil, something)`, `refute(something.nil?)`, or `refute_predicate(something, :nil?)`.
|
8
8
|
#
|
9
9
|
# @example
|
10
10
|
# # bad
|
@@ -12,6 +12,8 @@ module RuboCop
|
|
12
12
|
# refute_equal(nil, actual, 'message')
|
13
13
|
# refute(actual.nil?)
|
14
14
|
# refute(actual.nil?, 'message')
|
15
|
+
# refute_predicate(object, :nil?)
|
16
|
+
# refute_predicate(object, :nil?, 'message')
|
15
17
|
#
|
16
18
|
# # good
|
17
19
|
# refute_nil(actual)
|
@@ -23,12 +25,13 @@ module RuboCop
|
|
23
25
|
extend AutoCorrector
|
24
26
|
|
25
27
|
ASSERTION_TYPE = 'refute'
|
26
|
-
RESTRICT_ON_SEND = %i[refute_equal
|
28
|
+
RESTRICT_ON_SEND = %i[refute refute_equal refute_predicate].freeze
|
27
29
|
|
28
30
|
def_node_matcher :nil_refutation, <<~PATTERN
|
29
31
|
{
|
30
32
|
(send nil? :refute_equal nil $_ $...)
|
31
33
|
(send nil? :refute (send $_ :nil?) $...)
|
34
|
+
(send nil? :refute_predicate $_ (sym :nil?) $...)
|
32
35
|
}
|
33
36
|
PATTERN
|
34
37
|
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
class RefutePathExists < Base
|
19
19
|
extend AutoCorrector
|
20
20
|
|
21
|
-
MSG = 'Prefer using `%<good_method>s
|
21
|
+
MSG = 'Prefer using `%<good_method>s`.'
|
22
22
|
RESTRICT_ON_SEND = %i[refute].freeze
|
23
23
|
|
24
24
|
def_node_matcher :refute_file_exists, <<~PATTERN
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
32
32
|
refute_file_exists(node) do |path, failure_message|
|
33
33
|
failure_message = failure_message.first
|
34
34
|
good_method = build_good_method(path, failure_message)
|
35
|
-
message = format(MSG, good_method: good_method
|
35
|
+
message = format(MSG, good_method: good_method)
|
36
36
|
|
37
37
|
add_offense(node, message: message) do |corrector|
|
38
38
|
corrector.replace(node, good_method)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Minitest
|
6
|
+
# This cop enforces the test to use `refute_predicate`
|
7
|
+
# instead of using `refute(obj.a_predicate_method?)`.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# refute(obj.one?)
|
12
|
+
# refute(obj.one?, 'message')
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# refute_predicate(obj, :one?)
|
16
|
+
# refute_predicate(obj, :one?, 'message')
|
17
|
+
#
|
18
|
+
class RefutePredicate < Base
|
19
|
+
include ArgumentRangeHelper
|
20
|
+
include PredicateAssertionHandleable
|
21
|
+
extend AutoCorrector
|
22
|
+
|
23
|
+
MSG = 'Prefer using `refute_predicate(%<new_arguments>s)`.'
|
24
|
+
RESTRICT_ON_SEND = %i[refute].freeze
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def assertion_type
|
29
|
+
'refute'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -5,10 +5,12 @@ require_relative 'mixin/in_delta_mixin'
|
|
5
5
|
require_relative 'mixin/minitest_cop_rule'
|
6
6
|
require_relative 'mixin/minitest_exploration_helpers'
|
7
7
|
require_relative 'mixin/nil_assertion_handleable'
|
8
|
+
require_relative 'mixin/predicate_assertion_handleable'
|
8
9
|
require_relative 'minitest/assert_empty'
|
9
10
|
require_relative 'minitest/assert_empty_literal'
|
10
11
|
require_relative 'minitest/assert_equal'
|
11
12
|
require_relative 'minitest/assert_in_delta'
|
13
|
+
require_relative 'minitest/assert_predicate'
|
12
14
|
require_relative 'minitest/assert_with_expected_argument'
|
13
15
|
require_relative 'minitest/assertion_in_lifecycle_hook'
|
14
16
|
require_relative 'minitest/assert_kind_of'
|
@@ -21,6 +23,7 @@ require_relative 'minitest/assert_path_exists'
|
|
21
23
|
require_relative 'minitest/assert_respond_to'
|
22
24
|
require_relative 'minitest/assert_silent'
|
23
25
|
require_relative 'minitest/assert_truthy'
|
26
|
+
require_relative 'minitest/duplicate_test_run'
|
24
27
|
require_relative 'minitest/global_expectations'
|
25
28
|
require_relative 'minitest/literal_as_actual_argument'
|
26
29
|
require_relative 'minitest/multiple_assertions'
|
@@ -35,6 +38,7 @@ require_relative 'minitest/refute_includes'
|
|
35
38
|
require_relative 'minitest/refute_match'
|
36
39
|
require_relative 'minitest/refute_instance_of'
|
37
40
|
require_relative 'minitest/refute_path_exists'
|
41
|
+
require_relative 'minitest/refute_predicate'
|
38
42
|
require_relative 'minitest/refute_respond_to'
|
39
43
|
require_relative 'minitest/test_method_name'
|
40
44
|
require_relative 'minitest/unreachable_assertion'
|
@@ -4,7 +4,7 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
# Common functionality for `AssertInDelta` and `RefuteInDelta` cops.
|
6
6
|
module InDeltaMixin
|
7
|
-
MSG = 'Prefer using `%<good_method>s
|
7
|
+
MSG = 'Prefer using `%<good_method>s`.'
|
8
8
|
|
9
9
|
def on_send(node)
|
10
10
|
equal_floats_call(node) do |expected, actual, message|
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
good_method = build_good_method(expected, actual, message)
|
13
13
|
|
14
14
|
if expected.float_type? || actual.float_type?
|
15
|
-
message = format(MSG, good_method: good_method
|
15
|
+
message = format(MSG, good_method: good_method)
|
16
16
|
|
17
17
|
add_offense(node, message: message) do |corrector|
|
18
18
|
corrector.replace(node, good_method)
|
@@ -28,8 +28,7 @@ module RuboCop
|
|
28
28
|
include ArgumentRangeHelper
|
29
29
|
extend AutoCorrector
|
30
30
|
|
31
|
-
MSG = 'Prefer using `#{preferred_method}(%<new_arguments>s)
|
32
|
-
'`#{assertion_method}(%<original_arguments>s)`.'
|
31
|
+
MSG = 'Prefer using `#{preferred_method}(%<new_arguments>s)`.'
|
33
32
|
RESTRICT_ON_SEND = %i[#{assertion_method}].freeze
|
34
33
|
|
35
34
|
def on_send(node)
|
@@ -70,12 +69,9 @@ module RuboCop
|
|
70
69
|
message_argument&.source
|
71
70
|
].flatten.compact.join(', ')
|
72
71
|
|
73
|
-
original_arguments = arguments.map(&:source).join(', ')
|
74
|
-
|
75
72
|
format(
|
76
73
|
MSG,
|
77
|
-
new_arguments: new_arguments
|
78
|
-
original_arguments: original_arguments
|
74
|
+
new_arguments: new_arguments
|
79
75
|
)
|
80
76
|
end
|
81
77
|
|
@@ -5,7 +5,7 @@ module RuboCop
|
|
5
5
|
module Minitest
|
6
6
|
# Common functionality for `AssertNil` and `RefuteNil` cops.
|
7
7
|
module NilAssertionHandleable
|
8
|
-
MSG = 'Prefer using `%<assertion_type>s_nil(%<preferred_args>s)
|
8
|
+
MSG = 'Prefer using `%<assertion_type>s_nil(%<preferred_args>s)`.'
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -22,23 +22,18 @@ module RuboCop
|
|
22
22
|
message_source = message&.source
|
23
23
|
|
24
24
|
preferred_args = [actual.source, message_source].compact
|
25
|
-
current_args = if comparison_assertion_method?(node)
|
26
|
-
['nil', preferred_args].join(', ')
|
27
|
-
else
|
28
|
-
["#{actual.source}.nil?", message_source].compact.join(', ')
|
29
|
-
end
|
30
25
|
|
31
26
|
format(
|
32
27
|
MSG,
|
33
28
|
assertion_type: assertion_type,
|
34
29
|
preferred_args: preferred_args.join(', '),
|
35
|
-
method: node.method_name
|
30
|
+
method: node.method_name
|
36
31
|
)
|
37
32
|
end
|
38
33
|
|
39
34
|
def autocorrect(corrector, node, actual)
|
40
35
|
corrector.replace(node.loc.selector, :"#{assertion_type}_nil")
|
41
|
-
if
|
36
|
+
if comparison_or_predicate_assertion_method?(node)
|
42
37
|
corrector.replace(first_and_second_arguments_range(node), actual.source)
|
43
38
|
else
|
44
39
|
corrector.remove(node.first_argument.loc.dot)
|
@@ -46,8 +41,8 @@ module RuboCop
|
|
46
41
|
end
|
47
42
|
end
|
48
43
|
|
49
|
-
def
|
50
|
-
node.method?(:"#{assertion_type}_equal")
|
44
|
+
def comparison_or_predicate_assertion_method?(node)
|
45
|
+
node.method?(:"#{assertion_type}_equal") || node.method?(:"#{assertion_type}_predicate")
|
51
46
|
end
|
52
47
|
end
|
53
48
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Minitest
|
6
|
+
# Common functionality for `Minitest/AssertPredicate` and `Minitest/RefutePredicate` cops.
|
7
|
+
module PredicateAssertionHandleable
|
8
|
+
MSG = 'Prefer using `%<assertion_type>s_predicate(%<new_arguments>s)`.'
|
9
|
+
RESTRICT_ON_SEND = %i[assert].freeze
|
10
|
+
|
11
|
+
def on_send(node)
|
12
|
+
return unless (arguments = peel_redundant_parentheses_from(node.arguments))
|
13
|
+
return unless arguments.first.respond_to?(:predicate_method?) && arguments.first.predicate_method?
|
14
|
+
return unless arguments.first.arguments.count.zero?
|
15
|
+
|
16
|
+
add_offense(node, message: offense_message(arguments)) do |corrector|
|
17
|
+
autocorrect(corrector, node, arguments)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def autocorrect(corrector, node, arguments)
|
22
|
+
corrector.replace(node.loc.selector, "#{assertion_type}_predicate")
|
23
|
+
|
24
|
+
new_arguments = new_arguments(arguments).join(', ')
|
25
|
+
|
26
|
+
corrector.replace(first_argument_range(node), new_arguments)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def peel_redundant_parentheses_from(arguments)
|
32
|
+
return arguments unless arguments.first&.begin_type?
|
33
|
+
|
34
|
+
peel_redundant_parentheses_from(arguments.first.children)
|
35
|
+
end
|
36
|
+
|
37
|
+
def offense_message(arguments)
|
38
|
+
message_argument = arguments.last if arguments.first != arguments.last
|
39
|
+
|
40
|
+
new_arguments = [
|
41
|
+
new_arguments(arguments),
|
42
|
+
message_argument&.source
|
43
|
+
].flatten.compact.join(', ')
|
44
|
+
|
45
|
+
format(MSG, assertion_type: assertion_type, new_arguments: new_arguments)
|
46
|
+
end
|
47
|
+
|
48
|
+
def new_arguments(arguments)
|
49
|
+
receiver = correct_receiver(arguments.first.receiver)
|
50
|
+
method_name = arguments.first.method_name
|
51
|
+
|
52
|
+
[receiver, ":#{method_name}"]
|
53
|
+
end
|
54
|
+
|
55
|
+
def correct_receiver(receiver)
|
56
|
+
receiver ? receiver.source : 'self'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
22
22
|
# class FooTest < Minitest::Test
|
23
23
|
# def test_do_something
|
24
24
|
# assert_equal(nil, somestuff)
|
25
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)
|
25
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)`.
|
26
26
|
# end
|
27
27
|
# end
|
28
28
|
# RUBY
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
36
36
|
# class FooTest < Minitest::Test
|
37
37
|
# def test_do_something
|
38
38
|
# assert_equal(nil, somestuff)
|
39
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)
|
39
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)`.
|
40
40
|
# end
|
41
41
|
# end
|
42
42
|
# RUBY
|
@@ -64,7 +64,7 @@ module RuboCop
|
|
64
64
|
# class FooTest < Minitest::Test
|
65
65
|
# def test_do_something
|
66
66
|
# assert_equal(nil, somestuff)
|
67
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)
|
67
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_nil(somestuff)`.
|
68
68
|
# end
|
69
69
|
# end
|
70
70
|
# RUBY
|
data/mkdocs.yml
CHANGED
@@ -4,10 +4,10 @@ edit_uri: edit/master/legacy-docs/
|
|
4
4
|
copyright: "Copyright © 2022 Bozhidar Batsov, Jonas Arvidsson, Koichi ITO, and RuboCop contributors"
|
5
5
|
docs_dir: legacy-docs
|
6
6
|
pages:
|
7
|
-
- Home: index.md
|
8
|
-
- Installation: installation.md
|
9
|
-
- Usage: usage.md
|
10
|
-
- Cops: cops.md
|
11
|
-
- Cops Documentation:
|
12
|
-
|
7
|
+
- Home: index.md
|
8
|
+
- Installation: installation.md
|
9
|
+
- Usage: usage.md
|
10
|
+
- Cops: cops.md
|
11
|
+
- Cops Documentation:
|
12
|
+
- Minitest Cops: cops_minitest.md
|
13
13
|
theme: readthedocs
|
data/relnotes/v0.18.0.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
### New features
|
2
|
+
|
3
|
+
* [#161](https://github.com/rubocop/rubocop-minitest/pull/161): Add new `Minitest/AssertPredicate` and `Minitest/RefutePredicate` cops. ([@koic][])
|
4
|
+
|
5
|
+
### Changes
|
6
|
+
|
7
|
+
* [#162](https://github.com/rubocop/rubocop-minitest/pull/162): Make `Minitest/AssertNil` (`Minitest/RefuteNil`) aware of `assert_predicate(obj, :nil?)` (`refute_predicate(obj, :nil?)`). ([@koic][])
|
8
|
+
|
9
|
+
[@koic]: https://github.com/koic
|
data/relnotes/v0.19.0.md
ADDED
data/relnotes/v0.19.1.md
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-04-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -60,10 +60,12 @@ files:
|
|
60
60
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
61
61
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
62
62
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
63
|
+
- ".github/workflows/linting.yml"
|
63
64
|
- ".github/workflows/spell_checking.yml"
|
64
65
|
- ".gitignore"
|
65
66
|
- ".rubocop.yml"
|
66
67
|
- ".rubocop_todo.yml"
|
68
|
+
- ".yamllint.yml"
|
67
69
|
- ".yardopts"
|
68
70
|
- CHANGELOG.md
|
69
71
|
- CONTRIBUTING.md
|
@@ -100,11 +102,13 @@ files:
|
|
100
102
|
- lib/rubocop/cop/minitest/assert_nil.rb
|
101
103
|
- lib/rubocop/cop/minitest/assert_output.rb
|
102
104
|
- lib/rubocop/cop/minitest/assert_path_exists.rb
|
105
|
+
- lib/rubocop/cop/minitest/assert_predicate.rb
|
103
106
|
- lib/rubocop/cop/minitest/assert_respond_to.rb
|
104
107
|
- lib/rubocop/cop/minitest/assert_silent.rb
|
105
108
|
- lib/rubocop/cop/minitest/assert_truthy.rb
|
106
109
|
- lib/rubocop/cop/minitest/assert_with_expected_argument.rb
|
107
110
|
- lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb
|
111
|
+
- lib/rubocop/cop/minitest/duplicate_test_run.rb
|
108
112
|
- lib/rubocop/cop/minitest/global_expectations.rb
|
109
113
|
- lib/rubocop/cop/minitest/literal_as_actual_argument.rb
|
110
114
|
- lib/rubocop/cop/minitest/multiple_assertions.rb
|
@@ -119,6 +123,7 @@ files:
|
|
119
123
|
- lib/rubocop/cop/minitest/refute_match.rb
|
120
124
|
- lib/rubocop/cop/minitest/refute_nil.rb
|
121
125
|
- lib/rubocop/cop/minitest/refute_path_exists.rb
|
126
|
+
- lib/rubocop/cop/minitest/refute_predicate.rb
|
122
127
|
- lib/rubocop/cop/minitest/refute_respond_to.rb
|
123
128
|
- lib/rubocop/cop/minitest/test_method_name.rb
|
124
129
|
- lib/rubocop/cop/minitest/unreachable_assertion.rb
|
@@ -129,6 +134,7 @@ files:
|
|
129
134
|
- lib/rubocop/cop/mixin/minitest_cop_rule.rb
|
130
135
|
- lib/rubocop/cop/mixin/minitest_exploration_helpers.rb
|
131
136
|
- lib/rubocop/cop/mixin/nil_assertion_handleable.rb
|
137
|
+
- lib/rubocop/cop/mixin/predicate_assertion_handleable.rb
|
132
138
|
- lib/rubocop/minitest.rb
|
133
139
|
- lib/rubocop/minitest/assert_offense.rb
|
134
140
|
- lib/rubocop/minitest/inject.rb
|
@@ -154,6 +160,9 @@ files:
|
|
154
160
|
- relnotes/v0.17.0.md
|
155
161
|
- relnotes/v0.17.1.md
|
156
162
|
- relnotes/v0.17.2.md
|
163
|
+
- relnotes/v0.18.0.md
|
164
|
+
- relnotes/v0.19.0.md
|
165
|
+
- relnotes/v0.19.1.md
|
157
166
|
- relnotes/v0.2.0.md
|
158
167
|
- relnotes/v0.2.1.md
|
159
168
|
- relnotes/v0.3.0.md
|
@@ -180,7 +189,7 @@ metadata:
|
|
180
189
|
homepage_uri: https://docs.rubocop.org/rubocop-minitest/
|
181
190
|
changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
|
182
191
|
source_code_uri: https://github.com/rubocop/rubocop-minitest
|
183
|
-
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.
|
192
|
+
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.19
|
184
193
|
bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
|
185
194
|
rubygems_mfa_required: 'true'
|
186
195
|
post_install_message:
|