minitest 5.18.1 → 5.23.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.
data/lib/minitest.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  require "optparse"
2
- require "thread"
3
- require "mutex_m"
4
- require "minitest/parallel"
5
2
  require "stringio"
6
3
  require "etc"
7
4
 
5
+ require_relative "minitest/parallel"
6
+ require_relative "minitest/compress"
7
+
8
8
  ##
9
9
  # :include: README.rdoc
10
10
 
11
11
  module Minitest
12
- VERSION = "5.18.1" # :nodoc:
12
+ VERSION = "5.23.1" # :nodoc:
13
13
 
14
14
  @@installed_at_exit ||= false
15
15
  @@after_run = []
@@ -60,6 +60,9 @@ module Minitest
60
60
  cattr_accessor :info_signal
61
61
  self.info_signal = "INFO"
62
62
 
63
+ cattr_accessor :allow_fork
64
+ self.allow_fork = false
65
+
63
66
  ##
64
67
  # Registers Minitest to run at process exit
65
68
 
@@ -75,7 +78,7 @@ module Minitest
75
78
 
76
79
  pid = Process.pid
77
80
  at_exit {
78
- next if Process.pid != pid
81
+ next if !Minitest.allow_fork && Process.pid != pid
79
82
  @@after_run.reverse_each(&:call)
80
83
  exit exit_code || false
81
84
  }
@@ -131,7 +134,7 @@ module Minitest
131
134
  # Minitest.run(args)
132
135
  # Minitest.__run(reporter, options)
133
136
  # Runnable.runnables.each
134
- # runnable.run(reporter, options)
137
+ # runnable_klass.run(reporter, options)
135
138
  # self.runnable_methods.each
136
139
  # self.run_one_method(self, runnable_method, reporter)
137
140
  # Minitest.run_one_method(klass, runnable_method)
@@ -147,7 +150,7 @@ module Minitest
147
150
 
148
151
  reporter = CompositeReporter.new
149
152
  reporter << SummaryReporter.new(options[:io], options)
150
- reporter << ProgressReporter.new(options[:io], options)
153
+ reporter << ProgressReporter.new(options[:io], options) unless options[:quiet]
151
154
 
152
155
  self.reporter = reporter # this makes it available to plugins
153
156
  self.init_plugins options
@@ -161,11 +164,32 @@ module Minitest
161
164
  warn "Interrupted. Exiting..."
162
165
  end
163
166
  self.parallel_executor.shutdown
167
+
168
+ # might have been removed/replaced during init_plugins:
169
+ summary = reporter.reporters.grep(SummaryReporter).first
170
+
164
171
  reporter.report
165
172
 
173
+ return empty_run! options if summary && summary.count == 0
166
174
  reporter.passed?
167
175
  end
168
176
 
177
+ def self.empty_run! options # :nodoc:
178
+ filter = options[:filter]
179
+ return true unless filter # no filter, but nothing ran == success
180
+
181
+ warn "Nothing ran for filter: %s" % [filter]
182
+
183
+ require "did_you_mean" # soft dependency, punt if it doesn't load
184
+
185
+ ms = Runnable.runnables.flat_map(&:runnable_methods)
186
+ cs = DidYouMean::SpellChecker.new(dictionary: ms).correct filter
187
+
188
+ warn DidYouMean::Formatter.message_for cs unless cs.empty?
189
+ rescue LoadError
190
+ # do nothing
191
+ end
192
+
169
193
  ##
170
194
  # Internal run method. Responsible for telling all Runnable
171
195
  # sub-classes to run.
@@ -209,6 +233,10 @@ module Minitest
209
233
  options[:verbose] = true
210
234
  end
211
235
 
236
+ opts.on "-q", "--quiet", "Quiet. Show no progress processing files." do
237
+ options[:quiet] = true
238
+ end
239
+
212
240
  opts.on "--show-skips", "Show skipped at the end of run." do
213
241
  options[:show_skips] = true
214
242
  end
@@ -225,6 +253,20 @@ module Minitest
225
253
  options[:skip] = s.chars.to_a
226
254
  end
227
255
 
256
+ ruby27plus = ::Warning.respond_to?(:[]=)
257
+
258
+ opts.on "-W[error]", String, "Turn Ruby warnings into errors" do |s|
259
+ options[:Werror] = true
260
+ case s
261
+ when "error", "all", nil then
262
+ require "minitest/error_on_warning"
263
+ $VERBOSE = true
264
+ ::Warning[:deprecated] = true if ruby27plus
265
+ else
266
+ ::Warning[s.to_sym] = true if ruby27plus # check validity of category
267
+ end
268
+ end
269
+
228
270
  unless extensions.empty?
