rubocop-minitest 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +18 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +5 -1
  4. data/.rubocop.yml +5 -3
  5. data/.rubocop_todo.yml +8 -7
  6. data/CHANGELOG.md +94 -37
  7. data/CONTRIBUTING.md +3 -3
  8. data/Gemfile +2 -2
  9. data/LICENSE.txt +1 -1
  10. data/README.md +20 -4
  11. data/Rakefile +29 -0
  12. data/bin/console +2 -0
  13. data/config/default.yml +100 -16
  14. data/docs/antora.yml +7 -0
  15. data/docs/modules/ROOT/nav.adoc +6 -0
  16. data/docs/modules/ROOT/pages/cops.adoc +49 -0
  17. data/docs/modules/ROOT/pages/cops_minitest.adoc +1050 -0
  18. data/docs/modules/ROOT/pages/index.adoc +5 -0
  19. data/docs/modules/ROOT/pages/installation.adoc +15 -0
  20. data/docs/modules/ROOT/pages/usage.adoc +32 -0
  21. data/{manual → legacy-docs}/cops.md +0 -0
  22. data/{manual → legacy-docs}/cops_minitest.md +16 -16
  23. data/legacy-docs/index.md +1 -0
  24. data/{manual → legacy-docs}/installation.md +0 -0
  25. data/{manual → legacy-docs}/usage.md +0 -0
  26. data/lib/rubocop/cop/generator.rb +56 -0
  27. data/lib/rubocop/cop/minitest/assert_empty_literal.rb +23 -7
  28. data/lib/rubocop/cop/minitest/assert_in_delta.rb +29 -0
  29. data/lib/rubocop/cop/minitest/assert_kind_of.rb +25 -0
  30. data/lib/rubocop/cop/minitest/assert_nil.rb +1 -0
  31. data/lib/rubocop/cop/minitest/assert_output.rb +49 -0
  32. data/lib/rubocop/cop/minitest/assert_path_exists.rb +59 -0
  33. data/lib/rubocop/cop/minitest/assert_silent.rb +45 -0
  34. data/lib/rubocop/cop/minitest/assert_truthy.rb +1 -0
  35. data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +38 -0
  36. data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +43 -0
  37. data/lib/rubocop/cop/minitest/global_expectations.rb +4 -4
  38. data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +53 -0
  39. data/lib/rubocop/cop/minitest/multiple_assertions.rb +63 -0
  40. data/lib/rubocop/cop/minitest/refute_equal.rb +2 -1
  41. data/lib/rubocop/cop/minitest/refute_false.rb +1 -0
  42. data/lib/rubocop/cop/minitest/refute_in_delta.rb +29 -0
  43. data/lib/rubocop/cop/minitest/refute_kind_of.rb +25 -0
  44. data/lib/rubocop/cop/minitest/refute_nil.rb +1 -0
  45. data/lib/rubocop/cop/minitest/refute_path_exists.rb +59 -0
  46. data/lib/rubocop/cop/minitest/test_method_name.rb +79 -0
  47. data/lib/rubocop/cop/minitest/unspecified_exception.rb +36 -0
  48. data/lib/rubocop/cop/minitest_cops.rb +16 -0
  49. data/lib/rubocop/cop/mixin/argument_range_helper.rb +10 -0
  50. data/lib/rubocop/cop/mixin/in_delta_mixin.rb +50 -0
  51. data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +2 -1
  52. data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +97 -0
  53. data/lib/rubocop/minitest/version.rb +8 -1
  54. data/mkdocs.yml +4 -4
  55. data/relnotes/v0.1.0.md +1 -1
  56. data/relnotes/v0.10.0.md +21 -0
  57. data/relnotes/v0.10.1.md +5 -0
  58. data/relnotes/v0.10.2.md +5 -0
  59. data/relnotes/v0.10.3.md +5 -0
  60. data/relnotes/v0.11.0.md +16 -0
  61. data/relnotes/v0.2.0.md +4 -4
  62. data/relnotes/v0.2.1.md +1 -1
  63. data/relnotes/v0.3.0.md +6 -6
  64. data/relnotes/v0.4.0.md +5 -5
  65. data/relnotes/v0.4.1.md +1 -1
  66. data/relnotes/v0.5.0.md +1 -1
  67. data/relnotes/v0.5.1.md +1 -1
  68. data/relnotes/v0.6.0.md +1 -1
  69. data/relnotes/v0.6.1.md +2 -2
  70. data/relnotes/v0.6.2.md +1 -1
  71. data/relnotes/v0.7.0.md +5 -5
  72. data/relnotes/v0.8.0.md +4 -4
  73. data/relnotes/v0.8.1.md +1 -1
  74. data/relnotes/v0.9.0.md +3 -3
  75. data/rubocop-minitest.gemspec +7 -7
  76. data/tasks/cops_documentation.rake +15 -264
  77. data/tasks/cut_release.rake +16 -0
  78. metadata +55 -20
  79. data/manual/index.md +0 -1
data/bin/console CHANGED
@@ -2,6 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
+ require 'pathname'
6
+ require 'yaml'
5
7
  require 'rubocop/minitest'
6
8
 
7
9
  # You can add fixtures and/or initialization code here to make experimenting
data/config/default.yml CHANGED
@@ -6,106 +6,190 @@ Minitest:
6
6
 
7
7
  Minitest/AssertEmpty:
8
8
  Description: 'This cop enforces the test to use `assert_empty` instead of using `assert(object.empty?)`.'
9
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-empty'
9
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-empty'
10
10
  Enabled: true
11
11
  VersionAdded: '0.2'
12
12
 
13
13
  Minitest/AssertEmptyLiteral:
14
14
  Description: 'This cop enforces the test to use `assert_empty` instead of using `assert([], object)` or `assert({}, object)`.'
15
15
  Enabled: true
