minitest 5.12.0 → 5.22.2

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.
@@ -26,9 +26,8 @@ describe Minitest::Spec do
26
26
 
27
27
  msg = e.message.sub(/(---Backtrace---).*/m, '\1')
28
28
  msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
29
- msg.gsub!(/@.+>/, "@PATH>")
30
29
  msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
31
- msg.gsub!(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX")
30
+ msg.gsub!(/:0x[Xa-fA-F0-9]{4,}[ @].+?>/, ":0xXXXXXX@PATH>")
32
31
 
33
32
  if expected
34
33
  @assertion_count += 1
@@ -44,6 +43,10 @@ describe Minitest::Spec do
44
43
  end
45
44
  end
46
45
 
46
+ def assert_success spec
47
+ assert_equal true, spec
48
+ end
49
+
47
50
  before do
48
51
  @assertion_count = 4
49
52
  end
@@ -60,10 +63,30 @@ describe Minitest::Spec do
60
63
  end
61
64
  end
62
65
 
66
+ it "needs to check for file existence" do
67
+ @assertion_count = 3
68
+
69
+ assert_success _(__FILE__).path_must_exist
70
+
71
+ assert_triggered "Expected path 'blah' to exist." do
72
+ _("blah").path_must_exist
73
+ end
74
+ end
75
+
76
+ it "needs to check for file non-existence" do
77
+ @assertion_count = 3
78
+
79
+ assert_success _("blah").path_wont_exist
80
+
81
+ assert_triggered "Expected path '#{__FILE__}' to not exist." do
82
+ _(__FILE__).path_wont_exist
83
+ end
84
+ end
85
+
63
86
  it "needs to be sensible about must_include order" do
64
87
  @assertion_count += 3 # must_include is 2 assertions
65
88
 
66
- _(_([1, 2, 3]).must_include(2)).must_equal true
89
+ assert_success _([1, 2, 3]).must_include(2)
67
90
 
68
91
  assert_triggered "Expected [1, 2, 3] to include 5." do
69
92
  _([1, 2, 3]).must_include 5
@@ -77,7 +100,7 @@ describe Minitest::Spec do
77
100
  it "needs to be sensible about wont_include order" do
78
101
  @assertion_count += 3 # wont_include is 2 assertions
79
102
 
80
- _(_([1, 2, 3]).wont_include(5)).must_equal false
103
+ assert_success _([1, 2, 3]).wont_include(5)
81
104
 
82
105
  assert_triggered "Expected [1, 2, 3] to not include 2." do
83
106
  _([1, 2, 3]).wont_include 2
@@ -114,11 +137,51 @@ describe Minitest::Spec do
114
137
  end
115
138
  end
116
139
 
140
+ def good_pattern
141
+ capture_io do # 3.0 is noisy
142
+ eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
143
+ end
144
+ end
145
+
146
+ def bad_pattern
147
+ capture_io do # 3.0 is noisy
148
+ eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
149
+ end
150
+ end
151
+
152
+ it "needs to pattern match" do
153
+ @assertion_count = 1
154
+
155
+ if RUBY_VERSION > "3" then
156
+ expect { good_pattern }.must_pattern_match
157
+ else
158
+ assert_raises NotImplementedError do
159
+ expect {}.must_pattern_match
160
+ end
161
+ end
162
+ end
163
+
164
+ it "needs to error on bad pattern match" do
165
+ skip unless RUBY_VERSION > "3"
166
+
167
+ @assertion_count = 1
168
+
169
+ exp = if RUBY_VERSION.start_with? "3.0"
170
+ "[1, 2, 3]" # terrible error message!
171
+ else
172
+ /length mismatch/
173
+ end
174
+
175
+ assert_triggered exp do
176
+ expect { bad_pattern }.must_pattern_match
177
+ end
178
+ end
179
+
117
180
  it "needs to ensure silence" do
118
181
  @assertion_count -= 1 # no msg
119
182
  @assertion_count += 2 # assert_output is 2 assertions
120
183
 
121
- _(expect {}.must_be_silent).must_equal true
184
+ assert_success expect {}.must_be_silent
122
185
 
123
186
  assert_triggered "In stdout.\nExpected: \"\"\n Actual: \"xxx\"" do
124
187
  expect { print "xxx" }.must_be_silent
@@ -130,10 +193,10 @@ describe Minitest::Spec do
130
193
 
131
194
  @assertion_count = 2
132
195
 
133
- methods = Object.public_instance_methods.find_all { |n| n =~ /^must|^wont/ }
196
+ methods = Minitest::Expectations.public_instance_methods.grep(/must|wont/)
134
197
  methods.map!(&:to_s) if Symbol === methods.first
135
198
 
136
- musts, wonts = methods.sort.partition { |m| m =~ /^must/ }
199
+ musts, wonts = methods.sort.partition { |m| m =~ /must/ }
137
200
 
138
201
  expected_musts = %w[must_be
139
202
  must_be_close_to
@@ -149,13 +212,15 @@ describe Minitest::Spec do
149
212
  must_include
150
213
  must_match
151
214
  must_output
215
+ must_pattern_match
152
216
  must_raise
153
217
  must_respond_to
154
- must_throw]
218
+ must_throw
219
+ path_must_exist]
155
220
 
