rubocop-minitest 0.19.1 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +0 -3
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
  4. data/.github/workflows/spell_checking.yml +1 -1
  5. data/.rubocop.yml +6 -1
  6. data/CHANGELOG.md +17 -3
  7. data/CONTRIBUTING.md +1 -1
  8. data/Gemfile +1 -1
  9. data/config/default.yml +6 -0
  10. data/docs/antora.yml +1 -1
  11. data/docs/modules/ROOT/pages/cops.adoc +1 -0
  12. data/docs/modules/ROOT/pages/cops_minitest.adoc +114 -43
  13. data/lib/rubocop/cop/minitest/assert_empty.rb +1 -2
  14. data/lib/rubocop/cop/minitest/assert_empty_literal.rb +1 -1
  15. data/lib/rubocop/cop/minitest/assert_equal.rb +1 -1
  16. data/lib/rubocop/cop/minitest/assert_in_delta.rb +1 -1
  17. data/lib/rubocop/cop/minitest/assert_includes.rb +1 -1
  18. data/lib/rubocop/cop/minitest/assert_instance_of.rb +1 -1
  19. data/lib/rubocop/cop/minitest/assert_kind_of.rb +1 -1
  20. data/lib/rubocop/cop/minitest/assert_match.rb +1 -1
  21. data/lib/rubocop/cop/minitest/assert_nil.rb +1 -1
  22. data/lib/rubocop/cop/minitest/assert_output.rb +1 -1
  23. data/lib/rubocop/cop/minitest/assert_path_exists.rb +1 -2
  24. data/lib/rubocop/cop/minitest/assert_predicate.rb +1 -1
  25. data/lib/rubocop/cop/minitest/assert_respond_to.rb +1 -1
  26. data/lib/rubocop/cop/minitest/assert_silent.rb +1 -1
  27. data/lib/rubocop/cop/minitest/assert_truthy.rb +1 -2
  28. data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +1 -1
  29. data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +1 -1
  30. data/lib/rubocop/cop/minitest/duplicate_test_run.rb +1 -1
  31. data/lib/rubocop/cop/minitest/global_expectations.rb +1 -1
  32. data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +1 -1
  33. data/lib/rubocop/cop/minitest/multiple_assertions.rb +1 -1
  34. data/lib/rubocop/cop/minitest/no_assertions.rb +1 -1
  35. data/lib/rubocop/cop/minitest/refute_empty.rb +1 -2
  36. data/lib/rubocop/cop/minitest/refute_equal.rb +1 -1
  37. data/lib/rubocop/cop/minitest/refute_false.rb +1 -2
  38. data/lib/rubocop/cop/minitest/refute_in_delta.rb +1 -1
  39. data/lib/rubocop/cop/minitest/refute_includes.rb +1 -1
  40. data/lib/rubocop/cop/minitest/refute_instance_of.rb +1 -1
  41. data/lib/rubocop/cop/minitest/refute_kind_of.rb +1 -1
  42. data/lib/rubocop/cop/minitest/refute_match.rb +1 -1
  43. data/lib/rubocop/cop/minitest/refute_nil.rb +1 -1
  44. data/lib/rubocop/cop/minitest/refute_path_exists.rb +1 -2
  45. data/lib/rubocop/cop/minitest/refute_predicate.rb +1 -1
  46. data/lib/rubocop/cop/minitest/refute_respond_to.rb +1 -1
  47. data/lib/rubocop/cop/minitest/skip_ensure.rb +95 -0
  48. data/lib/rubocop/cop/minitest/test_method_name.rb +1 -1
  49. data/lib/rubocop/cop/minitest/unreachable_assertion.rb +1 -1
  50. data/lib/rubocop/cop/minitest/unspecified_exception.rb +1 -1
  51. data/lib/rubocop/cop/minitest_cops.rb +1 -0
  52. data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +2 -2
  53. data/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb +6 -2
  54. data/lib/rubocop/minitest/assert_offense.rb +3 -3
  55. data/lib/rubocop/minitest/version.rb +1 -1
  56. data/relnotes/v0.12.0.md +1 -1
  57. data/relnotes/v0.15.2.md +1 -1
  58. data/relnotes/v0.20.0.md +13 -0
  59. data/relnotes/v0.9.0.md +1 -1
  60. data/rubocop-minitest.gemspec +1 -1
  61. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75689600fc3dd6dc4fe96f80dc7c7e8a3b26e59978a15334f58c12421279873f