16
+ SafeAutoCorrect: false
16
17
  VersionAdded: '0.5'
18
+ VersionChanged: '0.11'
17
19
 
18
20
  Minitest/AssertEqual:
19
21
  Description: 'This cop enforces the test to use `assert_equal` instead of using `assert(expected == actual)`.'
20
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-equal-arguments-order'
22
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-equal-arguments-order'
21
23
  Enabled: true
22
24
  VersionAdded: '0.4'
23
25
 
26
+ Minitest/AssertInDelta:
27
+ Description: 'This cop enforces the test to use `assert_in_delta` instead of using `assert_equal` to compare floats.'
28
+ StyleGuide: 'https://minitest.rubystyle.guide/#assert-in-delta'
29
+ Enabled: 'pending'
30
+ VersionAdded: '0.10'
31
+
32
+ Minitest/AssertionInLifecycleHook:
33
+ Description: 'This cop checks for usage of assertions in lifecycle hooks.'
34
+ Enabled: 'pending'
35
+ VersionAdded: '0.10'
36
+
24
37
  Minitest/AssertMatch:
25
38
  Description: 'This cop enforces the test to use `assert_match` instead of using `assert(matcher.match(object))`.'
26
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-match'
39
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-match'
27
40
  Enabled: true
28
41
  VersionAdded: '0.6'
29
42
 
30
43
  Minitest/AssertIncludes:
31
44
  Description: 'This cop enforces the test to use `assert_includes` instead of using `assert(collection.include?(object))`.'
32
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-includes'
45
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-includes'
33
46
  Enabled: true
34
47
  VersionAdded: '0.2'
35
48
 
36
49
  Minitest/AssertInstanceOf:
37
50
  Description: 'This cop enforces the test to use `assert_instance_of(Class, object)` over `assert(object.instance_of?(Class))`'
38
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of'
51
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-instance-of'
39
52
  Enabled: true
40
53
  VersionAdded: '0.4'
41
54
 
55
+ Minitest/AssertKindOf:
56
+ Description: 'This cop enforces the test to use `assert_kind_of(Class, object)` over `assert(object.kind_of?(Class))`'
57
+ StyleGuide: 'https://github.com/rubocop/minitest-style-guide#assert-kind-of'
58
+ Enabled: 'pending'
59
+ VersionAdded: '0.10'
60
+
42
61
  Minitest/AssertNil:
43
62
  Description: 'This cop enforces the test to use `assert_nil` instead of using `assert_equal(nil, something)`.'
44
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-nil'
63
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-nil'
45
64
  Enabled: true
46
65
  VersionAdded: '0.1'
47
66
 
67
+ Minitest/AssertOutput:
68
+ Description: 'This cop checks for opportunities to use `assert_output`.'
69
+ StyleGuide: 'https://minitest.rubystyle.guide/#assert-output'
70
+ Enabled: 'pending'
71
+ VersionAdded: '0.10'
72
+
73
+ Minitest/AssertPathExists:
74
+ Description: 'This cop enforces the test to use `assert_path_exists` instead of using `assert(File.exist?(path))`.'
75
+ StyleGuide: 'https://minitest.rubystyle.guide/#assert-path-exists'
76
+ Enabled: 'pending'
77
+ VersionAdded: '0.10'
78
+
48
79
  Minitest/AssertRespondTo:
49
80
  Description: 'This cop enforces the test to use `assert_respond_to(object, :do_something)` over `assert(object.respond_to?(:do_something))`.'
50
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-responds-to-method'
81
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-responds-to-method'
51
82
  Enabled: true
52
83
  VersionAdded: '0.3'
53
84
 
85
+ Minitest/AssertSilent:
86
+ Description: "This cop enforces the test to use `assert_silent { ... }` instead of using `assert_output('', '') { ... }`."
87
+ StyleGuide: 'https://github.com/rubocop/minitest-style-guide#assert-silent'
88
+ Enabled: 'pending'
89
+ VersionAdded: '0.10'
90
+
54
91
  Minitest/AssertTruthy:
55
92
  Description: 'This cop enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.'
56
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-truthy'
93
+ StyleGuide: 'https://minitest.rubystyle.guide#assert-truthy'
57
94
  Enabled: true
58
95
  VersionAdded: '0.2'
59
96
 
97
+ Minitest/AssertWithExpectedArgument:
98
+ Description: 'This cop tries to detect when a user accidentally used `assert` when they meant to use `assert_equal`.'
99
+ Enabled: pending
100
+ VersionAdded: '0.11'
101
+
60
102
  Minitest/GlobalExpectations:
61
103
  Description: 'This cop checks for deprecated global expectations.'
104
+ StyleGuide: 'https://minitest.rubystyle.guide#global-expectations'
62
105
  Enabled: true
63
106
  VersionAdded: '0.7'
64
107
 
108
+ Minitest/LiteralAsActualArgument:
109
+ Description: 'This cop enforces correct order of `expected` and `actual` arguments for `assert_equal`.'
110
+ StyleGuide: 'https://minitest.rubystyle.guide/#assert-equal-arguments-order'
111
+ Enabled: 'pending'
112
+ VersionAdded: '0.10'
113
+
114
+ Minitest/MultipleAssertions:
115
+ Description: 'This cop checks if test cases contain too many assertion calls.'
116
+ Enabled: 'pending'
117
+ VersionAdded: '0.10'
118
+ Max: 3
119
+
65
120
  Minitest/RefuteEmpty:
66
121
  Description: 'This cop enforces to use `refute_empty` instead of using `refute(object.empty?)`.'
67
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-empty'
122
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-empty'
68
123
  Enabled: true
69
124
  VersionAdded: '0.3'
70
125
 
71
126
  Minitest/RefuteEqual:
72
127
  Description: 'Check if your test uses `refute_equal` instead of `assert(expected != object)` or `assert(! expected == object))`.'