156
221
  bad = %w[not raise throw send output be_silent]
157
222
 
158
- expected_wonts = expected_musts.map { |m| m.sub(/^must/, "wont") }
223
+ expected_wonts = expected_musts.map { |m| m.sub(/must/, "wont") }.sort
159
224
  expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
160
225
 
161
226
  _(musts).must_equal expected_musts
@@ -175,7 +240,7 @@ describe Minitest::Spec do
175
240
  end
176
241
 
177
242
  it "needs to verify binary messages" do
178
- _(_(42).wont_be(:<, 24)).must_equal false
243
+ assert_success _(42).wont_be(:<, 24)
179
244
 
180
245
  assert_triggered "Expected 24 to not be < 42." do
181
246
  _(24).wont_be :<, 42
@@ -189,7 +254,7 @@ describe Minitest::Spec do
189
254
  it "needs to verify emptyness" do
190
255
  @assertion_count += 3 # empty is 2 assertions
191
256
 
192
- _(_([]).must_be_empty).must_equal true
257
+ assert_success _([]).must_be_empty
193
258
 
194
259
  assert_triggered "Expected [42] to be empty." do
195
260
  _([42]).must_be_empty
@@ -203,7 +268,7 @@ describe Minitest::Spec do
203
268
  it "needs to verify equality" do
204
269
  @assertion_count += 1
205
270
 
206
- _(_(6 * 7).must_equal(42)).must_equal true
271
+ assert_success _(6 * 7).must_equal(42)
207
272
 
208
273
  assert_triggered "Expected: 42\n Actual: 54" do
209
274
  _(6 * 9).must_equal 42
@@ -213,7 +278,7 @@ describe Minitest::Spec do
213
278
  _(6 * 9).must_equal 42, "msg"
214
279
  end
215
280
 