4
- data.tar.gz: afad72a5c22682e4c79fffae91c7f49d25f08d925ed001bec887f8624ad1a391
3
+ metadata.gz: 6c35365ef5838d4a75f01181865e860ecb774a73288a310ffe2bfec21b6c6001
4
+ data.tar.gz: ccbdb0bb831bcebec0cde35263bf90063e400a25d97bccb9facf3edbc0bbd23a
5
5
  SHA512:
6
- metadata.gz: 7c3c53d4f3e5915a39babb33862bc7ee9a1aef01e76fa680581723631c6a101a04af01f15fa33047c01f2dd57b99d44ac3da99f66bf5f06b8923e07f5c03f986
7
- data.tar.gz: 649292ccae1c3a021f9c72399b03f3b38bf223c78e492e7ec93a5c030a73c920c3e1b7cae305d21b3942a68fe57d5451105e184fd20166f9820878bf077decc1
6
+ metadata.gz: 0a85bb1c4f0226eb025cdf18ae72757403ea71b422b19291e80bf696c95735cb2ddd3f61f921ad01c04c88ef731aa3e39d68141ac8971315e5933575cab6ec8c
7
+ data.tar.gz: b449004eb3a26c8996490d5e5008e784f10660edba75e99a7b3d5ef317d6c4585757aee59e7c95fb7100d892a2769c88bf26f42ac96684488945a5e9ee775155
data/.circleci/config.yml CHANGED
@@ -35,9 +35,6 @@ workflows:
35
35
  build:
36
36
  jobs:
37
37
  - documentation-checks
38
- - rake_default:
39
- name: Ruby 2.5
40
- image: cimg/ruby:2.5
41
38
  - rake_default:
42
39
  name: Ruby 2.6
43
40
  image: cimg/ruby:2.6
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: Feature Request
3
- about: Suggest new RuboCop Rails features or improvements to existing features.
3
+ about: Suggest new RuboCop Minitest features or improvements to existing features.
4
4
  ---
5
5
 
6
6
  ## Is your feature request related to a problem? Please describe.
@@ -28,6 +28,6 @@ jobs:
28
28
  steps:
29
29
  - uses: actions/checkout@v3
30
30
  - name: Install
31
- run: wget -O - -q https://git.io/misspell | sh -s -- -b .
31
+ run: wget -O - -q https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | sh -s -- -b .
32
32
  - name: Misspell
33
33
  run: git ls-files --empty-directory | xargs ./misspell -error
data/.rubocop.yml CHANGED
@@ -9,7 +9,7 @@ require:
9
9
 
10
10
  AllCops:
11
11
  NewCops: enable
12
- TargetRubyVersion: 2.5
12
+ TargetRubyVersion: 2.6
13
13
  SuggestExtensions: false
14
14
 
15
15
  InternalAffairs/NodeMatcherDirective:
@@ -28,7 +28,12 @@ Naming/PredicateName:
28
28
  - def_node_search
29
29
 
30
30
  Naming/InclusiveLanguage:
31
+ Enabled: true
32
+ CheckStrings: true
31
33
  FlaggedTerms:
34
+ behaviour:
35
+ Suggestions:
36
+ - behavior
32
37
  offence:
33
38
  Suggestions:
34
39
  - offense
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.20.0 (2022-05-29)
6
+
7
+ ### New features
8
+
9
+ * [#169](https://github.com/rubocop/rubocop-minitest/issues/169): Add new `Minitest/SkipEnsure` cop. ([@koic][])
10
+
11
+ ### Bug fixes
12
+
13
+ * [#172](https://github.com/rubocop/rubocop-minitest/issues/172): Fix a false positive for `Minitest/AssertPredicate` and `Minitest/RefutePredicate` when using numbered parameters. ([@koic][])
14
+
15
+ ### Changes
16
+
17
+ * [#168](https://github.com/rubocop/rubocop-minitest/pull/168): **(Compatibility)** Drop Ruby 2.5 support. ([@koic][])
18
+
5
19
  ## 0.19.1 (2022-04-10)
6
20
 
7
21
  ### Bug fixes
@@ -57,7 +71,7 @@
57
71
 
58
72
  ### Bug fixes
59
73
 
60
- * [#145](https://github.com/rubocop/rubocop-minitest/pull/145): Mark `Minitest/AssertEmptyLiteral` as safe auto-correction. ([@koic][])
74
+ * [#145](https://github.com/rubocop/rubocop-minitest/pull/145): Mark `Minitest/AssertEmptyLiteral` as safe autocorrection. ([@koic][])
61
75
 
62
76
  ## 0.15.1 (2021-09-26)
63
77
 
@@ -97,7 +111,7 @@
97
111
 
98
112
  ### Changes
99
113
 
100
- * [#129](https://github.com/rubocop/rubocop-minitest/pull/129): Drop Ruby 2.4 support. ([@koic][])
114
+ * [#129](https://github.com/rubocop/rubocop-minitest/pull/129): **(Compatibility)** Drop Ruby 2.4 support. ([@koic][])
101
115
 
102
116
  ## 0.11.1 (2021-03-31)
103
117
 
@@ -167,7 +181,7 @@
167
181
  ### Changes
168
182
 
169
183
  * [#73](https://github.com/rubocop/rubocop-minitest/issues/73): The Minitest department works on file names end with `_test.rb` by default. ([@koic][])
170
- * [#77](https://github.com/rubocop/rubocop-minitest/pull/77): **(BREAKING)** Drop support for Ruby 2.3. ([@koic][])
184
+ * [#77](https://github.com/rubocop/rubocop-minitest/pull/77): **(Compatibility)** Drop support for Ruby 2.3. ([@koic][])
171
185
 
172
186
  ## 0.8.1 (2020-04-06)
173
187
 
data/CONTRIBUTING.md CHANGED
@@ -49,7 +49,7 @@ $ rubocop -V
49
49
  Here are a few examples:
50
50
 
51
51
  ```
52
- * [#716](https://github.com/rubocop/rubocop-minitest/issues/716): Fixed a regression in the auto-correction logic of `MethodDefParentheses`. ([@bbatsov][])
52
+ * [#716](https://github.com/rubocop/rubocop-minitest/issues/716): Fixed a regression in the autocorrection logic of `MethodDefParentheses`. ([@bbatsov][])
53
53
  * New cop `ElseLayout` checks for odd arrangement of code in the `else` branch of a conditional expression. ([@bbatsov][])
54
54
  ```
55
55
 
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gemspec
9
9
  gem 'bump', require: false
10
10
  gem 'rake'
11
11
  gem 'rubocop', github: 'rubocop/rubocop'
12
- gem 'rubocop-performance', '~> 1.12.0'
12
+ gem 'rubocop-performance', '~> 1.13.0'
13
13
  gem 'yard', '~> 0.9'
14
14
 
15
15
  local_gemfile = File.expand_path('Gemfile.local', __dir__)
data/config/default.yml CHANGED
@@ -107,6 +107,7 @@ Minitest/AssertionInLifecycleHook:
107
107
 
108
108
  Minitest/DuplicateTestRun:
109
109
  Description: 'This cop detects duplicate test runs caused by one test class inheriting from another.'
110
+ StyleGuide: 'https://minitest.rubystyle.guide/#subclassing-test-cases'
110
111
  Enabled: pending
111
112
  VersionAdded: '0.19'
112
113
 
@@ -217,6 +218,11 @@ Minitest/RefuteRespondTo:
217
218
  Enabled: true
218
219
  VersionAdded: '0.4'
219
220
 
221
+ Minitest/SkipEnsure:
222
+ Description: 'Checks that `ensure` call even if `skip`.'
223
+ Enabled: pending
224
+ VersionAdded: '0.20'
225
+
220
226
  Minitest/TestMethodName:
221
227
  Description: 'This cop enforces that test method names start with `test_` prefix.'
222
228
  Enabled: 'pending'
data/docs/antora.yml CHANGED
@@ -2,6 +2,6 @@ name: rubocop-minitest
2
2
  title: RuboCop Minitest
3
3
  # We always provide version without patch here (e.g. 1.1),
4
4
  # as patch versions should not appear in the docs.
5
- version: '0.19'
5
+ version: '0.20'
6
6
  nav:
7
7
  - modules/ROOT/nav.adoc
@@ -47,6 +47,7 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
47
47
  * xref:cops_minitest.adoc#minitestrefutepathexists[Minitest/RefutePathExists]
48
48
  * xref:cops_minitest.adoc#minitestrefutepredicate[Minitest/RefutePredicate]
49
49
  * xref:cops_minitest.adoc#minitestrefuterespondto[Minitest/RefuteRespondTo]
50
+ * xref:cops_minitest.adoc#minitestskipensure[Minitest/SkipEnsure]
50
51
  * xref:cops_minitest.adoc#minitesttestmethodname[Minitest/TestMethodName]
51
52
  * xref:cops_minitest.adoc#minitestunreachableassertion[Minitest/UnreachableAssertion]
52
53
  * xref:cops_minitest.adoc#minitestunspecifiedexception[Minitest/UnspecifiedException]
@@ -12,8 +12,7 @@
12
12
  | -
13
13
  |===
14
14
 
15
- This cop enforces the test to use `assert_empty`
16
- instead of using `assert(object.empty?)`.
15
+ Enforces the test to use `assert_empty` instead of using `assert(object.empty?)`.
17
16
 
18
17
  === Examples
19
18
 
@@ -44,7 +43,7 @@ assert_empty(object, 'message')
44
43
  | 0.11
45
44
  |===
46
45
 
47
- This cop enforces the test to use `assert_empty`
46
+ Enforces the test to use `assert_empty`
48
47
  instead of using `assert_equal([], object)` or `assert_equal({}, object)`.
49
48
 
50
49
  === Examples
@@ -71,7 +70,7 @@ assert_empty(object)
71
70
  | -
72
71
  |===
73
72
 
74
- This cop enforces the use of `assert_equal(expected, actual)`
73
+ Enforces the use of `assert_equal(expected, actual)`
75
74
  over `assert(expected == actual)`.
76
75
 
77
76
  === Examples
@@ -101,7 +100,7 @@ assert_equal("rubocop-minitest", actual)
101
100
  | -
102
101
  |===
103
102
 
104
- This cop enforces the test to use `assert_in_delta`
103
+ Enforces the test to use `assert_in_delta`
105
104
  instead of using `assert_equal` to compare floats.
106
105
 
107
106
  === Examples
@@ -133,7 +132,7 @@ assert_in_delta(0.2, actual, 0.001, 'message')
133
132
  | -
134
133
  |===
135
134
 
136
- This cop enforces the test to use `assert_includes`
135
+ Enforces the test to use `assert_includes`
137
136
  instead of using `assert(collection.include?(object))`.
138
137
 
139
138
  === Examples
@@ -165,7 +164,7 @@ assert_includes(collection, object, 'message')
165
164
  | -
166
165
  |===
167
166
 
168
- This cop enforces the test to use `assert_instance_of(Class, object)`
167
+ Enforces the test to use `assert_instance_of(Class, object)`
169
168
  over `assert(object.instance_of?(Class))`.
170
169
 
171
170
  === Examples
@@ -197,7 +196,7 @@ assert_instance_of(Class, object, 'message')
197
196
  | -
198
197
  |===
199
198
 
200
- This cop enforces the test to use `assert_kind_of(Class, object)`
199
+ Enforces the test to use `assert_kind_of(Class, object)`
201
200
  over `assert(object.kind_of?(Class))`.
202
201
 
203
202
  === Examples
@@ -229,7 +228,7 @@ assert_kind_of(Class, object, 'message')
229
228
  | -
230
229
  |===
231
230
 
232
- This cop enforces the test to use `assert_match`
231
+ Enforces the test to use `assert_match`
233
232
  instead of using `assert(matcher.match(string))`.
234
233
 
235
234
  === Examples
@@ -261,7 +260,7 @@ assert_match(matcher, string, 'message')
261
260
  | -
262
261
  |===
263
262
 
264
- This cop enforces the test to use `assert_nil` instead of using
263
+ Enforces the test to use `assert_nil` instead of using
265
264
  `assert_equal(nil, something)`, `assert(something.nil?)`, or `assert_predicate(something, :nil?)`.
266
265
 
267
266
  === Examples
@@ -297,7 +296,7 @@ assert_nil(actual, 'message')
297
296
  | -
298
297
  |===
299
298
 
300
- This cop checks for opportunities to use `assert_output`.
299
+ Checks for opportunities to use `assert_output`.
301
300
 
302
301
  === Examples
303
302
 
@@ -329,8 +328,7 @@ assert_output(expected) { puts object.method }
329
328
  | -
330
329
  |===
331
330
 
332
- This cop enforces the test to use `assert_path_exists`
333
- instead of using `assert(File.exist?(path))`.
331
+ Enforces the test to use `assert_path_exists` instead of using `assert(File.exist?(path))`.
334
332
 
335
333
  === Examples
336
334
 
@@ -361,7 +359,7 @@ assert_path_exists(path, 'message')
361
359
  | -
362
360
  |===
363
361
 
364
- This cop enforces the test to use `assert_predicate`
362
+ Enforces the test to use `assert_predicate`
365
363
  instead of using `assert(obj.a_predicate_method?)`.
366
364
 
367
365
  === Examples
@@ -393,7 +391,7 @@ assert_predicate(obj, :one?, 'message')
393
391
  | -
394
392
  |===
395
393
 
396
- This cop enforces the use of `assert_respond_to(object, :do_something)`
394
+ Enforces the use of `assert_respond_to(object, :do_something)`
397
395
  over `assert(object.respond_to?(:do_something))`.
398
396
 
399
397
  === Examples
@@ -427,7 +425,7 @@ assert_respond_to(self, :do_something)
427
425
  | -
428
426
  |===
429
427
 
430
- This cop enforces the test to use `assert_silent { ... }`
428
+ Enforces the test to use `assert_silent { ... }`
431
429
  instead of using `assert_output('', '') { ... }`.
432
430
 
433
431
  === Examples
@@ -457,8 +455,7 @@ assert_silent { puts object.do_something }
457
455
  | -
458
456
  |===
459
457
 
460
- This cop enforces the test to use `assert(actual)`
461
- instead of using `assert_equal(true, actual)`.
458
+ Enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.
462
459
 
463
460
  === Examples
464
461
 
@@ -489,7 +486,7 @@ assert(actual, 'message')
489
486
  | -
490
487
  |===
491
488
 
492
- This cop tries to detect when a user accidentally used
489
+ Tries to detect when a user accidentally used
493
490
  `assert` when they meant to use `assert_equal`.
494
491
 
495
492
  === Safety
@@ -523,7 +520,7 @@ assert(foo, 'message')
523
520
  | -
524
521
  |===
525
522
 
526
- This cop checks for usage of assertions in lifecycle hooks.
523
+ Checks for usage of assertions in lifecycle hooks.
527
524
 
528
525
  === Examples
529
526
 
@@ -560,7 +557,7 @@ If a Minitest class inherits from another class,
560
557
  it will also inherit its methods causing Minitest to run the parent's tests methods twice.
561
558
 
562
559
  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.
560
+ This cop will add an offense to the Child class in such a case.
564
561
 
565
562
  === Examples
566
563
 
@@ -601,6 +598,10 @@ class ChildTest
601
598
  end
602
599
  ----
603
600
 
601
+ === References
602
+
603
+ * https://minitest.rubystyle.guide/#subclassing-test-cases
604
+
604
605
  == Minitest/GlobalExpectations
605
606
 
606
607
  |===
@@ -613,7 +614,7 @@ end
613
614
  | 0.16
614
615
  |===
615
616
 
616
- This cop checks for deprecated global expectations
617
+ Checks for deprecated global expectations
617
618
  and autocorrects them to use expect format.
618
619
 
619
620
  === Examples
@@ -740,7 +741,7 @@ value { musts }.must_raise TypeError
740
741
  | -
741
742
  |===
742
743
 
743
- This cop enforces correct order of expected and
744
+ Enforces correct order of expected and
744
745
  actual arguments for `assert_equal`.
745
746
 
746
747
  === Examples
@@ -774,7 +775,7 @@ assert_equal [1, 2], foo, 'message'
774
775
  | -
775
776
  |===
776
777
 
777
- This cop checks if test cases contain too many assertion calls.
778
+ Checks if test cases contain too many assertion calls.
778
779
  The maximum allowed assertion calls is configurable.
779
780
 
780
781
  === Examples
@@ -825,7 +826,7 @@ end
825
826
  | -
826
827
  |===
827
828
 
828
- This cop checks if test cases contain any assertion calls.
829
+ Checks if test cases contain any assertion calls.
829
830
 
830
831
  === Examples
831
832
 
@@ -857,8 +858,7 @@ end
857
858
  | -
858
859
  |===
859
860
 
860
- This cop enforces to use `refute_empty` instead of
861
- using `refute(object.empty?)`.
861
+ Enforces to use `refute_empty` instead of using `refute(object.empty?)`.
862
862
 
863
863
  === Examples
864
864
 
@@ -889,7 +889,7 @@ refute_empty(object, 'message')
889
889
  | -
890
890
  |===
891
891
 
892
- This cop enforces the use of `refute_equal(expected, object)`
892
+ Enforces the use of `refute_equal(expected, object)`
893
893
  over `assert(expected != actual)` or `assert(! expected == actual)`.
894
894
 
895
895
  === Examples
@@ -920,8 +920,7 @@ refute_equal("rubocop-minitest", actual)
920
920
  | -
921
921
  |===
922
922
 
923
- This cop enforces the use of `refute(object)`
924
- over `assert_equal(false, object)`.
923
+ Enforces the use of `refute(object)` over `assert_equal(false, object)`.
925
924
 
926
925
  === Examples
927
926
 
@@ -955,7 +954,7 @@ refute(actual, 'message')
955
954
  | -
956
955
  |===
957
956
 
958
- This cop enforces the test to use `refute_in_delta`
957
+ Enforces the test to use `refute_in_delta`
959
958
  instead of using `refute_equal` to compare floats.
960
959
 
961
960
  === Examples
@@ -987,7 +986,7 @@ refute_in_delta(0.2, actual, 0.001, 'message')
987
986
  | -
988
987
  |===
989
988
 
990
- This cop enforces the test to use `refute_includes`
989
+ Enforces the test to use `refute_includes`
991
990
  instead of using `refute(collection.include?(object))`.
992
991
 
993
992
  === Examples
@@ -1019,7 +1018,7 @@ refute_includes(collection, object, 'message')
1019
1018
  | -
1020
1019
  |===
1021
1020
 
1022
- This cop enforces the use of `refute_instance_of(Class, object)`
1021
+ Enforces the use of `refute_instance_of(Class, object)`
1023
1022
  over `refute(object.instance_of?(Class))`.
1024
1023
 
1025
1024
  === Examples
@@ -1051,7 +1050,7 @@ refute_instance_of(Class, object, 'message')
1051
1050
  | -
1052
1051
  |===
1053
1052
 
1054
- This cop enforces the use of `refute_kind_of(Class, object)`
1053
+ Enforces the use of `refute_kind_of(Class, object)`
1055
1054
  over `refute(object.kind_of?(Class))`.
1056
1055
 
1057
1056
  === Examples
@@ -1083,7 +1082,7 @@ refute_kind_of(Class, object, 'message')
1083
1082
  | -
1084
1083
  |===
1085
1084
 
1086
- This cop enforces the test to use `refute_match`
1085
+ Enforces the test to use `refute_match`
1087
1086
  instead of using `refute(matcher.match(string))`.
1088
1087
 
1089
1088
  === Examples
@@ -1115,7 +1114,7 @@ refute_match(matcher, string, 'message')
1115
1114
  | -
1116
1115
  |===
1117
1116
 
1118
- This cop enforces the test to use `refute_nil` instead of using
1117
+ Enforces the test to use `refute_nil` instead of using
1119
1118
  `refute_equal(nil, something)`, `refute(something.nil?)`, or `refute_predicate(something, :nil?)`.
1120
1119
 
1121
1120
  === Examples
@@ -1151,8 +1150,7 @@ refute_nil(actual, 'message')
1151
1150
  | -
1152
1151
  |===
1153
1152
 
1154
- This cop enforces the test to use `refute_path_exists`
1155
- instead of using `refute(File.exist?(path))`.
1153
+ Enforces the test to use `refute_path_exists` instead of using `refute(File.exist?(path))`.
1156
1154
 
1157
1155
  === Examples
1158
1156
 
@@ -1183,7 +1181,7 @@ refute_path_exists(path, 'message')
1183
1181
  | -
1184
1182
  |===
1185
1183
 
1186
- This cop enforces the test to use `refute_predicate`
1184
+ Enforces the test to use `refute_predicate`
1187
1185
  instead of using `refute(obj.a_predicate_method?)`.
1188
1186
 
1189
1187
  === Examples
@@ -1215,7 +1213,7 @@ refute_predicate(obj, :one?, 'message')
1215
1213
  | -
1216
1214
  |===
1217
1215
 
1218
- This cop enforces the test to use `refute_respond_to(object, :do_something)`
1216
+ Enforces the test to use `refute_respond_to(object, :do_something)`
1219
1217
  over `refute(object.respond_to?(:do_something))`.
1220
1218
 
1221
1219
  === Examples
@@ -1237,6 +1235,79 @@ refute_respond_to(self, :do_something)
1237
1235
 
1238
1236
  * https://minitest.rubystyle.guide#refute-respond-to
1239
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
+
1240
1311
  == Minitest/TestMethodName
1241
1312
 
1242
1313
  |===
@@ -1249,7 +1320,7 @@ refute_respond_to(self, :do_something)
1249
1320
  | -
1250
1321
  |===
1251
1322
 
1252
- This cop enforces that test method names start with `test_` prefix.
1323
+ Enforces that test method names start with `test_` prefix.
1253
1324
  It aims to prevent tests that aren't executed by forgetting to start test method name with `test_`.
1254
1325
 
1255
1326
  === Examples
@@ -1289,7 +1360,7 @@ end
1289
1360
  | -
1290
1361
  |===
1291
1362
 
1292
- This cop checks for `assert_raises` has an assertion method at
1363
+ Checks for `assert_raises` has an assertion method at
1293
1364
  the bottom of block because the assertion will be never reached.
1294
1365
 
1295
1366
  === Examples
@@ -1321,7 +1392,7 @@ assert_equal('foo', obj.bar)
1321
1392
  | -
1322
1393
  |===
1323
1394
 
1324
- This cop checks for a specified error in `assert_raises`.
1395
+ Checks for a specified error in `assert_raises`.
1325
1396
 
1326
1397
  === Examples
1327
1398
 
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_empty`
7
- # instead of using `assert(object.empty?)`.
6
+ # Enforces the test to use `assert_empty` instead of using `assert(object.empty?)`.
8
7
  #
9
8
  # @example
10
9
  # # bad
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_empty`
6
+ # Enforces the test to use `assert_empty`
7
7
  # instead of using `assert_equal([], object)` or `assert_equal({}, object)`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the use of `assert_equal(expected, actual)`
6
+ # Enforces the use of `assert_equal(expected, actual)`
7
7
  # over `assert(expected == actual)`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_in_delta`
6
+ # Enforces the test to use `assert_in_delta`
7
7
  # instead of using `assert_equal` to compare floats.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_includes`
6
+ # Enforces the test to use `assert_includes`
7
7
  # instead of using `assert(collection.include?(object))`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_instance_of(Class, object)`
6
+ # Enforces the test to use `assert_instance_of(Class, object)`
7
7
  # over `assert(object.instance_of?(Class))`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_kind_of(Class, object)`
6
+ # Enforces the test to use `assert_kind_of(Class, object)`
7
7
  # over `assert(object.kind_of?(Class))`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_match`
6
+ # Enforces the test to use `assert_match`
7
7
  # instead of using `assert(matcher.match(string))`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
- # This cop enforces the test to use `assert_nil` instead of using
6
+ # Enforces the test to use `assert_nil` instead of using
7
7
  # `assert_equal(nil, something)`, `assert(something.nil?)`, or `assert_predicate(something, :nil?)`.
8
8
  #
9
9
  # @example