rubocop-minitest 0.10.1 → 0.12.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +18 -3
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +5 -1
  4. data/.rubocop.yml +5 -1
  5. data/.rubocop_todo.yml +8 -7
  6. data/CHANGELOG.md +95 -50
  7. data/CONTRIBUTING.md +3 -3
  8. data/Gemfile +2 -2
  9. data/LICENSE.txt +1 -1
  10. data/README.md +18 -2
  11. data/Rakefile +1 -1
  12. data/bin/console +2 -0
  13. data/config/default.yml +15 -4
  14. data/docs/antora.yml +1 -1
  15. data/docs/modules/ROOT/pages/cops.adoc +14 -1
  16. data/docs/modules/ROOT/pages/cops_minitest.adoc +79 -8
  17. data/docs/modules/ROOT/pages/index.adoc +1 -1
  18. data/legacy-docs/cops_minitest.md +16 -16
  19. data/legacy-docs/index.md +1 -1
  20. data/lib/rubocop/cop/minitest/assert_empty.rb +1 -1
  21. data/lib/rubocop/cop/minitest/assert_empty_literal.rb +12 -16
  22. data/lib/rubocop/cop/minitest/assert_equal.rb +1 -1
  23. data/lib/rubocop/cop/minitest/assert_in_delta.rb +4 -1
  24. data/lib/rubocop/cop/minitest/assert_includes.rb +1 -1
  25. data/lib/rubocop/cop/minitest/assert_instance_of.rb +1 -1
  26. data/lib/rubocop/cop/minitest/assert_kind_of.rb +1 -1
  27. data/lib/rubocop/cop/minitest/assert_match.rb +1 -1
  28. data/lib/rubocop/cop/minitest/assert_nil.rb +5 -11
  29. data/lib/rubocop/cop/minitest/assert_output.rb +1 -1
  30. data/lib/rubocop/cop/minitest/assert_path_exists.rb +6 -12
  31. data/lib/rubocop/cop/minitest/assert_respond_to.rb +1 -1
  32. data/lib/rubocop/cop/minitest/assert_silent.rb +8 -6
  33. data/lib/rubocop/cop/minitest/assert_truthy.rb +5 -11
  34. data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +41 -0
  35. data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +1 -1
  36. data/lib/rubocop/cop/minitest/global_expectations.rb +6 -7
  37. data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +15 -14
  38. data/lib/rubocop/cop/minitest/multiple_assertions.rb +2 -2
  39. data/lib/rubocop/cop/minitest/no_assertions.rb +48 -0
  40. data/lib/rubocop/cop/minitest/refute_empty.rb +1 -1
  41. data/lib/rubocop/cop/minitest/refute_equal.rb +7 -8
  42. data/lib/rubocop/cop/minitest/refute_false.rb +15 -22
  43. data/lib/rubocop/cop/minitest/refute_in_delta.rb +4 -1
  44. data/lib/rubocop/cop/minitest/refute_includes.rb +1 -1
  45. data/lib/rubocop/cop/minitest/refute_instance_of.rb +1 -1
  46. data/lib/rubocop/cop/minitest/refute_kind_of.rb +1 -1
  47. data/lib/rubocop/cop/minitest/refute_match.rb +1 -1
  48. data/lib/rubocop/cop/minitest/refute_nil.rb +4 -8
  49. data/lib/rubocop/cop/minitest/refute_path_exists.rb +6 -12
  50. data/lib/rubocop/cop/minitest/refute_respond_to.rb +1 -1
  51. data/lib/rubocop/cop/minitest/test_method_name.rb +18 -8
  52. data/lib/rubocop/cop/minitest/unspecified_exception.rb +1 -1
  53. data/lib/rubocop/cop/minitest_cops.rb +2 -0
  54. data/lib/rubocop/cop/mixin/in_delta_mixin.rb +5 -15
  55. data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +13 -13
  56. data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +27 -3
  57. data/lib/rubocop/minitest/version.rb +8 -1
  58. data/mkdocs.yml +2 -2
  59. data/relnotes/v0.1.0.md +1 -1
  60. data/relnotes/v0.10.0.md +12 -12
  61. data/relnotes/v0.10.1.md +1 -1
  62. data/relnotes/v0.10.2.md +5 -0
  63. data/relnotes/v0.10.3.md +5 -0
  64. data/relnotes/v0.11.0.md +16 -0
  65. data/relnotes/v0.11.1.md +5 -0
  66. data/relnotes/v0.12.0.md +10 -0
  67. data/relnotes/v0.2.0.md +4 -4
  68. data/relnotes/v0.2.1.md +1 -1
  69. data/relnotes/v0.3.0.md +6 -6
  70. data/relnotes/v0.4.0.md +5 -5
  71. data/relnotes/v0.4.1.md +1 -1
  72. data/relnotes/v0.5.0.md +1 -1
  73. data/relnotes/v0.5.1.md +1 -1
  74. data/relnotes/v0.6.0.md +1 -1
  75. data/relnotes/v0.6.1.md +2 -2
  76. data/relnotes/v0.6.2.md +1 -1
  77. data/relnotes/v0.7.0.md +5 -5
  78. data/relnotes/v0.8.0.md +4 -4
  79. data/relnotes/v0.8.1.md +1 -1
  80. data/relnotes/v0.9.0.md +3 -3
  81. data/rubocop-minitest.gemspec +7 -7
  82. data/tasks/cops_documentation.rake +24 -304
  83. metadata +28 -15
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
@@ -15,7 +15,7 @@ Minitest/AssertEmptyLiteral:
15
15
  Enabled: true
