rubocop-minitest 0.19.0 → 0.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) 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 +32 -4
  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 +126 -55
  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 +5 -2
  31. data/lib/rubocop/cop/minitest/global_expectations.rb +13 -13
  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 +11 -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.19.0.md +1 -1
  59. data/relnotes/v0.19.1.md +5 -0
  60. data/relnotes/v0.20.0.md +13 -0
  61. data/relnotes/v0.20.1.md +5 -0
  62. data/relnotes/v0.9.0.md +1 -1
  63. data/rubocop-minitest.gemspec +1 -1
  64. data/tasks/cut_release.rake +1 -1
  65. metadata +9 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95cf5254c67b24f10e4739b82656ebcd96fba6924832abaaf3045aacbb33708f
4
- data.tar.gz: 7aa03cd9becf56e2c2f27c59e0757d2e451a8866c212c713e1370bcc69e04c83
3
+ metadata.gz: d780d9c08b215f247a19ffc039d8385b58f63037585c882e3b760cdbe511ae14
4
+ data.tar.gz: 1ea02089d0b9a3511cbc19a3222f3c55e86a3c17d05bdc05291281df8115500a
5
5
  SHA512:
6
- metadata.gz: cd2b68e25392718c159b1d43dfabe0529f00a11230322d14a3c8b987e16b177a976ffacb37f97015c062a22e3f3c195e82f7ebd897b97c374682f909a0fe8805
7
- data.tar.gz: 29a54d7e19f8ad4b06c9bf443adf13c0920e5ab55413618a3268fb81253c6e96d16540a733677ab5b9e6340a172d58164d0f01f3f7c2725bfd90cbcbaf04e515
6
+ metadata.gz: 241d069163e52ba35fc4edb2c96d3f7fca6a32fa84ced1feee2abf777d42561503b309371444b81da318c3f07bce469a89e12fc2f6d0295372c3249c41db1ff1
7
+ data.tar.gz: 76ec782b3a226848f6676266dfbd1f06dc0cf2bbd999f01f9c46096def25cfe188c7dddb95ca93ab737812ef6eae81fd8401872b8a243344e1903c50143a699c
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,11 +2,37 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.20.1 (2022-06-13)
6
+
7
+ ### Bug fixes
8
+
9
+ * [#175](https://github.com/rubocop/rubocop-minitest/pull/175): Fix raise error when using assert with block. ([@ippachi][])
10
+
11
+ ## 0.20.0 (2022-05-29)
12
+
13
+ ### New features
14
+
15
+ * [#169](https://github.com/rubocop/rubocop-minitest/issues/169): Add new `Minitest/SkipEnsure` cop. ([@koic][])
16
+
17
+ ### Bug fixes
18
+
19
+ * [#172](https://github.com/rubocop/rubocop-minitest/issues/172): Fix a false positive for `Minitest/AssertPredicate` and `Minitest/RefutePredicate` when using numbered parameters. ([@koic][])
20
+
21
+ ### Changes
22
+
23
+ * [#168](https://github.com/rubocop/rubocop-minitest/pull/168): **(Compatibility)** Drop Ruby 2.5 support. ([@koic][])
24
+
25
+ ## 0.19.1 (2022-04-10)
26
+
27
+ ### Bug fixes
28
+
29
+ * [#167](https://github.com/rubocop/rubocop-minitest/pull/167): Fix potential for valid Ruby code to be unparsable in `Minitest/DuplicateTestRun` cop. ([@gjtorikian][])
30
+
5
31
  ## 0.19.0 (2022-04-05)
6
32
 
7
33
  ### New features
8
34
 
9
- * [#164](https://github.com/rubocop/rubocop-minitest/pull/164): Add new `Minitest/DuplicateTestRun cop. ([@ignacio-chiazzo][])
35
+ * [#164](https://github.com/rubocop/rubocop-minitest/pull/164): Add new `Minitest/DuplicateTestRun` cop. ([@ignacio-chiazzo][])
10
36
 
11
37
  ## 0.18.0 (2022-03-13)
12
38
 
@@ -51,7 +77,7 @@
51
77
 
52
78
  ### Bug fixes
53
79
 
54
- * [#145](https://github.com/rubocop/rubocop-minitest/pull/145): Mark `Minitest/AssertEmptyLiteral` as safe auto-correction. ([@koic][])
80
+ * [#145](https://github.com/rubocop/rubocop-minitest/pull/145): Mark `Minitest/AssertEmptyLiteral` as safe autocorrection. ([@koic][])
55
81
 
56
82
  ## 0.15.1 (2021-09-26)
57
83
 
@@ -91,7 +117,7 @@
91
117
 
92
118
  ### Changes
93
119
 
94
- * [#129](https://github.com/rubocop/rubocop-minitest/pull/129): Drop Ruby 2.4 support. ([@koic][])
120
+ * [#129](https://github.com/rubocop/rubocop-minitest/pull/129): **(Compatibility)** Drop Ruby 2.4 support. ([@koic][])
95
121
 
96
122
  ## 0.11.1 (2021-03-31)
97
123
 
@@ -161,7 +187,7 @@
161
187
  ### Changes
162
188
 
163
189
  * [#73](https://github.com/rubocop/rubocop-minitest/issues/73): The Minitest department works on file names end with `_test.rb` by default. ([@koic][])
164
- * [#77](https://github.com/rubocop/rubocop-minitest/pull/77): **(BREAKING)** Drop support for Ruby 2.3. ([@koic][])
190
+ * [#77](https://github.com/rubocop/rubocop-minitest/pull/77): **(Compatibility)** Drop support for Ruby 2.3. ([@koic][])
165
191
 
166
192
  ## 0.8.1 (2020-04-06)
167
193
 
@@ -293,3 +319,5 @@
293
319
  [@ghiculescu]: https://github.com/ghiculescu
294
320
  [@gi]: https://github.com/gi
295
321
  [@ignacio-chiazzo]: https://github.com/ignacio-chiazzo
322
+ [@gjtorikian]: https://github.com/gjtorikian
323
+ [@ippachi]: https://github.com/ippachi
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,12 +614,12 @@ 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
620
621
 
621
- ==== EnforcedStyle: _
622
+ ==== EnforcedStyle: any (default)
622
623
 
623
624
  [source,ruby]
624
625
  ----
@@ -627,6 +628,11 @@ musts.must_equal expected_musts
627
628
  wonts.wont_match expected_wonts
628
629
  musts.must_raise TypeError
629
630
 
631
+ # good
632
+ _(musts).must_equal expected_musts
633
+ _(wonts).wont_match expected_wonts
634
+ _ { musts }.must_raise TypeError
635
+
630
636
  expect(musts).must_equal expected_musts
631
637
  expect(wonts).wont_match expected_wonts
632
638
  expect { musts }.must_raise TypeError
@@ -634,14 +640,9 @@ expect { musts }.must_raise TypeError
634
640
  value(musts).must_equal expected_musts
635
641
  value(wonts).wont_match expected_wonts
636
642
  value { musts }.must_raise TypeError
637
-
638
- # good
639
- _(musts).must_equal expected_musts
640
- _(wonts).wont_match expected_wonts
641
- _ { musts }.must_raise TypeError
642
643
  ----
643
644
 
644
- ==== EnforcedStyle: any (default)
645
+ ==== EnforcedStyle: _
645
646
 
646
647
  [source,ruby]
647
648
  ----
@@ -650,11 +651,6 @@ musts.must_equal expected_musts
650
651
  wonts.wont_match expected_wonts
651
652
  musts.must_raise TypeError
652
653
 
653
- # good
654
- _(musts).must_equal expected_musts
655
- _(wonts).wont_match expected_wonts
656
- _ { musts }.must_raise TypeError
657
-
658
654
  expect(musts).must_equal expected_musts
659
655
  expect(wonts).wont_match expected_wonts
660
656
  expect { musts }.must_raise TypeError
@@ -662,6 +658,11 @@ expect { musts }.must_raise TypeError
662
658
  value(musts).must_equal expected_musts
663
659
  value(wonts).wont_match expected_wonts
664
660
  value { musts }.must_raise TypeError
661
+
662
+ # good
663
+ _(musts).must_equal expected_musts
664
+ _(wonts).wont_match expected_wonts
665
+ _ { musts }.must_raise TypeError
665
666
  ----
666
667
 
667
668
  ==== EnforcedStyle: expect
@@ -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