minitest 5.20.0 → 5.24.1

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.
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require "minitest/autorun"
4
+ require_relative "metametameta"
4
5
 
5
6
  if defined? Encoding then
6
7
  e = Encoding.default_external
@@ -33,7 +34,6 @@ class TestMinitestAssertions < Minitest::Test
33
34
 
34
35
  class DummyTest
35
36
  include Minitest::Assertions
36
- # include Minitest::Reportable # TODO: why do I really need this?
37
37
 
38
38
  attr_accessor :assertions, :failure
39
39
 
@@ -58,15 +58,6 @@ class TestMinitestAssertions < Minitest::Test
58
58
  "expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}")
59
59
  end
60
60
 
61
- def assert_deprecated name
62
- dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+(?::.*)?/
63
- dep = "" if $-w.nil?
64
-
65
- assert_output nil, dep do
66
- yield
67
- end
68
- end
69
-
70
61
  def assert_triggered expected, klass = Minitest::Assertion
71
62
  e = assert_raises klass do
72
63
  yield
@@ -301,7 +292,7 @@ class TestMinitestAssertions < Minitest::Test
301
292
  err_re = /Use assert_nil if expecting nil from .*test_minitest_\w+.rb/
302
293
  err_re = "" if $-w.nil?
303
294
 
304
- assert_output "", err_re do
295
+ assert_deprecation err_re do
305
296
  @tc.assert_equal nil, nil
306
297
  end
307
298
  end
@@ -379,7 +370,7 @@ class TestMinitestAssertions < Minitest::Test
379
370
  EOM
380
371
 
381
372
  assert_triggered msg do
382
- x = "bad-utf8-\xF1.txt".force_encoding "ASCII"
373
+ x = "bad-utf8-\xF1.txt".dup.force_encoding Encoding::ASCII
383
374
  y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
384
375
  @tc.assert_equal x, y
385
376
  end
@@ -762,12 +753,13 @@ class TestMinitestAssertions < Minitest::Test
762
753
  Class: <SomeError>
763
754
  Message: <\"blah\">
764
755
  ---Backtrace---