229
271
  opts.separator ""
230
272
  opts.separator "Known extensions: #{extensions.join(", ")}"
@@ -331,25 +373,15 @@ module Minitest
331
373
  # reporter to record.
332
374
 
333
375
  def self.run reporter, options = {}
334
- filtered_methods = if options[:filter]
335
- filter = options[:filter]
336
- filter = Regexp.new $1 if filter.is_a?(String) && filter =~ %r%/(.*)/%
337
-
338
- self.runnable_methods.find_all { |m|
339
- filter === m || filter === "#{self}##{m}"
340
- }
341
- else
342
- self.runnable_methods
343
- end
376
+ pos = options[:filter]
377
+ neg = options[:exclude]
344
378
 
345
- if options[:exclude]
346
- exclude = options[:exclude]
347
- exclude = Regexp.new $1 if exclude =~ %r%/(.*)/%
379
+ pos = Regexp.new $1 if pos.is_a?(String) && pos =~ %r%/(.*)/%
380
+ neg = Regexp.new $1 if neg.is_a?(String) && neg =~ %r%/(.*)/%
348
381
 
349
- filtered_methods.delete_if { |m|
350
- exclude === m || exclude === "#{self}##{m}"
351
- }
352
- end
382
+ filtered_methods = self.runnable_methods
383
+ .select { |m| !pos || pos === m || pos === "#{self}##{m}" }
384
+ .reject { |m| neg && (neg === m || neg === "#{self}##{m}") }
353
385
 
354
386
  return if filtered_methods.empty?
355
387
 
@@ -446,6 +478,31 @@ module Minitest
446
478
  self.name = name
447
479
  self.failures = []
448
480
  self.assertions = 0
481
+ # lazy initializer for metadata
482
+ end
483
+
484
+ ##
485
+ # Metadata you attach to the test results that get sent to the reporter.
486
+ #
487
+ # Lazily initializes to a hash, to keep memory down.
488
+ #
489
+ # NOTE: this data *must* be plain (read: marshal-able) data!
490
+ # Hashes! Arrays! Strings!
491
+
492
+ def metadata
493
+ @metadata ||= {}
494
+ end
495
+
496
+ ##
497
+ # Sets metadata, mainly used for +Result.from+.
498
+
499
+ attr_writer :metadata
500
+
501
+ ##
502
+ # Returns true if metadata exists.
503
+
504
+ def metadata?
505
+ defined? @metadata
449
506
  end
450
507
 
451
508
  ##
@@ -497,12 +554,14 @@ module Minitest
497
554
  not self.failure
498
555
  end
499
556
 
557
+ BASE_DIR = "#{Dir.pwd}/" # :nodoc:
558
+
500
559
  ##
501
560
  # The location identifier of this test. Depends on a method
502
561
  # existing called class_name.
503
562
 
504
563
  def location
505
- loc = " [#{self.failure.location}]" unless passed? or error?
564
+ loc = " [#{self.failure.location.delete_prefix BASE_DIR}]" unless passed? or error?
506
565
  "#{self.class_name}##{self.name}#{loc}"
507
566
  end
508
567
 
@@ -566,6 +625,7 @@ module Minitest
566
625
  r.assertions = o.assertions
567
626
  r.failures = o.failures.dup
568
627
  r.time = o.time
628
+ r.metadata = o.metadata if o.metadata?
569
629
 
570
630
  r.source_location = o.method(o.name).source_location rescue ["unknown", -1]
571
631
 
@@ -590,7 +650,10 @@ module Minitest
590
650
  # you want. Go nuts.
591
651
 
592
652
  class AbstractReporter
593
- include Mutex_m
653
+
654
+ def initialize # :nodoc:
655
+ @mutex = Mutex.new
656
+ end
594
657
 
595
658
  ##
596
659
  # Starts reporting on the run.
@@ -626,6 +689,10 @@ module Minitest
626
689
  def passed?
627
690
  true
628
691
  end
692
+
693
+ def synchronize(&block) # :nodoc:
694
+ @mutex.synchronize(&block)
695
+ end
629
696
  end
630
697
 
631
698
  class Reporter < AbstractReporter # :nodoc:
@@ -729,6 +796,11 @@ module Minitest
729
796
 
730
797
  attr_accessor :errors
731
798
 
799
+ ##
800
+ # Total number of tests that warned.
801
+
802
+ attr_accessor :warnings
803
+
732
804
  ##
733
805
  # Total number of tests that where skipped.