16
16
  SafeAutoCorrect: false
17
17
  VersionAdded: '0.5'
18
- VersionChanged: '0.10'
18
+ VersionChanged: '0.11'
19
19
 
20
20
  Minitest/AssertEqual:
21
21
  Description: 'This cop enforces the test to use `assert_equal` instead of using `assert(expected == actual)`.'
@@ -54,7 +54,7 @@ Minitest/AssertInstanceOf:
54
54
 
55
55
  Minitest/AssertKindOf:
56
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-hq/minitest-style-guide#assert-kind-of'
57
+ StyleGuide: 'https://github.com/rubocop/minitest-style-guide#assert-kind-of'
58
58
  Enabled: 'pending'
59
59
  VersionAdded: '0.10'
60
60
 
@@ -84,7 +84,7 @@ Minitest/AssertRespondTo:
84
84
 
85
85
  Minitest/AssertSilent:
86
86
  Description: "This cop enforces the test to use `assert_silent { ... }` instead of using `assert_output('', '') { ... }`."
87
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-silent'
87
+ StyleGuide: 'https://github.com/rubocop/minitest-style-guide#assert-silent'
88
88
  Enabled: 'pending'
89
89
  VersionAdded: '0.10'
90
90
 
@@ -94,6 +94,12 @@ Minitest/AssertTruthy:
94
94
  Enabled: true
95
95
  VersionAdded: '0.2'
96
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
+ Safe: false
101
+ VersionAdded: '0.11'
102
+
97
103
  Minitest/GlobalExpectations:
98
104
  Description: 'This cop checks for deprecated global expectations.'
99
105
  StyleGuide: 'https://minitest.rubystyle.guide#global-expectations'
@@ -112,6 +118,11 @@ Minitest/MultipleAssertions:
112
118
  VersionAdded: '0.10'
113
119
  Max: 3
114
120
 
121
+ Minitest/NoAssertions:
122
+ Description: 'This cop checks for at least one assertion (or flunk) in tests.'
123
+ Enabled: false
124
+ VersionAdded: '0.12'
125
+
115
126
  Minitest/RefuteEmpty:
116
127
  Description: 'This cop enforces to use `refute_empty` instead of using `refute(object.empty?)`.'
117
128
  StyleGuide: 'https://minitest.rubystyle.guide#refute-empty'
@@ -156,7 +167,7 @@ Minitest/RefuteInstanceOf:
156
167
 
157
168
  Minitest/RefuteKindOf:
158
169
  Description: 'This cop enforces the test to use `refute_kind_of(Class, object)` over `refute(object.kind_of?(Class))`.'
159
- StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#refute-kind-of'
170
+ StyleGuide: 'https://github.com/rubocop/minitest-style-guide#refute-kind-of'
160
171
  Enabled: 'pending'
161
172
  VersionAdded: '0.10'
162
173
 
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.10'
5
+ version: '0.12'
6
6
  nav:
7
7
  - modules/ROOT/nav.adoc
@@ -1,6 +1,17 @@
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
+
1
12
  // START_COP_LIST
2
13
 