73
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-equal'
128
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-equal'
74
129
  Enabled: true
75
130
  VersionAdded: '0.3'
76
131
 
77
132
  Minitest/RefuteFalse:
78
133
  Description: 'Check if your test uses `refute(actual)` instead of `assert_equal(false, actual)`.'
79
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-false'
134
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-false'
80
135
  Enabled: true
81
136
  VersionAdded: '0.3'
82
137
 
138
+ Minitest/RefuteInDelta:
139
+ Description: 'This cop enforces the test to use `refute_in_delta` instead of using `refute_equal` to compare floats.'
140
+ StyleGuide: 'https://minitest.rubystyle.guide/#refute-in-delta'
141
+ Enabled: 'pending'
142
+ VersionAdded: '0.10'
143
+
83
144
  Minitest/RefuteIncludes:
84
145
  Description: 'This cop enforces the test to use `refute_includes` instead of using `refute(collection.include?(object))`.'
85
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-includes'
146
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-includes'
86
147
  Enabled: true
87
148
  VersionAdded: '0.3'
88
149
 
89
150
  Minitest/RefuteMatch:
90
151
  Description: 'This cop enforces the test to use `refute_match` instead of using `refute(matcher.match(object))`.'
91
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-match'
152
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-match'
92
153
  Enabled: true
93
154
  VersionAdded: '0.6'
94
155
 
95
156
  Minitest/RefuteInstanceOf:
96
157
  Description: 'This cop enforces the test to use `refute_instance_of(Class, object)` over `refute(object.instance_of?(Class))`.'
97
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of'
158
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-instance-of'
98
159
  Enabled: true
99
160
  VersionAdded: '0.4'
100
161
 
162
+ Minitest/RefuteKindOf:
163
+ Description: 'This cop enforces the test to use `refute_kind_of(Class, object)` over `refute(object.kind_of?(Class))`.'
164
+ StyleGuide: 'https://github.com/rubocop/minitest-style-guide#refute-kind-of'
165
+ Enabled: 'pending'
166
+ VersionAdded: '0.10'
167
+
101
168
  Minitest/RefuteNil:
102
169
  Description: 'This cop enforces the test to use `refute_nil` instead of using `refute_equal(nil, something)`.'
103
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-nil'
170
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-nil'
104
171
  Enabled: true
105
172
  VersionAdded: '0.2'
106
173
 
174
+ Minitest/RefutePathExists:
175
+ Description: 'This cop enforces the test to use `refute_path_exists` instead of using `refute(File.exist?(path))`.'
176
+ StyleGuide: 'https://minitest.rubystyle.guide/#refute-path-exists'
177
+ Enabled: 'pending'
178
+ VersionAdded: '0.10'
179
+
107
180
  Minitest/RefuteRespondTo:
108
181
  Description: 'This cop enforces the test to use `refute_respond_to(object, :do_something)` over `refute(object.respond_to?(:do_something))`.'
109
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to'
182
+ StyleGuide: 'https://minitest.rubystyle.guide#refute-respond-to'
110
183
  Enabled: true
111
184
  VersionAdded: '0.4'