734
806
 
@@ -744,6 +816,7 @@ module Minitest
744
816
  self.total_time = nil
745
817
  self.failures = nil
746
818
  self.errors = nil
819
+ self.warnings = nil
747
820
  self.skips = nil
748
821
  end
749
822
 
@@ -772,6 +845,7 @@ module Minitest
772
845
  self.total_time = Minitest.clock_time - start_time
773
846
  self.failures = aggregate[Assertion].size
774
847
  self.errors = aggregate[UnexpectedError].size
848
+ self.warnings = aggregate[UnexpectedWarning].size
775
849
  self.skips = aggregate[Skip].size
776
850
  end
777
851
  end
@@ -799,7 +873,7 @@ module Minitest
799
873
  io.puts "# Running:"
800
874
  io.puts
801
875
 
802
- self.sync = io.respond_to? :"sync=" # stupid emacs
876
+ self.sync = io.respond_to? :"sync="
803
877
  self.old_sync, io.sync = io.sync, true if self.sync
804
878
  end
805
879
 
@@ -847,6 +921,8 @@ module Minitest
847
921
  results.any?(&:skipped?) unless
848
922
  options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
849
923
 
924
+ extra.prepend ", %d warnings" % [warnings] if options[:Werror]
925
+
850
926
  "%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
851
927
  [count, assertions, failures, errors, skips, extra]
852
928
  end
@@ -907,6 +983,8 @@ module Minitest
907
983
  # Represents run failures.
908
984
 
909
985
  class Assertion < Exception