3
- = Department xref:cops_minitest.adoc[Minitest]
14
+ === Department xref:cops_minitest.adoc[Minitest]
4
15
 
5
16
  * xref:cops_minitest.adoc#minitestassertempty[Minitest/AssertEmpty]
6
17
  * xref:cops_minitest.adoc#minitestassertemptyliteral[Minitest/AssertEmptyLiteral]
@@ -16,10 +27,12 @@
16
27
  * xref:cops_minitest.adoc#minitestassertrespondto[Minitest/AssertRespondTo]
17
28
  * xref:cops_minitest.adoc#minitestassertsilent[Minitest/AssertSilent]
18
29
  * xref:cops_minitest.adoc#minitestasserttruthy[Minitest/AssertTruthy]
30
+ * xref:cops_minitest.adoc#minitestassertwithexpectedargument[Minitest/AssertWithExpectedArgument]
19
31
  * xref:cops_minitest.adoc#minitestassertioninlifecyclehook[Minitest/AssertionInLifecycleHook]
20
32
  * xref:cops_minitest.adoc#minitestglobalexpectations[Minitest/GlobalExpectations]
21
33
  * xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument]
22
34
  * xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions]
35
+ * xref:cops_minitest.adoc#minitestnoassertions[Minitest/NoAssertions]
23
36
  * xref:cops_minitest.adoc#minitestrefuteempty[Minitest/RefuteEmpty]
24
37
  * xref:cops_minitest.adoc#minitestrefuteequal[Minitest/RefuteEqual]
25
38
  * xref:cops_minitest.adoc#minitestrefutefalse[Minitest/RefuteFalse]
@@ -41,19 +41,19 @@ assert_empty(object, 'message')
41
41
  | Yes
42
42
  | Yes (Unsafe)
43
43
  | 0.5
44
- | 0.10
44
+ | 0.11
45
45
  |===
46
46
 
47
47
  This cop enforces the test to use `assert_empty`
48
- instead of using `assert([], object)`.
48
+ instead of using `assert_equal([], object)`.
49
49
 
50
50
  === Examples
51
51
 
52
52
  [source,ruby]
53
53
  ----
54
54
  # bad
55
- assert([], object)
56
- assert({}, object)
55
+ assert_equal([], object)
56
+ assert_equal({}, object)
57
57
 
58
58
  # good
59
59
  assert_empty(object)
@@ -215,7 +215,7 @@ assert_kind_of(Class, object, 'message')
215
215
 
216
216
  === References
217
217
 
218
- * https://github.com/rubocop-hq/minitest-style-guide#assert-kind-of
218
+ * https://github.com/rubocop/minitest-style-guide#assert-kind-of
219
219
 
220
220
  == Minitest/AssertMatch
221
221
 
@@ -407,7 +407,7 @@ assert_silent { puts object.do_something }
407
407
 
408
408
  === References
409
409
 
410
- * https://github.com/rubocop-hq/minitest-style-guide#assert-silent
410
+ * https://github.com/rubocop/minitest-style-guide#assert-silent
411
411
 
412
412
  == Minitest/AssertTruthy
413
413
 
@@ -441,6 +441,38 @@ assert(actual, 'message')
441
441
 
442
442
  * https://minitest.rubystyle.guide#assert-truthy
443
443
 
444
+ == Minitest/AssertWithExpectedArgument
445
+
446
+ |===
447
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
448
+
449
+ | Pending
450
+ | No
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
+ It is marked as unsafe because it is not possible to determine
460
+ whether the second argument of `assert` is a message or not.
461
+
462
+ === Examples
463
+
464
+ [source,ruby]
465
+ ----
466
+ # bad
467
+ assert(3, my_list.length)
468
+ assert(expected, actual)
469
+
470
+ # good
471
+ assert_equal(3, my_list.length)
472
+ assert_equal(expected, actual)
473
+ assert(foo, 'message')
474
+ ----
475
+
444
476
  == Minitest/AssertionInLifecycleHook
445
477
 
446
478
  |===
@@ -593,6 +625,38 @@ end
593
625
  | Integer
594
626
  |===
595
627
 