765
- FILE:LINE:in \`block in test_assert_raises_default_triggered\'
756
+ FILE:LINE:in \'block in test_assert_raises_default_triggered\'
766
757
  ---------------
767
758
  EOM
768
759
 
769
760
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
770
761
  actual.gsub!(RE_LEVELS, "") unless jruby?
762
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
771
763
 
772
764
  assert_equal expected, actual
773
765
  end
@@ -841,12 +833,13 @@ class TestMinitestAssertions < Minitest::Test
841
833
  Class: <AnError>
842
834
  Message: <\"some message\">
843
835
  ---Backtrace---
844
- FILE:LINE:in \`block in test_assert_raises_subclass_triggered\'
836
+ FILE:LINE:in \'block in test_assert_raises_subclass_triggered\'
845
837
  ---------------
846
838
  EOM
847
839
 
848
840
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
849
841
  actual.gsub!(RE_LEVELS, "") unless jruby?
842
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
850
843
 
851
844
  assert_equal expected.chomp, actual
852
845
  end
@@ -863,12 +856,13 @@ class TestMinitestAssertions < Minitest::Test
863
856
  Class: <SyntaxError>
864
857
  Message: <\"icky\">
865
858
  ---Backtrace---
866
- FILE:LINE:in \`block in test_assert_raises_triggered_different\'
859
+ FILE:LINE:in \'block in test_assert_raises_triggered_different\'
867
860
  ---------------
868
861
  EOM
869
862
 
870
863
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
871
864
  actual.gsub!(RE_LEVELS, "") unless jruby?
865
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
872
866
 
873
867
  assert_equal expected, actual
874
868
  end
@@ -886,12 +880,13 @@ class TestMinitestAssertions < Minitest::Test
886
880
  Class: <SyntaxError>
887
881
  Message: <\"icky\">
888
882
  ---Backtrace---
889
- FILE:LINE:in \`block in test_assert_raises_triggered_different_msg\'
883
+ FILE:LINE:in \'block in test_assert_raises_triggered_different_msg\'
890
884
  ---------------
891
885
  EOM
892
886
 
893
887
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
894
888
  actual.gsub!(RE_LEVELS, "") unless jruby?
889
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
895
890
 
896
891
  assert_equal expected.chomp, actual
897
892
  end
@@ -936,6 +931,16 @@ class TestMinitestAssertions < Minitest::Test
936
931
  end
937
932
  end
938
933
 
934
+ def test_assert_respond_to__include_all
935
+ @tc.assert_respond_to @tc, :exit, include_all: true
936
+ end
937
+
938
+ def test_assert_respond_to__include_all_triggered
939
+ assert_triggered(/Expected .+::DummyTest. to respond to #exit\?/) do
940
+ @tc.assert_respond_to @tc, :exit?, include_all: true
941
+ end
942
+ end
943
+
939
944
  def test_assert_same
940
945
  @assertion_count = 3
941
946
 
@@ -952,8 +957,8 @@ class TestMinitestAssertions < Minitest::Test
952
957
  @tc.assert_same 1, 2
953
958
  end
954
959
 
955
- s1 = "blah"
956
- s2 = "blah"
960
+ s1 = +"blah"
961
+ s2 = +"blah"
957
962
 
958
963
  assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
959
964
  @tc.assert_same s1, s2
@@ -961,16 +966,24 @@ class TestMinitestAssertions < Minitest::Test
961
966
  end
962
967
 
963
968
  def test_assert_send
964
- assert_deprecated :assert_send do
969
+ @assertion_count = 0 if error_on_warn?
970
+ assert_deprecation(/DEPRECATED: assert_send/) do
965
971
  @tc.assert_send [1, :<, 2]
966
972
  end
967
973
  end
968
974
 
969
975
  def test_assert_send_bad
970
- assert_deprecated :assert_send do
971
- assert_triggered "Expected 1.>(*[2]) to return true." do
976
+ if error_on_warn? then
977
+ @assertion_count = 0
978
+ assert_deprecation(/DEPRECATED: assert_send/) do
972
979
  @tc.assert_send [1, :>, 2]
973
980
  end
981
+ else
982
+ assert_triggered "Expected 1.>(*[2]) to return true." do
983
+ assert_deprecation(/DEPRECATED: assert_send/) do
984
+ @tc.assert_send [1, :>, 2]
985
+ end
986
+ end
974
987
  end
975
988
  end
976
989
 
@@ -1153,18 +1166,14 @@ class TestMinitestAssertions < Minitest::Test
1153
1166
  def test_class_asserts_match_refutes
1154
1167
  @assertion_count = 0
1155
1168
 
1156
- methods = Minitest::Assertions.public_instance_methods
1157
- methods.map!(&:to_s) if Symbol === methods.first
1169
+ methods = Minitest::Assertions.public_instance_methods.map(&:to_s)
1158
1170
 
1159
1171
  # These don't have corresponding refutes _on purpose_. They're
1160
1172
  # useless and will never be added, so don't bother.
1161
1173
  ignores = %w[assert_output assert_raises assert_send
1162
1174
  assert_silent assert_throws assert_mock]
1163
1175
 
1164
- # These are test/unit methods. I'm not actually sure why they're still here
1165
- ignores += %w[assert_no_match assert_not_equal assert_not_nil
1166
- assert_not_same assert_nothing_raised
1167
- assert_nothing_thrown assert_raise]
1176
+ ignores += %w[assert_allocations] # for minitest-gcstats
1168
1177
 
1169
1178
  asserts = methods.grep(/^assert/).sort - ignores
1170
1179
  refutes = methods.grep(/^refute/).sort - ignores
@@ -1444,6 +1453,16 @@ class TestMinitestAssertions < Minitest::Test
1444
1453
  end
1445
1454
  end
1446
1455
 
1456
+ def test_refute_respond_to__include_all
1457
+ @tc.refute_respond_to "blah", :missing, include_all: true
1458
+ end
1459
+
1460
+ def test_refute_respond_to__include_all_triggered
1461
+ assert_triggered(/Expected .*DummyTest.* to not respond to exit./) do
1462
+ @tc.refute_respond_to @tc, :exit, include_all: true
1463
+ end
1464
+ end
1465
+
1447
1466
  def test_refute_same
1448
1467
  @tc.refute_same 1, 2
1449
1468
  end
@@ -1482,7 +1501,7 @@ class TestMinitestAssertions < Minitest::Test
1482
1501
  d0 = Time.now
1483
1502
  d1 = d0 + 86_400 # I am an idiot
1484
1503
 
1485
- assert_output "", /Stale skip_until \"not yet\" at .*?:\d+$/ do
1504
+ assert_deprecation(/Stale skip_until \"not yet\" at .*?:\d+$/) do
1486
1505
  assert_skip_until d0, "not yet"
1487
1506
  end
1488
1507
 
@@ -1626,14 +1645,14 @@ class TestMinitestAssertionHelpers < Minitest::Test
1626
1645
  end
1627
1646
 
1628
1647
  def test_mu_pp_for_diff_str_bad_encoding
1629
- str = "\666".force_encoding Encoding::UTF_8
1648
+ str = "\666".dup.force_encoding Encoding::UTF_8
1630
1649
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1631
1650
 
1632
1651
  assert_mu_pp_for_diff exp, str, :raw
1633
1652
  end
1634
1653
 
1635
1654
  def test_mu_pp_for_diff_str_bad_encoding_both
1636
- str = "\666A\\n\nB".force_encoding Encoding::UTF_8
1655
+ str = "\666A\\n\nB".dup.force_encoding Encoding::UTF_8
1637
1656
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6A\\\\n\\nB\""
1638
1657
 
1639
1658
  assert_mu_pp_for_diff exp, str, :raw
@@ -1680,7 +1699,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
1680
1699
  end
1681
1700
 
1682
1701
  def test_mu_pp_str_bad_encoding
1683
- str = "\666".force_encoding Encoding::UTF_8
1702
+ str = "\666".dup.force_encoding Encoding::UTF_8
1684
1703
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1685
1704
 
1686
1705
  assert_mu_pp exp, str, :raw
@@ -423,10 +423,12 @@ class TestMinitestMock < Minitest::Test
423
423
  arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
424
424
  mock = Minitest::Mock.new
425
425
 
426
- assert_output nil, /Using MT_KWARGS_HAC. yet passing kwargs/ do
426
+ assert_deprecation(/Using MT_KWARGS_HAC. yet passing kwargs/) do
427
427
  mock.expect :foo, nil, [{}], k1: arg1, k2: arg2, k3: arg3
428
428
  end
429
429
 
430
+ skip "-Werror" if error_on_warn? # mock above raised, so this is dead
431
+
430
432
  mock.foo({}, k1: arg1, k2: arg2, k3: arg3)
431
433
 
432
434
  assert_mock mock
@@ -686,7 +688,7 @@ class TestMinitestStub < Minitest::Test
686
688
  end
687
689
 
688
690
  def test_stub_yield_self
689
- obj = "foo"
691
+ obj = +"foo"
690
692
 
691
693
  val = obj.stub :to_s, "bar" do |s|
692
694
  s.to_s
@@ -728,7 +730,7 @@ class TestMinitestStub < Minitest::Test
728
730
  end
729
731
 
730
732
  exp = jruby? ? /Undefined method nope_nope_nope for '#{self.class}::Time'/ :
731
- /undefined method `nope_nope_nope' for( class)? `#{self.class}::Time'/
733
+ /undefined method [`']nope_nope_nope' for( class)? [`']#{self.class}::Time'/
732
734
  assert_match exp, e.message
733
735
  end
734
736
 
@@ -816,7 +818,7 @@ class TestMinitestStub < Minitest::Test
816
818
  # [:value, :block_call, :args] => N/A
817
819
 
818
820
  class Bar
819
- def call
821
+ def call(&_) # to ignore unused block
820
822
  puts "hi"
821
823
  end
822
824
  end
@@ -956,7 +958,7 @@ class TestMinitestStub < Minitest::Test
956
958
  def test_stub_lambda_block_call_5
957
959
  @assertion_count += 1
958
960
  rs = nil
959
- io = StringIO.new "", "w"
961
+ io = StringIO.new(+"", "w")
960
962
  File.stub5 :open, lambda { |p, m, &blk| blk and blk.call io } do
961
963
  File.open "foo.txt", "r" do |f|
962
964
  rs = f && f.write("woot")
@@ -971,7 +973,7 @@ class TestMinitestStub < Minitest::Test
971
973
 
972
974
  @assertion_count += 1
973
975
  rs = nil
974
- io = StringIO.new "", "w"
976
+ io = StringIO.new(+"", "w")
975
977
  File.stub6 :open, lambda { |p, m, &blk| blk.call io } do
976
978
  File.open "foo.txt", "r" do |f|
977
979
  rs = f.write("woot")
@@ -984,7 +986,7 @@ class TestMinitestStub < Minitest::Test
984
986
  def test_stub_lambda_block_call_args_5
985
987
  @assertion_count += 1
986
988
  rs = nil
987
- io = StringIO.new "", "w"
989
+ io = StringIO.new(+"", "w")
988
990
  File.stub5(:open, lambda { |p, m, &blk| blk and blk.call io }, :WTF?) do
989
991
  File.open "foo.txt", "r" do |f|
990
992
  rs = f.write("woot")
@@ -999,7 +1001,7 @@ class TestMinitestStub < Minitest::Test
999
1001
 
1000
1002
  @assertion_count += 1
1001
1003
  rs = nil
1002
- io = StringIO.new "", "w"
1004
+ io = StringIO.new(+"", "w")
1003
1005
  File.stub6(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
1004
1006
  File.open "foo.txt", "r" do |f|
1005
1007
  rs = f.write("woot")
@@ -1014,7 +1016,7 @@ class TestMinitestStub < Minitest::Test
1014
1016
 
1015
1017
  @assertion_count += 2
1016
1018
  rs = nil
1017
- io = StringIO.new "", "w"
1019
+ io = StringIO.new(+"", "w")
1018
1020
  @tc.assert_raises ArgumentError do
1019
1021
  File.stub6_2(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
1020
1022
  File.open "foo.txt", "r" do |f|
@@ -1064,7 +1066,7 @@ class TestMinitestStub < Minitest::Test
1064
1066
  def test_stub_value_block_args_5
1065
1067
  @assertion_count += 2
1066
1068
  rs = nil
1067
- io = StringIO.new "", "w"
1069
+ io = StringIO.new(+"", "w")
1068
1070
  File.stub5 :open, :value, io do
1069
1071
  result = File.open "foo.txt", "r" do |f|
1070
1072
  rs = f.write("woot")
@@ -1083,7 +1085,7 @@ class TestMinitestStub < Minitest::Test
1083
1085
  end
1084
1086
  end
1085
1087
  end
1086
- exp = /undefined method `write' for nil/
1088
+ exp = /undefined method [`']write' for nil/
1087
1089
  assert_match exp, e.message
1088
1090
  end
1089
1091
 
@@ -1092,7 +1094,7 @@ class TestMinitestStub < Minitest::Test
1092
1094
 
1093
1095
  @assertion_count += 2
1094
1096
  rs = nil
1095
- io = StringIO.new "", "w"
1097
+ io = StringIO.new(+"", "w")
1096
1098
  assert_deprecated do
1097
1099
  File.stub6 :open, :value, io do
1098
1100
  result = File.open "foo.txt", "r" do |f|
@@ -1110,7 +1112,7 @@ class TestMinitestStub < Minitest::Test
1110
1112
 
1111
1113
  @assertion_count += 2
1112
1114
  rs = nil
1113
- io = StringIO.new "", "w"
1115
+ io = StringIO.new(+"", "w")
1114
1116
  @tc.assert_raises ArgumentError do
1115
1117
  File.stub6_2 :open, :value, io do
1116
1118
  result = File.open "foo.txt", "r" do |f|
@@ -31,7 +31,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
31
31
 
32
32
  def setup
33
33
  super
34
- self.io = StringIO.new("")
34
+ self.io = StringIO.new(+"")
35
35
  self.r = new_composite_reporter
36
36
  end
37
37
 
@@ -48,6 +48,25 @@ class TestMinitestReporter < MetaMetaMetaTestCase
48
48
  @et
49
49
  end
50
50
 
51
+ def system_stack_error_test
52
+ unless defined? @sse then
53
+
54
+ ex = SystemStackError.new
55
+
56
+ pre = ("a".."c").to_a
57
+ mid = ("aa".."ad").to_a * 67
58
+ post = ("d".."f").to_a
59
+ ary = pre + mid + post
60
+
61
+ ex.set_backtrace ary
62
+
63
+ @sse = Minitest::Test.new(:woot)
64
+ @sse.failures << Minitest::UnexpectedError.new(ex)
65
+ @sse = Minitest::Result.from @sse
66
+ end
67
+ @sse
68
+ end
69
+
51
70
  def fail_test
52
71
  unless defined? @ft then
53
72
  @ft = Minitest::Test.new(:woot)
@@ -305,8 +324,44 @@ class TestMinitestReporter < MetaMetaMetaTestCase
305
324
  1) Error:
306
325
  Minitest::Test#woot:
307
326
  RuntimeError: no
308
- FILE:LINE:in `error_test'
309
- FILE:LINE:in `test_report_error'
327
+ FILE:LINE:in 'error_test'
328
+ FILE:LINE:in 'test_report_error'
329
+
330
+ 1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
331
+ EOM
332
+
333
+ assert_equal exp, normalize_output(io.string)
334
+ end
335
+
336
+ def test_report_error__sse
337
+ r.start
338
+ r.record system_stack_error_test
339
+ r.report
340
+
341
+ exp = clean <<-EOM
342
+ Run options:
343
+
344
+ # Running:
345
+
346
+ E
347
+
348
+ Finished in 0.00
349
+
350
+ 1) Error:
351
+ Minitest::Test#woot:
352
+ SystemStackError: 274 -> 12
353
+ a
354
+ b
355
+ c
356
+ +->> 67 cycles of 4 lines:
357
+ | aa
358
+ | ab
359
+ | ac
360
+ | ad
361
+ +-<<
362
+ d
363
+ e
364
+ f
310
365
 
311
366
  1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
312
367
  EOM
@@ -338,4 +393,48 @@ class TestMinitestReporter < MetaMetaMetaTestCase
338
393
 
339
394
  assert_equal exp, normalize_output(io.string)
340
395
  end
396
+
397
+ def test_report_failure_uses_backtrace_filter
398
+ filter = Minitest::BacktraceFilter.new
399
+ def filter.filter _bt
400
+ ["foo.rb:123:in 'foo'"]
401
+ end
402
+
403
+ with_backtrace_filter filter do
404
+ r.start
405
+ r.record fail_test
406
+ r.report
407
+ end
408
+
409
+ exp = "Minitest::Test#woot [foo.rb:123]"
410
+
411
+ assert_includes io.string, exp
412
+ end
413
+
414
+ def test_report_failure_uses_backtrace_filter_complex_sorbet
415
+ backtrace = <<~EOBT
416
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/assertions.rb:183:in 'assert'
417
+ example_test.rb:9:in 'assert_false'
418
+ /Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'bind_call'
419
+ /Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'validate_call'
420
+ /Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/_methods.rb:275:in 'block in _on_method_added'
421
+ example_test.rb:25:in 'test_something'
422
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:94:in 'block (3 levels) in run'
423
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:191:in 'capture_exceptions'
424
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:89:in 'block (2 levels) in run'
425
+ ... so many lines ...
426
+ EOBT
427
+
428
+ filter = Minitest::BacktraceFilter.new %r%lib/minitest|gems/sorbet%
429
+
430
+ with_backtrace_filter filter do
431
+ begin
432
+ assert_equal 1, 2
433
+ rescue Minitest::Assertion => e
434
+ e.set_backtrace backtrace.lines.map(&:chomp)
435
+
436
+ assert_match "example_test.rb:25", e.location
437
+ end
438
+ end
439
+ end
341
440
  end
@@ -284,18 +284,14 @@ describe Minitest::Spec do
284
284
  end
285
285
 
286
286
  it "needs to warn on equality with nil" do
287
- @assertion_count += 1 # extra test
287
+ @assertion_count = 3
288
+ @assertion_count += 2 unless error_on_warn? # 2 extra assertions
289
+
290
+ exp = /DEPRECATED: Use assert_nil if expecting nil from .* This will fail in Minitest 6./
288
291
 
289
- out, err = capture_io do
292
+ assert_deprecation exp do
290
293
  assert_success _(nil).must_equal(nil)
291
294
  end
292
-
293
- exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
294
- "This will fail in Minitest 6.\n"
295
- exp = "" if $-w.nil?
296
-
297
- assert_empty out
298
- assert_equal exp, err
299
295
  end
300
296
 
301
297
  it "needs to verify floats outside a delta" do
@@ -576,7 +572,8 @@ describe Minitest::Spec do
576
572
 
577
573
  it "can NOT use must_equal in a thread. It must use expect in a thread" do
578
574
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
579
- assert_raises RuntimeError do
575
+
576
+ assert_raises RuntimeError, Minitest::UnexpectedWarning do
580
577
  capture_io do
581
578
  Thread.new { (1 + 1).must_equal 2 }.join
582
579
  end
@@ -586,9 +583,9 @@ describe Minitest::Spec do
586
583
  it "fails gracefully when expectation used outside of `it`" do
587
584
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
588
585
 
589
- @assertion_count += 1
586
+ @assertion_count += 2 # assert_match is compound
590
587
 
591
- e = assert_raises RuntimeError do
588
+ e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
592
589
  capture_io do
593
590
  Thread.new { # forces ctx to be nil
594
591
  describe("woot") do
@@ -598,17 +595,21 @@ describe Minitest::Spec do
598
595
  end
599
596
  end
600
597
 
601
- assert_equal "Calling #must_equal outside of test.", e.message
598
+ exp = "Calling #must_equal outside of test."
599
+ exp = "DEPRECATED: global use of must_equal from" if error_on_warn?
600
+
601
+ assert_match exp, e.message
602
602
  end
603
603
 
604
604
  it "deprecates expectation used without _" do
605
605
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
606
606
 
607
- @assertion_count += 3
607
+ @assertion_count += 1
608
+ @assertion_count += 2 unless error_on_warn?
608
609
 
609
610
  exp = /DEPRECATED: global use of must_equal from/
610
611
 
611
- assert_output "", exp do
612
+ assert_deprecation exp do
612
613
  (1 + 1).must_equal 2
613
614
  end
614
615
  end
@@ -618,12 +619,13 @@ describe Minitest::Spec do
618
619
  it "deprecates expectation used without _ with empty backtrace_filter" do
619
620
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
620
621
 
621
- @assertion_count += 3
622
+ @assertion_count += 1
623
+ @assertion_count += 2 unless error_on_warn?
622
624
 
623
625
  exp = /DEPRECATED: global use of must_equal from/
624
626
 
625
627
  with_empty_backtrace_filter do
626
- assert_output "", exp do
628
+ assert_deprecation exp do
627
629
  (1 + 1).must_equal 2
628
630
  end
629
631
  end