986
+ RE = /in [`'](?:[^']+[#.])?(?:assert|refute|flunk|pass|fail|raise|must|wont)/ # :nodoc:
987
+
910
988
  def error # :nodoc:
911
989
  self
912
990
  end
@@ -915,12 +993,11 @@ module Minitest
915
993
  # Where was this run before an assertion was raised?
916
994
 
917
995
  def location
918
- last_before_assertion = ""
919
- self.backtrace.reverse_each do |s|
920
- break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
921
- last_before_assertion = s
922
- end
923
- last_before_assertion.sub(/:in .*$/, "")
996
+ bt = Minitest.filter_backtrace self.backtrace
997
+ idx = bt.rindex { |s| s.match? RE } || -1 # fall back to first item
998
+ loc = bt[idx+1] || bt.last || "unknown:-1"
999
+
1000
+ loc.sub(/:in .*$/, "")
924
1001
  end
925
1002
 
926
1003
  def result_code # :nodoc:
@@ -945,11 +1022,21 @@ module Minitest
945
1022
  # Assertion wrapping an unexpected error that was raised during a run.
946
1023
 
947
1024
  class UnexpectedError < Assertion
1025
+ include Minitest::Compress
1026
+
948
1027
  # TODO: figure out how to use `cause` instead
949
1028
  attr_accessor :error # :nodoc:
950
1029
 
951
1030
  def initialize error # :nodoc:
952
1031
  super "Unexpected exception"
1032
+
1033
+ if SystemStackError === error then
1034
+ bt = error.backtrace
1035
+ new_bt = compress bt
1036
+ error = error.exception "#{bt.size} -> #{new_bt.size}"
1037
+ error.set_backtrace new_bt
1038
+ end
1039
+
953
1040
  self.error = error
954
1041
  end
955
1042
 
@@ -957,8 +1044,11 @@ module Minitest
957
1044
  self.error.backtrace
958
1045
  end
959
1046
 
1047
+ BASE_RE = %r%#{Dir.pwd}/% # :nodoc:
1048
+
960
1049
  def message # :nodoc:
961
- bt = Minitest.filter_backtrace(self.backtrace).join "\n "
1050
+ bt = Minitest.filter_backtrace(self.backtrace).join("\n ")
1051
+ .gsub(BASE_RE, "")
962
1052
  "#{self.error.class}: #{self.error.message}\n #{bt}"
963
1053
  end
964
1054
 
@@ -967,6 +1057,15 @@ module Minitest
967
1057
  end
968
1058
  end
969
1059
 
1060
+ ##
1061
+ # Assertion raised on warning when running in -Werror mode.
1062
+
1063
+ class UnexpectedWarning < Assertion
1064
+ def result_label # :nodoc:
1065
+ "Warning"
1066
+ end
1067
+ end
1068
+
970
1069
  ##
971
1070
  # Provides a simple set of guards that you can use in your tests
972
1071
  # to skip execution if it is not applicable. These methods are
@@ -1040,7 +1139,13 @@ module Minitest
1040
1139
 
1041
1140
  class BacktraceFilter
1042
1141
 
1043
- MT_RE = %r%lib/minitest% #:nodoc:
1142
+ MT_RE = %r%lib/minitest|internal:warning% #:nodoc:
1143
+
1144
+ attr_accessor :regexp
1145
+
1146
+ def initialize regexp = MT_RE
1147
+ self.regexp = regexp
1148
+ end
1044
1149
 
1045
1150
  ##
1046
1151
  # Filter +bt+ to something useful. Returns the whole thing if
@@ -1051,9 +1156,9 @@ module Minitest
1051
1156
 
1052
1157
  return bt.dup if $DEBUG || ENV["MT_DEBUG"]
1053
1158
 
1054
- new_bt = bt.take_while { |line| line !~ MT_RE }
1055
- new_bt = bt.select { |line| line !~ MT_RE } if new_bt.empty?
1056
- new_bt = bt.dup if new_bt.empty?
1159
+ new_bt = bt.take_while { |line| line.to_s !~ regexp }
1160
+ new_bt = bt.select { |line| line.to_s !~ regexp } if new_bt.empty?
1161
+ new_bt = bt.dup if new_bt.empty?
1057
1162
 
1058
1163
  new_bt
1059
1164
  end
@@ -8,24 +8,36 @@ class Minitest::Test
8
8
  end
9
9
 
10
10
  def with_empty_backtrace_filter
11
- original = Minitest.backtrace_filter
12
-
13
- obj = Minitest::BacktraceFilter.new
14
- def obj.filter _bt
15
- []
11
+ with_backtrace_filter Minitest::BacktraceFilter.new %r%.% do
12
+ yield
16
13
  end
14
+ end
15
+
16
+ def with_backtrace_filter filter
17
+ original = Minitest.backtrace_filter
17
18
 
18
19
  Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
19
20
  begin
20
- Minitest.backtrace_filter = obj
21
+ Minitest.backtrace_filter = filter
21
22
  yield
22
23
  ensure
23
24
  Minitest.backtrace_filter = original
24
25
  end
25
26
  end
26
27
  end
27
- end
28
28
 
29
+ def error_on_warn?
30
+ defined?(Minitest::ErrorOnWarning)
31
+ end
32
+
33
+ def assert_deprecation re = /DEPRECATED/
34
+ assert_output "", re do
35
+ yield
36
+ end
37
+ rescue Minitest::UnexpectedWarning => e # raised if -Werror was used
38
+ assert_match re, e.message
39
+ end
40
+ end
29
41
 
30
42
  class FakeNamedTest < Minitest::Test
31
43
  @@count = 0
@@ -55,7 +67,7 @@ class MetaMetaMetaTestCase < Minitest::Test
55
67
  def run_tu_with_fresh_reporter flags = %w[--seed 42]
56
68
  options = Minitest.process_args flags
57
69
 
58
- @output = StringIO.new("".encode('UTF-8'))
70
+ @output = StringIO.new("".encode(Encoding::UTF_8))
59
71
 
60
72
  self.reporter = Minitest::CompositeReporter.new
61
73
  reporter << Minitest::SummaryReporter.new(@output, options)
@@ -105,15 +117,20 @@ class MetaMetaMetaTestCase < Minitest::Test
105
117
  output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
106
118
  output.gsub!(/ +$/, "")
107
119
 
120
+ file = ->(s) { s.start_with?("/") ? "FULLFILE" : "FILE" }
121
+
108
122
  if windows? then
109
123
  output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, "[FILE:LINE]")
110
- output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
124
+ output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in [`']/, '\1FILE:LINE:in \'')
111
125
  else
112
- output.gsub!(/\[[^\]:]+:\d+\]/, "[FILE:LINE]")
113
- output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
126
+ output.gsub!(/\[([^\]:]+):\d+\]/) { "[#{file[$1]}:LINE]" }
127
+ output.gsub!(/^(\s+)([^:]+):\d+:in [`']/) { "#{$1}#{file[$2]}:LINE:in '" }
114
128
  end
115
129
 
116
- output.gsub!(/( at )[^:]+:\d+/, '\1[FILE:LINE]')
130
+ output.gsub!(/in [`']block in (?:([^']+)[#.])?/, "in 'block in")
131
+ output.gsub!(/in [`'](?:([^']+)[#.])?/, "in '")
132
+
133
+ output.gsub!(/( at )[^:]+:\d+/) { "#{$1}[#{file[$2]}:LINE]" } # eval?
117
134
 
118
135
  output
119
136
  end
@@ -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
 
@@ -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