628
+ == Minitest/NoAssertions
629
+
630
+ |===
631
+ | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
632
+
633
+ | Disabled
634
+ | Yes
635
+ | No
636
+ | 0.12
637
+ | -
638
+ |===
639
+
640
+ This cop checks if test cases contain any assertion calls.
641
+
642
+ === Examples
643
+
644
+ [source,ruby]
645
+ ----
646
+ # bad
647
+ class FooTest < Minitest::Test
648
+ def test_the_truth
649
+ end
650
+ end
651
+
652
+ # good
653
+ class FooTest < Minitest::Test
654
+ def test_the_truth
655
+ assert true
656
+ end
657
+ end
658
+ ----
659
+
596
660
  == Minitest/RefuteEmpty
597
661
 
598
662
  |===
@@ -638,7 +702,7 @@ refute_empty(object, 'message')
638
702
  |===
639
703
 
640
704
  This cop enforces the use of `refute_equal(expected, object)`
641
- over `assert_equal(expected != actual)` or `assert(! expected == actual)`.
705
+ over `assert(expected != actual)` or `assert(! expected == actual)`.
642
706
 
643
707
  === Examples
644
708
 
@@ -817,7 +881,7 @@ refute_kind_of(Class, object, 'message')
817
881
 
818
882
  === References
819
883
 
820
- * https://github.com/rubocop-hq/minitest-style-guide#refute-kind-of
884
+ * https://github.com/rubocop/minitest-style-guide#refute-kind-of
821
885
 
822
886
  == Minitest/RefuteMatch
823
887
 
@@ -962,6 +1026,7 @@ refute_respond_to(self, :do_something)
962
1026
  |===
963
1027
 
964
1028
  This cop enforces that test method names start with `test_` prefix.
1029
+ It aims to prevent tests that aren't executed by forgetting to start test method name with `test_`.
965
1030
 
966
1031
  === Examples
967
1032
 
@@ -980,6 +1045,12 @@ class FooTest < Minitest::Test
980
1045
  assert_equal 42, do_something
981
1046
  end
982
1047
  end
1048
+
1049
+ # good
1050
+ class FooTest < Minitest::Test
1051
+ def helper_method(argument)
1052
+ end
1053
+ end
983
1054
  ----
984
1055
 
985
1056
  == Minitest/UnspecifiedException
@@ -1,5 +1,5 @@
1
1
  = RuboCop Minitest
2
2
 
3
- A https://github.com/rubocop-hq/rubocop[RuboCop] extension focused on enforcing Minitest best practices and coding conventions.
3
+ A https://github.com/rubocop/rubocop[RuboCop] extension focused on enforcing Minitest best practices and coding conventions.
4
4
 
5
5
  It's based on the community-driven https://minitest.rubystyle.guide[Minitest style guide].
@@ -23,7 +23,7 @@ assert_empty(object, 'message')
23
23
 
24
24
  ### References
25
25
 