216
- assert_triggered(/^-42\n\+#<Proc:0xXXXXXX@PATH>\n/) do
281
+ assert_triggered(/^-42\n\+#<Proc:0xXXXXXX[ @]PATH>\n/) do
217
282
  _(proc { 42 }).must_equal 42 # proc isn't called, so expectation fails
218
283
  end
219
284
  end
@@ -222,7 +287,7 @@ describe Minitest::Spec do
222
287
  @assertion_count += 1 # extra test
223
288
 
224
289
  out, err = capture_io do
225
- _(_(nil).must_equal(nil)).must_equal true
290
+ assert_success _(nil).must_equal(nil)
226
291
  end
227
292
 
228
293
  exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
@@ -236,13 +301,13 @@ describe Minitest::Spec do
236
301
  it "needs to verify floats outside a delta" do
237
302
  @assertion_count += 1 # extra test
238
303
 
239
- _(_(24).wont_be_close_to(42)).must_equal false
304
+ assert_success _(24).wont_be_close_to(42)
240
305
 
241
306
  assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.001." do
242
307
  _(6 * 7.0).wont_be_close_to 42
243
308
  end
244
309
 
245
- x = maglev? ? "1.0000000000000001e-05" : "1.0e-05"
310
+ x = "1.0e-05"
246
311
  assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
247
312
  _(6 * 7.0).wont_be_close_to 42, 0.00001
248
313
  end
@@ -255,14 +320,14 @@ describe Minitest::Spec do
255
320
  it "needs to verify floats outside an epsilon" do
256
321
  @assertion_count += 1 # extra test
257
322
 
258
- _(_(24).wont_be_within_epsilon(42)).must_equal false
323
+ assert_success _(24).wont_be_within_epsilon(42)
259
324
 
260
- x = maglev? ? "0.042000000000000003" : "0.042"
325
+ x = "0.042"
261
326
  assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
262
327
  _(6 * 7.0).wont_be_within_epsilon 42
263
328
  end
264
329
 
265
- x = maglev? ? "0.00042000000000000002" : "0.00042"
330
+ x = "0.00042"
266
331
  assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
267
332
  _(6 * 7.0).wont_be_within_epsilon 42, 0.00001
268
333
  end
@@ -275,13 +340,13 @@ describe Minitest::Spec do
275
340
  it "needs to verify floats within a delta" do
276
341
  @assertion_count += 1 # extra test
277
342
 
278
- _(_(6.0 * 7).must_be_close_to(42.0)).must_equal true
343
+ assert_success _(6.0 * 7).must_be_close_to(42.0)
279
344
 
280
345
  assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.001." do
281
346
  _(1.0 / 100).must_be_close_to 0.0
282
347
  end
283
348
 
284
- x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
349
+ x = "1.0e-06"
285
350
  assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
286
351
  _(1.0 / 1000).must_be_close_to 0.0, 0.000001
287
352
  end
@@ -294,7 +359,7 @@ describe Minitest::Spec do
294
359
  it "needs to verify floats within an epsilon" do
295
360
  @assertion_count += 1 # extra test
296
361
 
297
- _(_(6.0 * 7).must_be_within_epsilon(42.0)).must_equal true
362
+ assert_success _(6.0 * 7).must_be_within_epsilon(42.0)
298
363
 
299
364
  assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.0." do
300
365
  _(1.0 / 100).must_be_within_epsilon 0.0
@@ -310,7 +375,7 @@ describe Minitest::Spec do
310
375
  end
311
376
 
312
377
  it "needs to verify identity" do
313
- _(_(1).must_be_same_as(1)).must_equal true
378
+ assert_success _(1).must_be_same_as(1)
314
379
 
315
380
  assert_triggered "Expected 1 (oid=N) to be the same as 2 (oid=N)." do
316
381
  _(1).must_be_same_as 2
@@ -323,8 +388,8 @@ describe Minitest::Spec do
323
388
 
324
389
  it "needs to verify inequality" do
325
390
  @assertion_count += 2
326
- _(_(42).wont_equal(6 * 9)).must_equal false
327
- _(_(proc {}).wont_equal(42)).must_equal false
391
+ assert_success _(42).wont_equal(6 * 9)
392
+ assert_success _(proc {}).wont_equal(42)
328
393
 
329
394
  assert_triggered "Expected 1 to not be equal to 1." do
330
395
  _(1).wont_equal 1
@@ -336,7 +401,7 @@ describe Minitest::Spec do
336
401
  end
337
402
 
338
403
  it "needs to verify instances of a class" do
339
- _(_(42).wont_be_instance_of(String)).must_equal false
404
+ assert_success _(42).wont_be_instance_of(String)
340
405
 
341
406
  assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
342
407
  _(42).wont_be_kind_of Int
@@ -350,8 +415,8 @@ describe Minitest::Spec do
350
415
  it "needs to verify kinds of a class" do
351
416
  @assertion_count += 2
352
417
 
353
- _(_(42).wont_be_kind_of(String)).must_equal false
354
- _(_(proc {}).wont_be_kind_of(String)).must_equal false
418
+ assert_success _(42).wont_be_kind_of(String)
419
+ assert_success _(proc {}).wont_be_kind_of(String)
355
420
 
356
421
  assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
357
422
  _(42).wont_be_kind_of Int
@@ -365,8 +430,8 @@ describe Minitest::Spec do
365
430
  it "needs to verify kinds of objects" do
366
431
  @assertion_count += 3 # extra test
367
432
 
368
- _(_(6 * 7).must_be_kind_of(Int)).must_equal true
369
- _(_(6 * 7).must_be_kind_of(Numeric)).must_equal true
433
+ assert_success _(6 * 7).must_be_kind_of(Int)
434
+ assert_success _(6 * 7).must_be_kind_of(Numeric)
370
435
 
371
436
  assert_triggered "Expected 42 to be a kind of String, not #{Int.name}." do
372
437
  _(6 * 7).must_be_kind_of String
@@ -385,7 +450,7 @@ describe Minitest::Spec do
385
450
  it "needs to verify mismatch" do
386
451
  @assertion_count += 3 # match is 2
387
452
 
388
- _(_("blah").wont_match(/\d+/)).must_equal false
453
+ assert_success _("blah").wont_match(/\d+/)
389
454
 
390
455
  assert_triggered "Expected /\\w+/ to not match \"blah\"." do
391
456
  _("blah").wont_match(/\w+/)
@@ -397,7 +462,7 @@ describe Minitest::Spec do
397
462
  end
398
463
 
399
464
  it "needs to verify nil" do
400
- _(_(nil).must_be_nil).must_equal true
465
+ assert_success _(nil).must_be_nil
401
466
 
402
467
  assert_triggered "Expected 42 to be nil." do
403
468
  _(42).must_be_nil
@@ -411,7 +476,7 @@ describe Minitest::Spec do
411
476
  it "needs to verify non-emptyness" do
412
477
  @assertion_count += 3 # empty is 2 assertions
413
478
 
414
- _(_(["some item"]).wont_be_empty).must_equal false
479
+ assert_success _(["some item"]).wont_be_empty
415
480
 
416
481
  assert_triggered "Expected [] to not be empty." do
417
482
  _([]).wont_be_empty
@@ -423,7 +488,7 @@ describe Minitest::Spec do
423
488
  end
424
489
 
425
490
  it "needs to verify non-identity" do
426
- _(_(1).wont_be_same_as(2)).must_equal false
491
+ assert_success _(1).wont_be_same_as(2)
427
492
 
428
493
  assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
429
494
  _(1).wont_be_same_as 1
@@ -435,7 +500,7 @@ describe Minitest::Spec do
435
500
  end
436
501
 
437
502
  it "needs to verify non-nil" do
438
- _(_(42).wont_be_nil).must_equal false
503
+ assert_success _(42).wont_be_nil
439
504
 
440
505
  assert_triggered "Expected nil to not be nil." do
441
506
  _(nil).wont_be_nil
@@ -447,7 +512,7 @@ describe Minitest::Spec do
447
512
  end
448
513
 
449
514
  it "needs to verify objects not responding to a message" do
450
- _(_("").wont_respond_to(:woot!)).must_equal false
515
+ assert_success _("").wont_respond_to(:woot!)
451
516
 
452
517
  assert_triggered "Expected \"\" to not respond to to_s." do
453
518
  _("").wont_respond_to :to_s
@@ -461,7 +526,7 @@ describe Minitest::Spec do
461
526
  it "needs to verify output in stderr" do
462
527
  @assertion_count -= 1 # no msg
463
528
 
464
- _(expect { $stderr.print "blah" }.must_output(nil, "blah")).must_equal true
529
+ assert_success expect { $stderr.print "blah" }.must_output(nil, "blah")
465
530
 
466
531
  assert_triggered "In stderr.\nExpected: \"blah\"\n Actual: \"xxx\"" do
467
532
  expect { $stderr.print "xxx" }.must_output(nil, "blah")
@@ -471,7 +536,7 @@ describe Minitest::Spec do
471
536
  it "needs to verify output in stdout" do
472
537
  @assertion_count -= 1 # no msg
473
538
 
474
- _(expect { print "blah" }.must_output("blah")).must_equal true
539
+ assert_success expect { print "blah" }.must_output("blah")
475
540
 
476
541
  assert_triggered "In stdout.\nExpected: \"blah\"\n Actual: \"xxx\"" do
477
542
  expect { print "xxx" }.must_output("blah")
@@ -481,7 +546,7 @@ describe Minitest::Spec do
481
546
  it "needs to verify regexp matches" do
482
547
  @assertion_count += 3 # must_match is 2 assertions
483
548
 
484
- _(_("blah").must_match(/\w+/)).must_equal true
549
+ assert_kind_of MatchData, _("blah").must_match(/\w+/)
485
550
 
486
551
  assert_triggered "Expected /\\d+/ to match \"blah\"." do
487
552
  _("blah").must_match(/\d+/)
@@ -547,12 +612,29 @@ describe Minitest::Spec do
547
612
  (1 + 1).must_equal 2
548
613
  end
549
614
  end
615
+
616
+ # https://github.com/seattlerb/minitest/issues/837
617
+ # https://github.com/rails/rails/pull/39304
618
+ it "deprecates expectation used without _ with empty backtrace_filter" do
619
+ skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
620
+
621
+ @assertion_count += 3
622
+
623
+ exp = /DEPRECATED: global use of must_equal from/
624
+
625
+ with_empty_backtrace_filter do
626
+ assert_output "", exp do
627
+ (1 + 1).must_equal 2
628
+ end
629
+ end
630
+ end
550
631
  end
551
632
 
552
633
  it "needs to verify throw" do
553
- @assertion_count += 2 # 2 extra tests
634
+ @assertion_count += 4 # 2 extra tests
554
635
 
555
- _(expect { throw :blah }.must_throw(:blah)).must_equal true
636
+ assert_nil expect { throw :blah }.must_throw(:blah)
637
+ assert_equal 42, expect { throw :blah, 42 }.must_throw(:blah)
556
638
 
557
639
  assert_triggered "Expected :blah to have been thrown." do
558
640
  expect {}.must_throw :blah
@@ -572,7 +654,7 @@ describe Minitest::Spec do
572
654
  end
573
655
 
574
656
  it "needs to verify types of objects" do
575
- _(_(6 * 7).must_be_instance_of(Int)).must_equal true
657
+ assert_success _(6 * 7).must_be_instance_of(Int)
576
658
 
577
659
  exp = "Expected 42 to be an instance of String, not #{Int.name}."
578
660
 
@@ -588,7 +670,7 @@ describe Minitest::Spec do
588
670
  it "needs to verify using any (negative) predicate" do
589
671
  @assertion_count -= 1 # doesn"t take a message
590
672
 
591
- _(_("blah").wont_be(:empty?)).must_equal false
673
+ assert_success _("blah").wont_be(:empty?)
592
674
 
593
675
  assert_triggered "Expected \"\" to not be empty?." do
594
676
  _("").wont_be :empty?
@@ -598,7 +680,7 @@ describe Minitest::Spec do
598
680
  it "needs to verify using any binary operator" do
599
681
  @assertion_count -= 1 # no msg
600
682
 
601
- _(_(41).must_be(:<, 42)).must_equal true
683
+ assert_success _(41).must_be(:<, 42)
602
684
 
603
685
  assert_triggered "Expected 42 to be < 41." do
604
686
  _(42).must_be(:<, 41)
@@ -608,7 +690,7 @@ describe Minitest::Spec do
608
690
  it "needs to verify using any predicate" do
609
691
  @assertion_count -= 1 # no msg
610
692
 
611
- _(_("").must_be(:empty?)).must_equal true
693
+ assert_success _("").must_be(:empty?)
612
694
 
613
695
  assert_triggered "Expected \"blah\" to be empty?." do
614
696
  _("blah").must_be :empty?
@@ -616,7 +698,7 @@ describe Minitest::Spec do
616
698
  end
617
699
 
618
700
  it "needs to verify using respond_to" do
619
- _(_(42).must_respond_to(:+)).must_equal true
701
+ assert_success _(42).must_respond_to(:+)
620
702
 
621
703
  assert_triggered "Expected 42 (#{Int.name}) to respond to #clear." do
622
704
  _(42).must_respond_to :clear
@@ -703,6 +785,10 @@ describe Minitest::Spec, :subject do
703
785
  end
704
786
 
705
787
  class TestMetaStatic < Minitest::Test
788
+ def assert_method_count expected, klass
789
+ assert_equal expected, klass.public_instance_methods.grep(/^test_/).count
790
+ end
791
+
706
792
  def test_children
707
793
  Minitest::Spec.children.clear # prevents parallel run
708
794
 
@@ -736,8 +822,8 @@ class TestMetaStatic < Minitest::Test
736
822
  end
737
823
  end
738
824
 
739
- assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
740
- assert_equal 1, inner.public_instance_methods.grep(/^test_/).count
825
+ assert_method_count 1, outer
826
+ assert_method_count 1, inner
741
827
  end
742
828
 
743
829
  def test_it_wont_add_test_methods_to_children
@@ -751,14 +837,18 @@ class TestMetaStatic < Minitest::Test
751
837
  end
752
838
  end
753
839
 
754
- assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
755
- assert_equal 0, inner.public_instance_methods.grep(/^test_/).count
840
+ assert_method_count 1, outer
841
+ assert_method_count 0, inner
756
842
  end
757
843
  end
758
844
 
759
845
  class TestMeta < MetaMetaMetaTestCase
760
846
  # do not call parallelize_me! here because specs use register_spec_type globally
761
847
 
848
+ def assert_defined_methods expected, klass
849
+ assert_equal expected, klass.instance_methods(false).sort.map(&:to_s)
850
+ end
851
+
762
852
  def util_structure
763
853
  y = z = nil
764
854
  before_list = []
@@ -831,7 +921,7 @@ class TestMeta < MetaMetaMetaTestCase
831
921
  end
832
922
  end
833
923
 
834
- test_name = spec_class.instance_methods.sort.grep(/test/).first
924
+ test_name = spec_class.instance_methods.sort.grep(/test_/).first
835
925
 
836
926
  spec = spec_class.new test_name
837
927
 
@@ -880,9 +970,9 @@ class TestMeta < MetaMetaMetaTestCase
880
970
  inner_methods2 = inner_methods1 +
881
971
  %w[test_0002_anonymous test_0003_anonymous]
882
972
 
883
- assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
884
- assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
885
- assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s)
973
+ assert_defined_methods top_methods, x
974
+ assert_defined_methods inner_methods1, y
975
+ assert_defined_methods inner_methods2, z
886
976
  end
887
977
 
888
978
  def test_structure_postfix_it
@@ -899,8 +989,8 @@ class TestMeta < MetaMetaMetaTestCase
899
989
  it "inner-it" do end
900
990
  end
901
991
 
902
- assert_equal %w[test_0001_inner-it], y.instance_methods(false).map(&:to_s)
903
- assert_equal %w[test_0001_inner-it], z.instance_methods(false).map(&:to_s)
992
+ assert_defined_methods %w[test_0001_inner-it], y
993
+ assert_defined_methods %w[test_0001_inner-it], z
904
994
  end
905
995
 
906
996
  def test_setup_teardown_behavior
@@ -931,9 +1021,9 @@ class TestMeta < MetaMetaMetaTestCase
931
1021
  ].sort