185
+
186
+ Minitest/TestMethodName:
187
+ Description: 'This cop enforces that test method names start with `test_` prefix.'
188
+ Enabled: 'pending'
189
+ VersionAdded: '0.10'
190
+
191
+ Minitest/UnspecifiedException:
192
+ Description: 'This cop checks for a specified error in `assert_raises`.'
193
+ StyleGuide: 'https://minitest.rubystyle.guide#unspecified-exception'
194
+ Enabled: 'pending'
195
+ VersionAdded: '0.10'
data/docs/antora.yml ADDED
@@ -0,0 +1,7 @@
1
+ name: rubocop-minitest
2
+ title: RuboCop Minitest
3
+ # We always provide version without patch here (e.g. 1.1),
4
+ # as patch versions should not appear in the docs.
5
+ version: '0.11'
6
+ nav:
7
+ - modules/ROOT/nav.adoc
@@ -0,0 +1,6 @@
1
+ * xref:index.adoc[Home]
2
+ * xref:installation.adoc[Installation]
3
+ * xref:usage.adoc[Usage]
4
+ * xref:cops.adoc[Cops]
5
+ * Cops Documentation
6
+ ** xref:cops_minitest.adoc[Minitest]
@@ -0,0 +1,49 @@
1
+ = Cops
2
+
3
+ In RuboCop lingo the various checks performed on the code are called cops.
4
+ Each cop is responsible for detecting one particular offense.
5
+ RuboCop Minitest has only one Minitest department.
6
+
7
+ == Minitest
8
+
9
+ Minitest cops check for Minitest best practices and coding conventions. Many of the them are
10
+ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
11
+
12
+ // START_COP_LIST
13
+
14
+ === Department xref:cops_minitest.adoc[Minitest]
15
+
16
+ * xref:cops_minitest.adoc#minitestassertempty[Minitest/AssertEmpty]
17
+ * xref:cops_minitest.adoc#minitestassertemptyliteral[Minitest/AssertEmptyLiteral]
18
+ * xref:cops_minitest.adoc#minitestassertequal[Minitest/AssertEqual]
19
+ * xref:cops_minitest.adoc#minitestassertindelta[Minitest/AssertInDelta]
20
+ * xref:cops_minitest.adoc#minitestassertincludes[Minitest/AssertIncludes]
21
+ * xref:cops_minitest.adoc#minitestassertinstanceof[Minitest/AssertInstanceOf]
22
+ * xref:cops_minitest.adoc#minitestassertkindof[Minitest/AssertKindOf]
23
+ * xref:cops_minitest.adoc#minitestassertmatch[Minitest/AssertMatch]
24
+ * xref:cops_minitest.adoc#minitestassertnil[Minitest/AssertNil]
25
+ * xref:cops_minitest.adoc#minitestassertoutput[Minitest/AssertOutput]
26
+ * xref:cops_minitest.adoc#minitestassertpathexists[Minitest/AssertPathExists]
27
+ * xref:cops_minitest.adoc#minitestassertrespondto[Minitest/AssertRespondTo]
28
+ * xref:cops_minitest.adoc#minitestassertsilent[Minitest/AssertSilent]
29
+ * xref:cops_minitest.adoc#minitestasserttruthy[Minitest/AssertTruthy]
30
+ * xref:cops_minitest.adoc#minitestassertwithexpectedargument[Minitest/AssertWithExpectedArgument]
31
+ * xref:cops_minitest.adoc#minitestassertioninlifecyclehook[Minitest/AssertionInLifecycleHook]
32
+ * xref:cops_minitest.adoc#minitestglobalexpectations[Minitest/GlobalExpectations]
33
+ * xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument]
34
+ * xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions]
35
+ * xref:cops_minitest.adoc#minitestrefuteempty[Minitest/RefuteEmpty]
36
+ * xref:cops_minitest.adoc#minitestrefuteequal[Minitest/RefuteEqual]
37
+ * xref:cops_minitest.adoc#minitestrefutefalse[Minitest/RefuteFalse]
38
+ * xref:cops_minitest.adoc#minitestrefuteindelta[Minitest/RefuteInDelta]
39
+ * xref:cops_minitest.adoc#minitestrefuteincludes[Minitest/RefuteIncludes]
40
+ * xref:cops_minitest.adoc#minitestrefuteinstanceof[Minitest/RefuteInstanceOf]
41
+ * xref:cops_minitest.adoc#minitestrefutekindof[Minitest/RefuteKindOf]
42
+ * xref:cops_minitest.adoc#minitestrefutematch[Minitest/RefuteMatch]
43
+ * xref:cops_minitest.adoc#minitestrefutenil[Minitest/RefuteNil]
44
+ * xref:cops_minitest.adoc#minitestrefutepathexists[Minitest/RefutePathExists]
45
+ * xref:cops_minitest.adoc#minitestrefuterespondto[Minitest/RefuteRespondTo]
46
+ * xref:cops_minitest.adoc#minitesttestmethodname[Minitest/TestMethodName]
47
+ * xref:cops_minitest.adoc#minitestunspecifiedexception[Minitest/UnspecifiedException]
48
+
49
+ // END_COP_LIST
@@ -0,0 +1,1050 @@
1
+ = Minitest
2
+
3
+ == Minitest/AssertEmpty
4
+
5
+ |===
6
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
7
+
8
+ | Enabled
9
+ | Yes
10
+ | Yes
11
+ | 0.2
12
+ | -
13
+ |===
14
+
15
+ This cop enforces the test to use `assert_empty`
16
+ instead of using `assert(object.empty?)`.
17
+
18
+ === Examples
19
+
20
+ [source,ruby]
21
+ ----
22
+ # bad
23
+ assert(object.empty?)
24
+ assert(object.empty?, 'message')
25
+
26
+ # good
27
+ assert_empty(object)
28
+ assert_empty(object, 'message')
29
+ ----
30
+
31
+ === References
32
+
33
+ * https://minitest.rubystyle.guide#assert-empty
34
+
35
+ == Minitest/AssertEmptyLiteral
36
+
37
+ |===
38
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
39
+
40
+ | Enabled
41
+ | Yes
42
+ | Yes (Unsafe)
43
+ | 0.5
44
+ | 0.11
45
+ |===
46
+
47
+ This cop enforces the test to use `assert_empty`
48
+ instead of using `assert_equal([], object)`.
49
+
50
+ === Examples
51
+
52
+ [source,ruby]
53
+ ----
54
+ # bad
55
+ assert_equal([], object)
56
+ assert_equal({}, object)
57
+
58
+ # good
59
+ assert_empty(object)
60
+ ----
61
+
62
+ == Minitest/AssertEqual
63
+
64
+ |===
65
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
66
+
67
+ | Enabled
68
+ | Yes
69
+ | Yes
70
+ | 0.4
71
+ | -
72
+ |===
73
+
74
+ This cop enforces the use of `assert_equal(expected, actual)`
75
+ over `assert(expected == actual)`.
76
+
77
+ === Examples
78
+
79
+ [source,ruby]
80
+ ----
81
+ # bad
82
+ assert("rubocop-minitest" == actual)
83
+
84
+ # good
85
+ assert_equal("rubocop-minitest", actual)
86
+ ----
87
+
88
+ === References
89
+
90
+ * https://minitest.rubystyle.guide#assert-equal-arguments-order
91
+
92
+ == Minitest/AssertInDelta
93
+
94
+ |===
95
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
96
+
97
+ | Pending
98
+ | Yes
99
+ | Yes
100
+ | 0.10
101
+ | -
102
+ |===
103
+
104
+ This cop enforces the test to use `assert_in_delta`
105
+ instead of using `assert_equal` to compare floats.
106
+
107
+ === Examples
108
+
109
+ [source,ruby]
110
+ ----
111
+ # bad
112
+ assert_equal(0.2, actual)
113
+ assert_equal(0.2, actual, 'message')
114
+
115
+ # good
116
+ assert_in_delta(0.2, actual)
117
+ assert_in_delta(0.2, actual, 0.001, 'message')
118
+ ----
119
+
120
+ === References
121
+
122
+ * https://minitest.rubystyle.guide/#assert-in-delta
123
+
124
+ == Minitest/AssertIncludes
125
+
126
+ |===
127
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
128
+
129
+ | Enabled
130
+ | Yes
131
+ | Yes
132
+ | 0.2
133
+ | -
134
+ |===
135
+
136
+ This cop enforces the test to use `assert_includes`
137
+ instead of using `assert(collection.include?(object))`.
138
+
139
+ === Examples
140
+
141
+ [source,ruby]
142
+ ----
143
+ # bad
144
+ assert(collection.include?(object))
145
+ assert(collection.include?(object), 'message')
146
+
147
+ # good
148
+ assert_includes(collection, object)
149
+ assert_includes(collection, object, 'message')
150
+ ----
151
+
152
+ === References
153
+
154
+ * https://minitest.rubystyle.guide#assert-includes
155
+
156
+ == Minitest/AssertInstanceOf
157
+
158
+ |===
159
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
160
+
161
+ | Enabled
162
+ | Yes
163
+ | Yes
164
+ | 0.4
165
+ | -
166
+ |===
167
+
168
+ This cop enforces the test to use `assert_instance_of(Class, object)`
169
+ over `assert(object.instance_of?(Class))`.
170
+
171
+ === Examples
172
+
173
+ [source,ruby]
174
+ ----
175
+ # bad
176
+ assert(object.instance_of?(Class))
177
+ assert(object.instance_of?(Class), 'message')
178
+
179
+ # good
180
+ assert_instance_of(Class, object)
181
+ assert_instance_of(Class, object, 'message')
182
+ ----
183
+
184
+ === References
185
+
186
+ * https://minitest.rubystyle.guide#assert-instance-of
187
+
188
+ == Minitest/AssertKindOf
189
+
190
+ |===
191
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
192
+
193
+ | Pending
194
+ | Yes
195
+ | Yes
196
+ | 0.10
197
+ | -
198
+ |===
199
+
200
+ This cop enforces the test to use `assert_kind_of(Class, object)`
201
+ over `assert(object.kind_of?(Class))`.
202
+
203
+ === Examples
204
+
205
+ [source,ruby]
206
+ ----
207
+ # bad
208
+ assert(object.kind_of?(Class))
209
+ assert(object.kind_of?(Class), 'message')
210
+
211
+ # good
212
+ assert_kind_of(Class, object)
213
+ assert_kind_of(Class, object, 'message')
214
+ ----
215
+
216
+ === References
217
+
218
+ * https://github.com/rubocop/minitest-style-guide#assert-kind-of
219
+
220
+ == Minitest/AssertMatch
221
+
222
+ |===
223
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
224
+
225
+ | Enabled
226
+ | Yes
227
+ | Yes
228
+ | 0.6
229
+ | -
230
+ |===
231
+
232
+ This cop enforces the test to use `assert_match`
233
+ instead of using `assert(matcher.match(string))`.
234
+
235
+ === Examples
236
+
237
+ [source,ruby]
238
+ ----
239
+ # bad
240
+ assert(matcher.match(string))
241
+ assert(matcher.match(string), 'message')
242
+
243
+ # good
244
+ assert_match(regex, string)
245
+ assert_match(matcher, string, 'message')
246
+ ----
247
+
248
+ === References
249
+
250
+ * https://minitest.rubystyle.guide#assert-match
251
+
252
+ == Minitest/AssertNil
253
+
254
+ |===
255
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
256
+
257
+ | Enabled
258
+ | Yes
259
+ | Yes
260
+ | 0.1
261
+ | -
262
+ |===
263
+
264
+ This cop enforces the test to use `assert_nil`
265
+ instead of using `assert_equal(nil, something)`.
266
+
267
+ === Examples
268
+
269
+ [source,ruby]
270
+ ----
271
+ # bad
272
+ assert_equal(nil, actual)
273
+ assert_equal(nil, actual, 'message')
274
+
275
+ # good
276
+ assert_nil(actual)
277
+ assert_nil(actual, 'message')
278
+ ----
279
+
280
+ === References
281
+
282
+ * https://minitest.rubystyle.guide#assert-nil
283
+
284
+ == Minitest/AssertOutput
285
+
286
+ |===
287
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
288
+
289
+ | Pending
290
+ | Yes
291
+ | No
292
+ | 0.10
293
+ | -
294
+ |===
295
+
296
+ This cop checks for opportunities to use `assert_output`.
297
+
298
+ === Examples
299
+
300
+ [source,ruby]
301
+ ----
302
+ # bad
303
+ $stdout = StringIO.new
304
+ puts object.method
305
+ $stdout.rewind
306
+ assert_match expected, $stdout.read
307
+
308
+ # good
309
+ assert_output(expected) { puts object.method }
310
+ ----
311
+
312
+ === References
313
+
314
+ * https://minitest.rubystyle.guide/#assert-output
315
+
316
+ == Minitest/AssertPathExists
317
+
318
+ |===
319
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
320
+
321
+ | Pending
322
+ | Yes
323
+ | Yes
324
+ | 0.10
325
+ | -
326
+ |===
327
+
328
+ This cop enforces the test to use `assert_path_exists`
329
+ instead of using `assert(File.exist?(path))`.
330
+
331
+ === Examples
332
+
333
+ [source,ruby]
334
+ ----
335
+ # bad
336
+ assert(File.exist?(path))
337
+ assert(File.exist?(path), 'message')
338
+
339
+ # good
340
+ assert_path_exists(path)
341
+ assert_path_exists(path, 'message')
342
+ ----
343
+
344
+ === References
345
+
346
+ * https://minitest.rubystyle.guide/#assert-path-exists
347
+
348
+ == Minitest/AssertRespondTo
349
+
350
+ |===
351
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
352
+
353
+ | Enabled
354
+ | Yes
355
+ | Yes
356
+ | 0.3
357
+ | -
358
+ |===
359
+
360
+ This cop enforces the use of `assert_respond_to(object, :do_something)`
361
+ over `assert(object.respond_to?(:do_something))`.
362
+
363
+ === Examples
364
+
365
+ [source,ruby]
366
+ ----
367
+ # bad
368
+ assert(object.respond_to?(:do_something))
369
+ assert(object.respond_to?(:do_something), 'message')
370
+ assert(respond_to?(:do_something))
371
+
372
+ # good
373
+ assert_respond_to(object, :do_something)
374
+ assert_respond_to(object, :do_something, 'message')
375
+ assert_respond_to(self, :do_something)
376
+ ----
377
+
378
+ === References
379
+
380
+ * https://minitest.rubystyle.guide#assert-responds-to-method
381
+
382
+ == Minitest/AssertSilent
383
+
384
+ |===
385
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
386
+
387
+ | Pending
388
+ | Yes
389
+ | Yes
390
+ | 0.10
391
+ | -
392
+ |===
393
+
394
+ This cop enforces the test to use `assert_silent { ... }`
395
+ instead of using `assert_output('', '') { ... }`.
396
+
397
+ === Examples
398
+
399
+ [source,ruby]
400
+ ----
401
+ # bad
402
+ assert_output('', '') { puts object.do_something }
403
+
404
+ # good
405
+ assert_silent { puts object.do_something }
406
+ ----
407
+
408
+ === References
409
+
410
+ * https://github.com/rubocop/minitest-style-guide#assert-silent
411
+
412
+ == Minitest/AssertTruthy
413
+
414
+ |===
415
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
416
+
417
+ | Enabled
418
+ | Yes
419
+ | Yes
420
+ | 0.2
421
+ | -
422
+ |===
423
+
424
+ This cop enforces the test to use `assert(actual)`
425
+ instead of using `assert_equal(true, actual)`.
426
+
427
+ === Examples
428
+
429
+ [source,ruby]
430
+ ----
431
+ # bad
432
+ assert_equal(true, actual)
433
+ assert_equal(true, actual, 'message')
434
+
435
+ # good
436
+ assert(actual)
437
+ assert(actual, 'message')
438
+ ----
439
+
440
+ === References
441
+
442
+ * https://minitest.rubystyle.guide#assert-truthy
443
+
444
+ == Minitest/AssertWithExpectedArgument
445
+
446
+ |===
447
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
448
+
449
+ | Pending
450
+ | Yes
451
+ | No
452
+ | 0.11
453
+ | -
454
+ |===
455
+
456
+ This cop tries to detect when a user accidentally used
457
+ `assert` when they meant to use `assert_equal`.
458
+
459
+ === Examples
460
+
461
+ [source,ruby]
462
+ ----
463
+ # bad
464
+ assert(3, my_list.length)
465
+ assert(expected, actual)
466
+
467
+ # good
468
+ assert_equal(3, my_list.length)
469
+ assert_equal(expected, actual)
470
+ assert(foo, 'message')
471
+ ----
472
+
473
+ == Minitest/AssertionInLifecycleHook
474
+
475
+ |===
476
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
477
+
478
+ | Pending
479
+ | Yes
480
+ | No
481
+ | 0.10
482
+ | -
483
+ |===
484
+
485
+ This cop checks for usage of assertions in lifecycle hooks.
486
+
487
+ === Examples
488
+
489
+ [source,ruby]
490
+ ----
491
+ # bad
492
+ class FooTest < Minitest::Test
493
+ def setup
494
+ assert_equal(foo, bar)
495
+ end
496
+ end
497
+
498
+ # good
499
+ class FooTest < Minitest::Test
500
+ def test_something
501
+ assert_equal(foo, bar)
502
+ end
503
+ end
504
+ ----
505
+
506
+ == Minitest/GlobalExpectations
507
+
508
+ |===
509
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
510
+
511
+ | Enabled
512
+ | Yes
513
+ | Yes
514
+ | 0.7
515
+ | -
516
+ |===
517
+
518
+ This cop checks for deprecated global expectations
519
+ and autocorrects them to use expect format.
520
+
521
+ === Examples
522
+
523
+ [source,ruby]
524
+ ----
525
+ # bad
526
+ musts.must_equal expected_musts
527
+ wonts.wont_match expected_wonts
528
+ musts.must_raise TypeError
529
+
530
+ # good
531
+ _(musts).must_equal expected_musts
532
+ _(wonts).wont_match expected_wonts
533
+ _ { musts }.must_raise TypeError
534
+ ----
535
+
536
+ === References
537
+
538
+ * https://minitest.rubystyle.guide#global-expectations
539
+
540
+ == Minitest/LiteralAsActualArgument
541
+
542
+ |===
543
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
544
+
545
+ | Pending
546
+ | Yes
547
+ | Yes
548
+ | 0.10
549
+ | -
550
+ |===
551
+
552
+ This cop enforces correct order of expected and
553
+ actual arguments for `assert_equal`.
554
+
555
+ === Examples
556
+
557
+ [source,ruby]
558
+ ----
559
+ # bad
560
+ assert_equal foo, 2
561
+ assert_equal foo, [1, 2]
562
+ assert_equal foo, [1, 2], 'message'
563
+
564
+ # good
565
+ assert_equal 2, foo
566
+ assert_equal [1, 2], foo
567
+ assert_equal [1, 2], foo, 'message'
568
+ ----
569
+
570
+ === References
571
+
572
+ * https://minitest.rubystyle.guide/#assert-equal-arguments-order
573
+
574
+ == Minitest/MultipleAssertions
575
+
576
+ |===
577
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
578
+
579
+ | Pending
580
+ | Yes
581
+ | No
582
+ | 0.10
583
+ | -
584
+ |===
585
+
586
+ This cop checks if test cases contain too many assertion calls.
587
+ The maximum allowed assertion calls is configurable.
588
+
589
+ === Examples
590
+
591
+ ==== Max: 1
592
+
593
+ [source,ruby]
594
+ ----
595
+ # bad
596
+ class FooTest < Minitest::Test
597
+ def test_asserts_twice
598
+ assert_equal(42, do_something)
599
+ assert_empty(array)
600
+ end
601
+ end
602
+
603
+ # good
604
+ class FooTest < Minitest::Test
605
+ def test_asserts_once
606
+ assert_equal(42, do_something)
607
+ end
608
+
609
+ def test_another_asserts_once
610
+ assert_empty(array)
611
+ end
612
+ end
613
+ ----
614
+
615
+ === Configurable attributes
616
+
617
+ |===
618
+ | Name | Default value | Configurable values
619
+
620
+ | Max
621
+ | `3`
622
+ | Integer
623
+ |===
624
+
625
+ == Minitest/RefuteEmpty
626
+
627
+ |===
628
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
629
+
630
+ | Enabled
631
+ | Yes
632
+ | Yes
633
+ | 0.3
634
+ | -
635
+ |===
636
+
637
+ This cop enforces to use `refute_empty` instead of
638
+ using `refute(object.empty?)`.
639
+
640
+ === Examples
641
+
642
+ [source,ruby]
643
+ ----
644
+ # bad
645
+ refute(object.empty?)
646
+ refute(object.empty?, 'message')
647
+
648
+ # good
649
+ refute_empty(object)
650
+ refute_empty(object, 'message')
651
+ ----
652
+
653
+ === References
654
+
655
+ * https://minitest.rubystyle.guide#refute-empty
656
+
657
+ == Minitest/RefuteEqual
658
+
659
+ |===
660
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
661
+
662
+ | Enabled
663
+ | Yes
664
+ | Yes
665
+ | 0.3
666
+ | -
667
+ |===
668
+
669
+ This cop enforces the use of `refute_equal(expected, object)`
670
+ over `assert(expected != actual)` or `assert(! expected == actual)`.
671
+
672
+ === Examples
673
+
674
+ [source,ruby]
675
+ ----
676
+ # bad
677
+ assert("rubocop-minitest" != actual)
678
+ assert(! "rubocop-minitest" == actual)
679
+
680
+ # good
681
+ refute_equal("rubocop-minitest", actual)
682
+ ----
683
+
684
+ === References
685
+
686
+ * https://minitest.rubystyle.guide#refute-equal
687
+
688
+ == Minitest/RefuteFalse
689
+
690
+ |===
691
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
692
+
693
+ | Enabled
694
+ | Yes
695
+ | Yes
696
+ | 0.3
697
+ | -
698
+ |===
699
+
700
+ This cop enforces the use of `refute(object)`
701
+ over `assert_equal(false, object)`.
702
+
703
+ === Examples
704
+
705
+ [source,ruby]
706
+ ----
707
+ # bad
708
+ assert_equal(false, actual)
709
+ assert_equal(false, actual, 'message')
710
+
711
+ assert(!test)
712
+ assert(!test, 'message')
713
+
714
+ # good
715
+ refute(actual)
716
+ refute(actual, 'message')
717
+ ----
718
+
719
+ === References
720
+
721
+ * https://minitest.rubystyle.guide#refute-false
722
+
723
+ == Minitest/RefuteInDelta
724
+
725
+ |===
726
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
727
+
728
+ | Pending
729
+ | Yes
730
+ | Yes
731
+ | 0.10
732
+ | -
733
+ |===
734
+
735
+ This cop enforces the test to use `refute_in_delta`
736
+ instead of using `refute_equal` to compare floats.
737
+
738
+ === Examples
739
+
740
+ [source,ruby]
741
+ ----
742
+ # bad
743
+ refute_equal(0.2, actual)
744
+ refute_equal(0.2, actual, 'message')
745
+
746
+ # good
747
+ refute_in_delta(0.2, actual)
748
+ refute_in_delta(0.2, actual, 0.001, 'message')
749
+ ----
750
+
751
+ === References
752
+
753
+ * https://minitest.rubystyle.guide/#refute-in-delta
754
+
755
+ == Minitest/RefuteIncludes
756
+
757
+ |===
758
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
759
+
760
+ | Enabled
761
+ | Yes
762
+ | Yes
763
+ | 0.3
764
+ | -
765
+ |===
766
+
767
+ This cop enforces the test to use `refute_includes`
768
+ instead of using `refute(collection.include?(object))`.
769
+
770
+ === Examples
771
+
772
+ [source,ruby]
773
+ ----
774
+ # bad
775
+ refute(collection.include?(object))
776
+ refute(collection.include?(object), 'message')
777
+
778
+ # good
779
+ refute_includes(collection, object)
780
+ refute_includes(collection, object, 'message')
781
+ ----
782
+
783
+ === References
784
+
785
+ * https://minitest.rubystyle.guide#refute-includes
786
+
787
+ == Minitest/RefuteInstanceOf
788
+
789
+ |===
790
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
791
+
792
+ | Enabled
793
+ | Yes
794
+ | Yes
795
+ | 0.4
796
+ | -
797
+ |===
798
+
799
+ This cop enforces the use of `refute_instance_of(Class, object)`
800
+ over `refute(object.instance_of?(Class))`.
801
+
802
+ === Examples
803
+
804
+ [source,ruby]
805
+ ----
806
+ # bad
807
+ refute(object.instance_of?(Class))
808
+ refute(object.instance_of?(Class), 'message')
809
+
810
+ # good
811
+ refute_instance_of(Class, object)
812
+ refute_instance_of(Class, object, 'message')
813
+ ----
814
+
815
+ === References
816
+
817
+ * https://minitest.rubystyle.guide#refute-instance-of
818
+
819
+ == Minitest/RefuteKindOf
820
+
821
+ |===
822
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
823
+
824
+ | Pending
825
+ | Yes
826
+ | Yes
827
+ | 0.10
828
+ | -
829
+ |===
830
+
831
+ This cop enforces the use of `refute_kind_of(Class, object)`
832
+ over `refute(object.kind_of?(Class))`.
833
+
834
+ === Examples
835
+
836
+ [source,ruby]
837
+ ----
838
+ # bad
839
+ refute(object.kind_of?(Class))
840
+ refute(object.kind_of?(Class), 'message')
841
+
842
+ # good
843
+ refute_kind_of(Class, object)
844
+ refute_kind_of(Class, object, 'message')
845
+ ----
846
+
847
+ === References
848
+
849
+ * https://github.com/rubocop/minitest-style-guide#refute-kind-of
850
+
851
+ == Minitest/RefuteMatch
852
+
853
+ |===
854
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
855
+
856
+ | Enabled
857
+ | Yes
858
+ | Yes
859
+ | 0.6
860
+ | -
861
+ |===
862
+
863
+ This cop enforces the test to use `refute_match`
864
+ instead of using `refute(matcher.match(string))`.
865
+
866
+ === Examples
867
+
868
+ [source,ruby]
869
+ ----
870
+ # bad
871
+ refute(matcher.match(string))
872
+ refute(matcher.match(string), 'message')
873
+
874
+ # good
875
+ refute_match(matcher, string)
876
+ refute_match(matcher, string, 'message')
877
+ ----
878
+
879
+ === References
880
+
881
+ * https://minitest.rubystyle.guide#refute-match
882
+
883
+ == Minitest/RefuteNil
884
+
885
+ |===
886
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
887
+
888
+ | Enabled
889
+ | Yes
890
+ | Yes
891
+ | 0.2
892
+ | -
893
+ |===
894
+
895
+ This cop enforces the test to use `refute_nil`
896
+ instead of using `refute_equal(nil, something)`.
897
+
898
+ === Examples
899
+
900
+ [source,ruby]
901
+ ----
902
+ # bad
903
+ refute_equal(nil, actual)
904
+ refute_equal(nil, actual, 'message')
905
+
906
+ # good
907
+ refute_nil(actual)
908
+ refute_nil(actual, 'message')
909
+ ----
910
+
911
+ === References
912
+
913
+ * https://minitest.rubystyle.guide#refute-nil
914
+
915
+ == Minitest/RefutePathExists
916
+
917
+ |===
918
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
919
+
920
+ | Pending
921
+ | Yes
922
+ | Yes
923
+ | 0.10
924
+ | -
925
+ |===
926
+
927
+ This cop enforces the test to use `refute_path_exists`
928
+ instead of using `refute(File.exist?(path))`.
929
+
930
+ === Examples
931
+
932
+ [source,ruby]
933
+ ----
934
+ # bad
935
+ refute(File.exist?(path))
936
+ refute(File.exist?(path), 'message')
937
+
938
+ # good
939
+ refute_path_exists(path)
940
+ refute_path_exists(path, 'message')
941
+ ----
942
+
943
+ === References
944
+
945
+ * https://minitest.rubystyle.guide/#refute-path-exists
946
+
947
+ == Minitest/RefuteRespondTo
948
+
949
+ |===
950
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
951
+
952
+ | Enabled
953
+ | Yes
954
+ | Yes
955
+ | 0.4
956
+ | -
957
+ |===
958
+
959
+ This cop enforces the test to use `refute_respond_to(object, :do_something)`
960
+ over `refute(object.respond_to?(:do_something))`.
961
+
962
+ === Examples
963
+
964
+ [source,ruby]
965
+ ----
966
+ # bad
967
+ refute(object.respond_to?(:do_something))
968
+ refute(object.respond_to?(:do_something), 'message')
969
+ refute(respond_to?(:do_something))
970
+
971
+ # good
972
+ refute_respond_to(object, :do_something)
973
+ refute_respond_to(object, :do_something, 'message')
974
+ refute_respond_to(self, :do_something)
975
+ ----
976
+
977
+ === References
978
+
979
+ * https://minitest.rubystyle.guide#refute-respond-to
980
+
981
+ == Minitest/TestMethodName
982
+
983
+ |===
984
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
985
+
986
+ | Pending
987
+ | Yes
988
+ | Yes
989
+ | 0.10
990
+ | -
991
+ |===
992
+
993
+ This cop enforces that test method names start with `test_` prefix.
994
+ It aims to prevent tests that aren't executed by forgetting to start test method name with `test_`.
995
+
996
+ === Examples
997
+
998
+ [source,ruby]
999
+ ----
1000
+ # bad
1001
+ class FooTest < Minitest::Test
1002
+ def does_something
1003
+ assert_equal 42, do_something
1004
+ end
1005
+ end
1006
+
1007
+ # good
1008
+ class FooTest < Minitest::Test
1009
+ def test_does_something
1010
+ assert_equal 42, do_something
1011
+ end
1012
+ end
1013
+
1014
+ # good
1015
+ class FooTest < Minitest::Test
1016
+ def helper_method(argument)
1017
+ end
1018
+ end
1019
+ ----
1020
+
1021
+ == Minitest/UnspecifiedException
1022
+
1023
+ |===
1024
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
1025
+
1026
+ | Pending
1027
+ | Yes
1028
+ | No
1029
+ | 0.10
1030
+ | -
1031
+ |===
1032
+
1033
+ This cop checks for a specified error in `assert_raises`.
1034
+
1035
+ === Examples
1036
+
1037
+ [source,ruby]
1038
+ ----
1039
+ # bad
1040
+ assert_raises { raise FooException }
1041
+ assert_raises('This should have raised') { raise FooException }
1042
+
1043
+ # good
1044
+ assert_raises(FooException) { raise FooException }
1045
+ assert_raises(FooException, 'This should have raised') { raise FooException }
1046
+ ----
1047
+
1048
+ === References
1049
+
1050
+ * https://minitest.rubystyle.guide#unspecified-exception