26
- * [https://github.com/rubocop-hq/minitest-style-guide#assert-empty](https://github.com/rubocop-hq/minitest-style-guide#assert-empty)
26
+ * [https://github.com/rubocop/minitest-style-guide#assert-empty](https://github.com/rubocop/minitest-style-guide#assert-empty)
27
27
 
28
28
  ## Minitest/AssertEmptyLiteral
29
29
 
@@ -66,7 +66,7 @@ assert_equal("rubocop-minitest", actual)
66
66
 
67
67
  ### References
68
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)
69
+ * [https://github.com/rubocop/minitest-style-guide#assert-equal-arguments-order](https://github.com/rubocop/minitest-style-guide#assert-equal-arguments-order)
70
70
 
71
71
  ## Minitest/AssertIncludes
72
72
 
@@ -91,7 +91,7 @@ assert_includes(collection, object, 'message')
91
91
 
92
92
  ### References
93
93
 
94
- * [https://github.com/rubocop-hq/minitest-style-guide#assert-includes](https://github.com/rubocop-hq/minitest-style-guide#assert-includes)
94
+ * [https://github.com/rubocop/minitest-style-guide#assert-includes](https://github.com/rubocop/minitest-style-guide#assert-includes)
95
95
 
96
96
  ## Minitest/AssertInstanceOf
97
97
 
@@ -116,7 +116,7 @@ assert_instance_of(Class, object, 'message')
116
116
 
117
117
  ### References
118
118
 
119
- * [https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of](https://github.com/rubocop-hq/minitest-style-guide#assert-instance-of)
119
+ * [https://github.com/rubocop/minitest-style-guide#assert-instance-of](https://github.com/rubocop/minitest-style-guide#assert-instance-of)
120
120
 
121
121
  ## Minitest/AssertMatch
122
122
 
@@ -141,7 +141,7 @@ assert_match(matcher, string, 'message')
141
141
 
142
142
  ### References
143
143
 
144
- * [https://github.com/rubocop-hq/minitest-style-guide#assert-match](https://github.com/rubocop-hq/minitest-style-guide#assert-match)
144
+ * [https://github.com/rubocop/minitest-style-guide#assert-match](https://github.com/rubocop/minitest-style-guide#assert-match)
145
145
 
146
146
  ## Minitest/AssertNil
147
147
 
@@ -166,7 +166,7 @@ assert_nil(actual, 'message')
166
166
 
167
167
  ### References
168
168
 
169
- * [https://github.com/rubocop-hq/minitest-style-guide#assert-nil](https://github.com/rubocop-hq/minitest-style-guide#assert-nil)
169
+ * [https://github.com/rubocop/minitest-style-guide#assert-nil](https://github.com/rubocop/minitest-style-guide#assert-nil)
170
170
 
171
171
  ## Minitest/AssertRespondTo
172
172
 
@@ -193,7 +193,7 @@ assert_respond_to(self, :do_something)
193
193
 
194
194
  ### References
195
195
 
196
- * [https://github.com/rubocop-hq/minitest-style-guide#assert-responds-to-method](https://github.com/rubocop-hq/minitest-style-guide#assert-responds-to-method)
196
+ * [https://github.com/rubocop/minitest-style-guide#assert-responds-to-method](https://github.com/rubocop/minitest-style-guide#assert-responds-to-method)
197
197
 
198
198
  ## Minitest/AssertTruthy
199
199
 
@@ -218,7 +218,7 @@ assert(actual, 'message')
218
218
 
219
219
  ### References
220
220
 
221
- * [https://github.com/rubocop-hq/minitest-style-guide#assert-truthy](https://github.com/rubocop-hq/minitest-style-guide#assert-truthy)
221
+ * [https://github.com/rubocop/minitest-style-guide#assert-truthy](https://github.com/rubocop/minitest-style-guide#assert-truthy)
222
222
 
223
223
  ## Minitest/GlobalExpectations
224
224
 
@@ -266,7 +266,7 @@ refute_empty(object, 'message')
266
266
 
267
267
  ### References
268
268
 
269
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-empty](https://github.com/rubocop-hq/minitest-style-guide#refute-empty)
269
+ * [https://github.com/rubocop/minitest-style-guide#refute-empty](https://github.com/rubocop/minitest-style-guide#refute-empty)
270
270
 
271
271
  ## Minitest/RefuteEqual
272
272
 
@@ -290,7 +290,7 @@ refute_equal("rubocop-minitest", actual)
290
290
 
291
291
  ### References
292
292
 
293
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-equal](https://github.com/rubocop-hq/minitest-style-guide#refute-equal)
293
+ * [https://github.com/rubocop/minitest-style-guide#refute-equal](https://github.com/rubocop/minitest-style-guide#refute-equal)
294
294
 
295
295
  ## Minitest/RefuteFalse
296
296
 
@@ -318,7 +318,7 @@ refute(actual, 'message')
318
318
 
319
319
  ### References
320
320
 
321
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-false](https://github.com/rubocop-hq/minitest-style-guide#refute-false)
321
+ * [https://github.com/rubocop/minitest-style-guide#refute-false](https://github.com/rubocop/minitest-style-guide#refute-false)
322
322
 
323
323
  ## Minitest/RefuteIncludes
324
324
 
@@ -343,7 +343,7 @@ refute_includes(collection, object, 'message')
343
343
 
344
344
  ### References
345
345
 
346
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-includes](https://github.com/rubocop-hq/minitest-style-guide#refute-includes)
346
+ * [https://github.com/rubocop/minitest-style-guide#refute-includes](https://github.com/rubocop/minitest-style-guide#refute-includes)
347
347
 
348
348
  ## Minitest/RefuteInstanceOf
349
349
 
@@ -368,7 +368,7 @@ refute_instance_of(Class, object, 'message')
368
368
 
369
369
  ### References
370
370
 
371
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of](https://github.com/rubocop-hq/minitest-style-guide#refute-instance-of)
371
+ * [https://github.com/rubocop/minitest-style-guide#refute-instance-of](https://github.com/rubocop/minitest-style-guide#refute-instance-of)
372
372
 
373
373
  ## Minitest/RefuteMatch
374
374
 
@@ -393,7 +393,7 @@ refute_match(matcher, string, 'message')
393
393
 
394
394
  ### References
395
395
 
396
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-match](https://github.com/rubocop-hq/minitest-style-guide#refute-match)
396
+ * [https://github.com/rubocop/minitest-style-guide#refute-match](https://github.com/rubocop/minitest-style-guide#refute-match)
397
397
 
398
398
  ## Minitest/RefuteNil
399
399
 
@@ -418,7 +418,7 @@ refute_nil(actual, 'message')
418
418
 
419
419
  ### References
420
420
 
421
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-nil](https://github.com/rubocop-hq/minitest-style-guide#refute-nil)
421
+ * [https://github.com/rubocop/minitest-style-guide#refute-nil](https://github.com/rubocop/minitest-style-guide#refute-nil)
422
422
 
423
423
  ## Minitest/RefuteRespondTo
424
424
 
@@ -445,4 +445,4 @@ refute_respond_to(self, :do_something)
445
445
 
446
446
  ### References
447
447
 
448
- * [https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to](https://github.com/rubocop-hq/minitest-style-guide#refute-respond-to)
448
+ * [https://github.com/rubocop/minitest-style-guide#refute-respond-to](https://github.com/rubocop/minitest-style-guide#refute-respond-to)
data/legacy-docs/index.md CHANGED
@@ -1 +1 @@
1
- A [RuboCop](https://github.com/rubocop-hq/rubocop) extension focused on enforcing Minitest best practices and coding conventions.
1
+ A [RuboCop](https://github.com/rubocop/rubocop) extension focused on enforcing Minitest best practices and coding conventions.
@@ -15,7 +15,7 @@ module RuboCop
15
15
  # assert_empty(object)
16
16
  # assert_empty(object, 'message')
17
17
  #
18
- class AssertEmpty < Cop
18
+ class AssertEmpty < Base
19
19
  extend MinitestCopRule
20
20
 
21
21
  define_rule :assert, target_method: :empty?
@@ -4,42 +4,38 @@ module RuboCop
4
4
  module Cop
5
5
  module Minitest
6
6
  # This cop enforces the test to use `assert_empty`
7
- # instead of using `assert([], object)`.
7
+ # instead of using `assert_equal([], object)`.
8
8
  #
9
9
  # @example
10
10
  # # bad
11
- # assert([], object)
12
- # assert({}, object)
11
+ # assert_equal([], object)
12
+ # assert_equal({}, object)
13
13
  #
14
14
  # # good
15
15
  # assert_empty(object)
16
16
  #
17
- class AssertEmptyLiteral < Cop
17
+ class AssertEmptyLiteral < Base
18
18
  include ArgumentRangeHelper
19
+ extend AutoCorrector
19
20
 
20
21
  MSG = 'Prefer using `assert_empty(%<arguments>s)` over ' \
21
- '`assert(%<literal>s, %<arguments>s)`.'
22
+ '`assert_equal(%<literal>s, %<arguments>s)`.'
23
+ RESTRICT_ON_SEND = %i[assert_equal].freeze
22
24
 
23
- def_node_matcher :assert_with_empty_literal, <<~PATTERN
24
- (send nil? :assert ${hash array} $...)
25
+ def_node_matcher :assert_equal_with_empty_literal, <<~PATTERN
26
+ (send nil? :assert_equal ${hash array} $...)
25
27
  PATTERN
26
28
 
27
29
  def on_send(node)
28
- assert_with_empty_literal(node) do |literal, matchers|
30
+ assert_equal_with_empty_literal(node) do |literal, matchers|
29
31
  return unless literal.values.empty?
30
32
 
31
33
  args = matchers.map(&:source).join(', ')
32
34
 
33
35
  message = format(MSG, literal: literal.source, arguments: args)
34
- add_offense(node, message: message)
35
- end
36
- end
37
-
38
- def autocorrect(node)
39
- assert_with_empty_literal(node) do |_literal, matchers|
40
- object = matchers.first
36
+ add_offense(node, message: message) do |corrector|
37
+ object = matchers.first
41
38
 
42
- lambda do |corrector|
43
39
  corrector.replace(node.loc.selector, 'assert_empty')
44
40
  corrector.replace(first_and_second_arguments_range(node), object.source)
45
41
  end