rubocop-minitest 0.2.0 → 0.5.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.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Minitest
5
- VERSION = '0.2.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -2,9 +2,19 @@
2
2
  #### Department [Minitest](cops_minitest.md)
3
3
 
4
4
  * [Minitest/AssertEmpty](cops_minitest.md#minitestassertempty)
5
+ * [Minitest/AssertEmptyLiteral](cops_minitest.md#minitestassertemptyliteral)
6
+ * [Minitest/AssertEqual](cops_minitest.md#minitestassertequal)
5
7
  * [Minitest/AssertIncludes](cops_minitest.md#minitestassertincludes)
8
+ * [Minitest/AssertInstanceOf](cops_minitest.md#minitestassertinstanceof)
6
9
  * [Minitest/AssertNil](cops_minitest.md#minitestassertnil)
10
+ * [Minitest/AssertRespondTo](cops_minitest.md#minitestassertrespondto)
7
11
  * [Minitest/AssertTruthy](cops_minitest.md#minitestasserttruthy)
12
+ * [Minitest/RefuteEmpty](cops_minitest.md#minitestrefuteempty)
13
+ * [Minitest/RefuteEqual](cops_minitest.md#minitestrefuteequal)
14
+ * [Minitest/RefuteFalse](cops_minitest.md#minitestrefutefalse)
15
+ * [Minitest/RefuteIncludes](cops_minitest.md#minitestrefuteincludes)
16
+ * [Minitest/RefuteInstanceOf](cops_minitest.md#minitestrefuteinstanceof)
8
17
  * [Minitest/RefuteNil](cops_minitest.md#minitestrefutenil)
18
+ * [Minitest/RefuteRespondTo](cops_minitest.md#minitestrefuterespondto)
9
19
 
10
20
  <!-- END_COP_LIST -->
@@ -6,56 +6,126 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChan
6
6
  --- | --- | --- | --- | ---
7
7
  Enabled | Yes | Yes | 0.2 | -
8
8
 
9
- Check if your test uses `assert_empty` instead of `assert(actual.empty?)`.
9
+ This cop enforces the test to use `assert_empty`
10
+ instead of using `assert(object.empty?)`.
10
11
 
11
12
  ### Examples
12
13
 
13
14
  ```ruby
14
15
  # bad
15
- assert(actual.empty?)
16
- assert(actual.empty?, 'the message')
16
+ assert(object.empty?)
17
+ assert(object.empty?, 'the message')
17
18
 
18
19
  # good
19
- assert_empty(actual)
20
- assert_empty(actual, 'the message')
20
+ assert_empty(object)
21
+ assert_empty(object, 'the message')
21
22
  ```
22
23
 
23
24
  ### References
24
25
 
25
26
  * [https://github.com/rubocop-hq/minitest-style-guide#assert-empty](https://github.com/rubocop-hq/minitest-style-guide#assert-empty)
26
27
 
28
+ ## Minitest/AssertEmptyLiteral
29
+
30
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
31
+ --- | --- | --- | --- | ---
32
+ Enabled | Yes | No | 0.5 | -
33
+
34
+ This cop enforces the test to use `assert_empty`
35
+ instead of using `assert([], object)`.
36
+
37
+ ### Examples
38
+
39
+ ```ruby
40
+ # bad
41
+ assert([], object)
42
+ assert({}, object)
43
+
44
+ # good
45
+ assert_empty(object)
46
+ ```
47
+
48
+ ## Minitest/AssertEqual
49
+
50
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
51
+ --- | --- | --- | --- | ---
52
+ Enabled | Yes | Yes | 0.4 | -
53
+
54
+ This cop enforces the use of `assert_equal(expected, actual)`
55
+ over `assert(expected == actual)`.
56
+
57
+ ### Examples
58
+
59
+ ```ruby
60
+ # bad
61
+ assert("rubocop-minitest" == actual)
62
+
63
+ # good
64
+ assert_equal("rubocop-minitest", actual)
65
+ ```
66
+
67
+ ### References
68
+
69
+ * [https://github.com/rubocop-hq/minitest-style-guide#assert-equal-arguments-order](https://github.com/rubocop-hq/minitest-style-guide#assert-equal-arguments-order)
70
+
27
71
  ## Minitest/AssertIncludes
28
72
 
29
73
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
30
74
  --- | --- | --- | --- | ---
31
75
  Enabled | Yes | Yes | 0.2 | -
32
76
 
33
- Check if your test uses `assert_includes`
34
- instead of `assert(collection.includes?(actual))`.
77
+ This cop enforces the test to use `assert_includes`
78
+ instead of using `assert(collection.include?(object))`.
35
79
 
36
80
  ### Examples
37
81
 
38
82
  ```ruby
39
83
  # bad
40
- assert(collection.includes?(actual))
41
- assert(collection.includes?(actual), 'the message')
84
+ assert(collection.include?(object))
85
+ assert(collection.include?(object), 'the message')
42
86
 
43
87
  # good
44
- assert_includes(collection, actual)
45
- assert_includes(collection, actual, 'the message')
88
+ assert_includes(collection, object)
89
+ assert_includes(collection, object, 'the message')
46
90
  ```
47
91
 
48
92
  ### References
49
93
 
50
94
  * [https://github.com/rubocop-hq/minitest-style-guide#assert-includes](https://github.com/rubocop-hq/minitest-style-guide#assert-includes)
51
95
 
96
+ ## Minitest/AssertInstanceOf
97
+
98
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
99
+ --- | --- | --- | --- | ---
100
+ Enabled | Yes | Yes | 0.4 | -
101
+
102
+ This cop enforces the test to use `assert_instance_of(Class, object)`
103
+ over `assert(object.instance_of?(Class))`.
104
+
105
+ ### Examples
106
+
107
+ ```ruby
108
+ # bad
109
+ assert(object.instance_of?(Class))
110
+ assert(object.instance_of?(Class), 'the message')
111
+
112
+ # good
113
+ assert_instance_of(Class, object)
114
+ assert_instance_of(Class, object, 'the message')
115
+ ```
116
+
117
+ ### References
118
+
119
+ * [https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of](https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of)
120
+
52
121
  ## Minitest/AssertNil
53
122
 
54
123
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
55
124
  --- | --- | --- | --- | ---
56
125
  Enabled | Yes | Yes | 0.1 | -
57
126
 
58
- Check if your test uses `assert_nil` instead of `assert_equal(nil, something)`.
127
+ This cop enforces the test to use `assert_nil`
128
+ instead of using `assert_equal(nil, something)`.
59
129
 
60
130
  ### Examples
61
131
 
@@ -73,14 +143,41 @@ assert_nil(actual, 'the message')
73
143
 
74
144
  * [https://github.com/rubocop-hq/minitest-style-guide#assert-nil](https://github.com/rubocop-hq/minitest-style-guide#assert-nil)
75
145
 
146
+ ## Minitest/AssertRespondTo
147
+
148
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
149
+ --- | --- | --- | --- | ---
150
+ Enabled | Yes | Yes | 0.3 | -
151
+
152
+ This cop enforces the use of `assert_respond_to(object, :some_method)`
153
+ over `assert(object.respond_to?(:some_method))`.
154
+
155
+ ### Examples
156
+
157
+ ```ruby
158
+ # bad
159
+ assert(object.respond_to?(:some_method))
160
+ assert(object.respond_to?(:some_method), 'the message')
161
+ assert(respond_to?(:some_method))
162
+
163
+ # good
164
+ assert_respond_to(object, :some_method)
165
+ assert_respond_to(object, :some_method, 'the message')
166
+ assert_respond_to(self, some_method)
167
+ ```
168
+
169
+ ### References
170
+
171
+ * [https://github.com/rubocop-hq/minitest-style-guide#assert-responds-to-method](https://github.com/rubocop-hq/minitest-style-guide#assert-responds-to-method)
172
+
76
173
  ## Minitest/AssertTruthy
77
174
 
78
175
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
79
176
  --- | --- | --- | --- | ---
80
177
  Enabled | Yes | Yes | 0.2 | -
81
178
 
82
- Check if your test uses `assert(actual)`
83
- instead of `assert_equal(true, actual)`.
179
+ This cop enforces the test to use `assert(actual)`
180
+ instead of using `assert_equal(true, actual)`.
84
181
 
85
182
  ### Examples
86
183
 
@@ -98,13 +195,138 @@ assert(actual, 'the message')
98
195
 
99
196
  * [https://github.com/rubocop-hq/minitest-style-guide#assert-truthy](https://github.com/rubocop-hq/minitest-style-guide#assert-truthy)
100
197
 
198
+ ## Minitest/RefuteEmpty
199
+
200
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
201
+ --- | --- | --- | --- | ---
202
+ Enabled | Yes | Yes | 0.3 | -
203
+
204
+ This cop enforces to use `refute_empty` instead of
205
+ using `refute(object.empty?)`.
206
+
207
+ ### Examples
208
+
209
+ ```ruby
210
+ # bad
211
+ refute(object.empty?)
212
+ refute(object.empty?, 'the message')
213
+
214
+ # good
215
+ refute_empty(object)
216
+ refute_empty(object, 'the message')
217
+ ```
218
+
219
+ ### References
220
+
221
+ * [https://github.com/rubocop-hq/minitest-style-guide#refute-empty](https://github.com/rubocop-hq/minitest-style-guide#refute-empty)
222
+
223
+ ## Minitest/RefuteEqual
224
+
225
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
226
+ --- | --- | --- | --- | ---
227
+ Enabled | Yes | Yes | 0.3 | -
228
+
229
+ This cop enforces the use of `refute_equal(expected, object)`
230
+ over `assert_equal(expected != actual)` or `assert(! expected == actual)`.
231
+
232
+ ### Examples
233
+
234
+ ```ruby
235
+ # bad
236
+ assert("rubocop-minitest" != actual)
237
+ assert(! "rubocop-minitest" == actual)
238
+
239
+ # good
240
+ refute_equal("rubocop-minitest", actual)
241
+ ```
242
+
243
+ ### References
244
+
245
+ * [https://github.com/rubocop-hq/minitest-style-guide#refute-equal](https://github.com/rubocop-hq/minitest-style-guide#refute-equal)
246
+
247
+ ## Minitest/RefuteFalse
248
+
249
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
250
+ --- | --- | --- | --- | ---
251
+ Enabled | Yes | Yes | 0.3 | -
252
+
253
+ This cop enforces the use of `refute(object)`
254
+ over `assert_equal(false, object)`.
255
+
256
+ ### Examples
257
+
258
+ ```ruby
259
+ # bad
260
+ assert_equal(false, actual)
261
+ assert_equal(false, actual, 'the message')
262
+
263
+ # good
264
+ refute(actual)
265
+ refute(actual, 'the message')
266
+ ```
267
+
268
+ ### References
269
+
270
+ * [https://github.com/rubocop-hq/minitest-style-guide#refute-false](https://github.com/rubocop-hq/minitest-style-guide#refute-false)
271
+
272
+ ## Minitest/RefuteIncludes
273
+
274
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
275
+ --- | --- | --- | --- | ---
276
+ Enabled | Yes | Yes | 0.3 | -
277
+
278
+ This cop enforces the test to use `refute_includes`
279
+ instead of using `refute(collection.include?(object))`.
280
+
281
+ ### Examples
282
+
283
+ ```ruby
284
+ # bad
285
+ refute(collection.include?(object))
286
+ refute(collection.include?(object), 'the message')
287
+
288
+ # good
289
+ refute_includes(collection, object)
290
+ refute_includes(collection, object, 'the message')
291
+ ```
292
+
293
+ ### References
294
+
295
+ * [https://github.com/rubocop-hq/minitest-style-guide#refute-includes](https://github.com/rubocop-hq/minitest-style-guide#refute-includes)
296
+
297
+ ## Minitest/RefuteInstanceOf
298
+
299
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
300
+ --- | --- | --- | --- | ---
301
+ Enabled | Yes | Yes | 0.4 | -
302
+
303
+ This cop enforces the use of `refute_instance_of(Class, object)`
304
+ over `refute(object.instance_of?(Class))`.
305
+
306
+ ### Examples
307
+
308
+ ```ruby
309
+ # bad
310
+ refute(object.instance_of?(Class))
311
+ refute(object.instance_of?(Class), 'the message')
312
+
313
+ # good
314
+ refute_instance_of(Class, object)
315
+ refute_instance_of(Class, object, 'the message')
316
+ ```
317
+
318
+ ### References
319
+
320
+ * [https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of](https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of)
321
+
101
322
  ## Minitest/RefuteNil
102
323
 
103
324
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
104
325
  --- | --- | --- | --- | ---
105
326
  Enabled | Yes | Yes | 0.2 | -
106
327
 
107
- Check if your test uses `refute_nil` instead of `refute_equal(nil, something)`.
328
+ This cop enforces the test to use `refute_nil`
329
+ instead of using `refute_equal(nil, something)`.
108
330
 
109
331
  ### Examples
110
332
 
@@ -121,3 +343,30 @@ refute_nil(actual, 'the message')
121
343
  ### References
122
344
 
123
345
  * [https://github.com/rubocop-hq/minitest-style-guide#refute-nil](https://github.com/rubocop-hq/minitest-style-guide#refute-nil)
346
+
347
+ ## Minitest/RefuteRespondTo
348
+
349
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
350
+ --- | --- | --- | --- | ---
351
+ Enabled | Yes | Yes | 0.4 | -
352
+
353
+ This cop enforces the test to use `refute_respond_to(object, :some_method)`
354
+ over `refute(object.respond_to?(:some_method))`.
355
+
356
+ ### Examples
357
+
358
+ ```ruby
359
+ # bad
360
+ refute(object.respond_to?(:some_method))
361
+ refute(object.respond_to?(:some_method), 'the message')
362
+ refute(respond_to?(:some_method))
363
+
364
+ # good
365
+ refute_respond_to(object, :some_method)
366
+ refute_respond_to(object, :some_method, 'the message')
367
+ refute_respond_to(self, :some_method)
368
+ ```
369
+
370
+ ### References
371
+
372
+ * [https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to](https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to)
@@ -0,0 +1,7 @@
1
+ ### New features
2
+
3
+ * Create RuboCop Minitest gem. ([@koic][])
4
+ * [#6](https://github.com/rubocop-hq/rubocop-minitest/pull/6): Add new `Minitest/AssertNil` cop. ([@duduribeiro ][])
5
+
6
+ [@koic]: https://github.com/koic
7
+ [@duduribeiro]: https://github.com/duduribeiro
@@ -0,0 +1,9 @@
1
+ ### New features
2
+
3
+ * [#11](https://github.com/rubocop-hq/rubocop-minitest/pull/11): Add new `Minitest/RefuteNil` cop. ([@tejasbubane ][])
4
+ * [#8](https://github.com/rubocop-hq/rubocop-minitest/pull/8): Add new `Minitest/AssertTruthy` cop. ([@abhaynikam ][])
5
+ * [#9](https://github.com/rubocop-hq/rubocop-minitest/pull/9): Add new `Minitest/AssertIncludes` cop. ([@abhaynikam ][])
6
+ * [#10](https://github.com/rubocop-hq/rubocop-minitest/pull/10): Add new `Minitest/AssertEmpty` cop. ([@abhaynikam ][])
7
+
8
+ [@tejasbubane]: https://github.com/tejasbubane
9
+ [@abhaynikam]: https://github.com/abhaynikam
@@ -0,0 +1,5 @@
1
+ ### Bug fixes
2
+
3
+ * [#13](https://github.com/rubocop-hq/rubocop-minitest/issues/13): Fix the execution target specified in `Include` parameter. ([@koic][])
4
+
5
+ [@koic]: https://github.com/koic
@@ -0,0 +1,16 @@
1
+ ## 0.3.0 (2019-10-13)
2
+
3
+ ### New features
4
+
5
+ * [#15](https://github.com/rubocop-hq/rubocop-minitest/pull/15): Add new `Minitest/RefuteIncludes` cop. ([@abhaynikam][])
6
+ * [#18](https://github.com/rubocop-hq/rubocop-minitest/pull/18): Add new `Minitest/RefuteFalse` cop. ([@duduribeiro][])
7
+ * [#20](https://github.com/rubocop-hq/rubocop-minitest/pull/20): Add new `Minitest/RefuteEmpty` cop. ([@abhaynikam][])
8
+ * [#21](https://github.com/rubocop-hq/rubocop-minitest/pull/21): Add new `Minitest/RefuteEqual` cop. ([@duduribeiro][])
9
+ * [#27](https://github.com/rubocop-hq/rubocop-minitest/pull/27): Add new `Minitest/AssertRespondTo` cop. ([@duduribeiro][])
10
+
11
+ ### Bug fixes
12
+
13
+ * [#19](https://github.com/rubocop-hq/rubocop-minitest/pull/19): Fix a false negative for `Minitest/AssertIncludes` when using `include` method in arguments of `assert` method. ([@abhaynikam][])
14
+
15
+ [@abhaynikam]: https://github.com/abhaynikam
16
+ [@duduribeiro]: https://github.com/duduribeiro
@@ -0,0 +1,14 @@
1
+ ### New features
2
+
3
+ * [#29](https://github.com/rubocop-hq/rubocop-minitest/pull/29): Add new `Minitest/RefuteRespondTo` cop. ([@herwinw][])
4
+ * [#31](https://github.com/rubocop-hq/rubocop-minitest/pull/31): Add new `Minitest/AssertEqual` cop. ([@herwinw][])
5
+ * [#34](https://github.com/rubocop-hq/rubocop-minitest/pull/34): Add new `Minitest/AssertInstanceOf` cop. ([@abhaynikam][])
6
+ * [#35](https://github.com/rubocop-hq/rubocop-minitest/pull/35): Add new `Minitest/RefuteInstanceOf` cop. ([@abhaynikam][])
7
+
8
+ ### Bug fixes
9
+
10
+ * [#25](https://github.com/rubocop-hq/rubocop-minitest/issues/25): Add `Enabled: true` to `Minitest` department config to suppress `Warning: Minitest does not support Enabled parameter`. ([@koic][])
11
+
12
+ [@herwinw]: https://github.com/herwinw
13
+ [@abhaynikam]: https://github.com/abhaynikam
14
+ [@koic]: https://github.com/koic
@@ -0,0 +1,5 @@
1
+ ### Bug fixes
2
+
3
+ * [#39](https://github.com/rubocop-hq/rubocop-minitest/issues/39): Fix an incorrect autocorrect for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo` when using assertion method calling `respond_to` with receiver omitted. ([@koic][])
4
+
5
+ [@koic]: https://github.com/koic
@@ -0,0 +1,5 @@
1
+ ### New features
2
+
3
+ * [#32](https://github.com/rubocop-hq/rubocop-minitest/issues/32): Add new `Minitest/AssertEmptyLiteral` cop. ([@tejasbubane][])
4
+
5
+ [@tejasbubane]: https://github.com/tejasbubane