932
1022
 
933
1023
  assert_equal test_methods, [x1, x2]
934
- assert_equal test_methods, x.instance_methods.grep(/^test/).map(&:to_s).sort
935
- assert_equal [], y.instance_methods.grep(/^test/)
936
- assert_equal [], z.instance_methods.grep(/^test/)
1024
+ assert_defined_methods test_methods, x
1025
+ assert_defined_methods [], y
1026
+ assert_defined_methods [], z
937
1027
  end
938
1028
 
939
1029
  def test_structure_subclasses
@@ -1019,3 +1109,38 @@ class ValueMonadTest < Minitest::Test
1019
1109
  assert_equal "c", struct.expect
1020
1110
  end
1021
1111
  end
1112
+
1113
+ describe Minitest::Spec, :infect_an_assertion do
1114
+ class << self
1115
+ attr_accessor :infect_mock
1116
+ end
1117
+
1118
+ def assert_infects exp, act, msg = nil, foo: nil, bar: nil
1119
+ self.class.infect_mock.assert_infects exp, act, msg, foo: foo, bar: bar
1120
+ end
1121
+
1122
+ infect_an_assertion :assert_infects, :must_infect
1123
+ infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
1124
+
1125
+ it "infects assertions with kwargs" do
1126
+ mock = Minitest::Mock.new
1127
+ mock.expect :assert_infects, true, [:exp, :act, nil], foo: :foo, bar: :bar
1128
+
1129
+ self.class.infect_mock = mock
1130
+
1131
+ _(:act).must_infect :exp, foo: :foo, bar: :bar
1132
+
1133
+ assert_mock mock
1134
+ end
1135
+
1136
+ it "infects assertions with kwargs (dont_flip)" do
1137
+ mock = Minitest::Mock.new
1138
+ mock.expect :assert_infects, true, [:act, :exp, nil], foo: :foo, bar: :bar
1139
+
1140
+ self.class.infect_mock = mock
1141
+
1142
+ _(:act).must_infect_without_flipping :exp, foo: :foo, bar: :bar
1143
+
1144
+ assert_mock mock
1145
+ end
1146
+ end