minitest 5.14.1 → 5.15.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ed38adcad085c6c7c1cb81e9b580908d0b5b1b3696ad0014485b6524c20e344
4
- data.tar.gz: c3574e199c963262186d5c865f248570194b1614ab4fcba13e5dfa8a2419785c
3
+ metadata.gz: 0d7d16c7decb91ba01a888704bd527d1e5569454b444fe1b4e41a8a3a7db7406
4
+ data.tar.gz: 1ee0d2823a94b63b8cd019198fe2ca20a5c3d9d7bf4918148bdfa543fb65945d
5
5
  SHA512:
6
- metadata.gz: 543a116cf39777334557ecae8d76768afcb860995555945295669a68c20c9268543112368f65c848081ff0ab2ca727a87590676c3cadf1bc87bebc5986f08e92
7
- data.tar.gz: b23ea10b6259ad60c96dbd3a384e8d39dcac48d3f961a26b3aa6e910ed947e6fc2d4b36fb06e8e84667457a6d897e3dca855771c0c6c3bfb81b38d3d83c1b3af
6
+ metadata.gz: 933a300969aa30dc8f254952dd17f9975cb1f3aad9c10c96260394d088b76900273773374b5ed72731356f2b7f1cfeb131583ae943322250a60401e554e11f45
7
+ data.tar.gz: 24a356e1d3c06e28d03860b4dca92d17b88979ebad6316fe97298207c58b29b0ae207657d0044a43ede1bf9a27ac43ca8c779e24fc9ca5ed4c920beca2eaf143
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- d��!�40$ ��k+��>hNV�Yp��]y:1�PC�{'=a��!�\�/2==�� ��t���n� A@"���+ �#���Lf��K;��\t�?UA�$�lЕdF��O��R�®�{n���- T@O1Ҿ ����~�<P?(H��z��0�����0.�L�r�d_��5�P�ª���As'o �ђ��hBO�޹u0S���3*�A[��w� ��wmlÁyτ3W���ﶓ����i�8qJ�_=���
1
+ o3_�"D%%���̮[���4�K�D祆�ߦ�;�&p�8�-�Ԓ�$t�3���4���� �p#�� L+���9�A�r�ӣ�Q��.;��yA.M
data/History.rdoc CHANGED
@@ -1,3 +1,42 @@
1
+ === 5.15.0 / 2021-12-14
2
+
3
+ * 1 major enhancement:
4
+
5
+ * assert_throws returns the value returned, if any. (volmer)
6
+
7
+ * 3 minor enhancements:
8
+
9
+ * Added -S <CODES> option to skip reporting of certain types of output
10
+ * Enable Ruby deprecation warnings by default. (casperisfine)
11
+ * Use Etc.nprocessors by default in order to maximize cpu usage. (tonytonyjan)
12
+
13
+ * 6 bug fixes:
14
+
15
+ * Close then unlink tempfiles on Windows. (nobu)
16
+ * Fixed #skip_until for windows paths. (MSP-Greg)
17
+ * Fixed a bunch of tests for jruby and windows. (MSP-Greg)
18
+ * Fixed marshalling of specs if they error. (tenderlove, jeremyevans, et al)
19
+ * Updated deprecation message for block expectations. (blowmage)
20
+ * Use Kernel.warn directly in expectations in case CUT defines their own warn. (firien)
21
+
22
+ === 5.14.4 / 2021-02-23
23
+
24
+ * 1 bug fix:
25
+
26
+ * Fixed deprecation warning using stub with methods using keyword arguments. (Nakilon)
27
+
28
+ === 5.14.3 / 2021-01-05
29
+
30
+ * 1 bug fix:
31
+
32
+ * Bumped require_ruby_version to < 4 (trunk = 3.1).
33
+
34
+ === 5.14.2 / 2020-08-31
35
+
36
+ * 1 bug fix:
37
+
38
+ * Bumped ruby version to include 3.0 (trunk).
39
+
1
40
  === 5.14.1 / 2020-05-15
2
41
 
3
42
  * 3 minor enhancements:
@@ -205,7 +244,7 @@
205
244
  * 2 bug fixes:
206
245
 
207
246
  * Re-release to refresh gem certificate signing. ugh.
208
- * Fixed hoe/minitest to not augment load path if we're actually testing minitest.
247
+ * Fixed hoe/minitest to not augment load path if we're actually testing minitest.
209
248
 
210
249
  === 5.9.0 / 2016-05-16
211
250
 
@@ -229,7 +268,7 @@
229
268
  * 2 bug fixes:
230
269
 
231
270
  * Re-release to refresh gem certificate signing. ugh.
232
- * Fixed hoe/minitest to not augment load path if we're actually testing minitest.
271
+ * Fixed hoe/minitest to not augment load path if we're actually testing minitest.
233
272
 
234
273
  === 5.8.4 / 2016-01-21
235
274
 
@@ -543,7 +582,7 @@ Minitest 5:
543
582
  * Added Minitest::Benchmark.
544
583
  * Your benchmarks need to move to their own subclass.
545
584
  * Benchmarks using the spec DSL have to have "Bench" somewhere in their describe.
546
- * MiniTest::Unit.after_tests moved to Minitest.after_tests
585
+ * MiniTest::Unit.after_tests moved to Minitest.after_run
547
586
  * MiniTest::Unit.autorun is now Minitest.autorun. Just require minitest/autorun pls.
548
587
  * Removed ParallelEach#grep since it isn't used anywhere.
549
588
  * Renamed Runnable#__name__ to Runnable#name (but uses @NAME internally).
@@ -1389,4 +1428,3 @@ back.
1389
1428
  * 1 major enhancement
1390
1429
 
1391
1430
  * Birthday!
1392
-
data/README.rdoc CHANGED
@@ -376,6 +376,42 @@ Using our example above, here is how we might implement MyCI:
376
376
 
377
377
  == FAQ
378
378
 
379
+ === What versions are compatible with what? Or what versions are supported?
380
+
381
+ Minitest is a dependency of rails, which until fairly recently had an
382
+ overzealous backwards compatibility policy. As such, I'm stuck
383
+ supporting versions of ruby that are long past EOL. Once rails 5.2 is
384
+ dropped (hopefully April 2021), I get to drop a bunch of versions of
385
+ ruby that I have to currently test against.
386
+
387
+ (As of 2021-01-31)
388
+
389
+ Current versions of rails: (https://endoflife.date/rails)
390
+
391
+ | rails | min ruby | rec ruby | minitest | status |
392
+ |-------+----------+----------+----------+----------|
393
+ | 7.0 | >= 2.7 | 3.0 | >= 5.1 | Future |
394
+ | 6.1 | >= 2.5 | 3.0 | >= 5.1 | Current |
395
+ | 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security |
396
+ | 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 | Security | EOL @railsconf 2021?
397
+
398
+ Current versions of ruby: (https://endoflife.date/ruby)
399
+
400
+ | ruby | Status | EOL Date |
401
+ |------+---------+------------|
402
+ | 3.0 | Current | 2024-03-31 |
403
+ | 2.7 | Maint | 2023-03-31 |
404
+ | 2.6 | Maint* | 2022-03-31 |
405
+ | 2.5 | EOL | 2021-03-31 |
406
+ | 2.4 | EOL | 2020-03-31 |
407
+ | 2.3 | EOL | 2019-03-31 |
408
+ | 2.2 | EOL | 2018-03-31 |
409
+
410
+ See also:
411
+
412
+ * https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
413
+ * https://jamesjeffersconsulting.com/ruby-rails-version-matrix/
414
+
379
415
  === How to test SimpleDelegates?
380
416
 
381
417
  The following implementation and test:
@@ -611,6 +647,7 @@ minitest-growl :: Test notifier for minitest via growl.
611
647
  minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
612
648
  minitest-have_tag :: Adds Minitest assertions to test for the existence of
613
649
  HTML tags, including contents, within a provided string.
650
+ minitest-heat :: Reporting that builds a heat map of failure locations
614
651
  minitest-hooks :: Around and before_all/after_all/around_all hooks
615
652
  minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
616
653
  minitest-implicit-subject :: Implicit declaration of the test subject.
@@ -685,6 +722,8 @@ mongoid-minitest :: Minitest matchers for Mongoid.
685
722
  mutant-minitest :: Minitest integration for mutant.
686
723
  pry-rescue :: A pry plugin w/ minitest support. See
687
724
  pry-rescue/minitest.rb.
725
+ rematch :: Declutter your test files from large hardcoded data
726
+ and update them automatically when your code changes.
688
727
  rspec2minitest :: Easily translate any RSpec matchers to Minitest
689
728
  assertions and expectations.
690
729
 
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ Hoe.spec "minitest" do
11
11
 
12
12
  license "MIT"
13
13
 
14
- require_ruby_version "~> 2.2"
14
+ require_ruby_version [">= 2.2", "< 4.0"]
15
15
  end
16
16
 
17
17
  desc "Find missing expectations"
data/lib/hoe/minitest.rb CHANGED
@@ -24,9 +24,5 @@ module Hoe::Minitest
24
24
 
25
25
  def define_minitest_tasks
26
26
  self.testlib = :minitest
27
-
28
- # make sure we use the gemmed minitest on 1.9
29
- self.test_prelude = 'gem "minitest"' unless
30
- minitest? or ENV["MT_NO_ISOLATE"]
31
27
  end
32
28
  end
@@ -473,7 +473,7 @@ module Minitest
473
473
  def assert_throws sym, msg = nil
474
474
  default = "Expected #{mu_pp(sym)} to have been thrown"
475
475
  caught = true
476
- catch(sym) do
476
+ value = catch(sym) do
477
477
  begin
478
478
  yield
479
479
  rescue ThreadError => e # wtf?!? 1.8 + threads == suck
@@ -489,6 +489,7 @@ module Minitest
489
489
  end
490
490
 
491
491
  assert caught, message(msg) { default }
492
+ value
492
493
  rescue Assertion
493
494
  raise
494
495
  rescue => e
@@ -561,15 +562,13 @@ module Minitest
561
562
 
562
563
  return captured_stdout.read, captured_stderr.read
563
564
  ensure
564
- captured_stdout.unlink
565
- captured_stderr.unlink
566
565
  $stdout.reopen orig_stdout
567
566
  $stderr.reopen orig_stderr
568
567
 
569
568
  orig_stdout.close
570
569
  orig_stderr.close
571
- captured_stdout.close
572
- captured_stderr.close
570
+ captured_stdout.close!
571
+ captured_stderr.close!
573
572
  end
574
573
  end
575
574
  end
@@ -793,7 +792,7 @@ module Minitest
793
792
 
794
793
  def skip_until y,m,d,msg
795
794
  skip msg if Time.now < Time.local(y, m, d)
796
- where = caller.first.split(/:/, 3).first(2).join ":"
795
+ where = caller.first.rpartition(':in').reject(&:empty?).first
797
796
  warn "Stale skip_until %p at %s" % [msg, where]
798
797
  end
799
798
 
data/lib/minitest/mock.rb CHANGED
@@ -207,7 +207,9 @@ class Object
207
207
  # assert obj_under_test.stale?
208
208
  # end
209
209
  # end
210
- #
210
+ #--
211
+ # NOTE: keyword args in callables are NOT checked for correctness
212
+ # against the existing method. Too many edge cases to be worth it.
211
213
 
212
214
  def stub name, val_or_callable, *block_args
213
215
  new_name = "__minitest_stub__#{name}"
@@ -231,6 +233,8 @@ class Object
231
233
  end
232
234
  end
233
235
 
236
+ metaclass.send(:ruby2_keywords, name) if metaclass.respond_to?(:ruby2_keywords, true)
237
+
234
238
  yield self
235
239
  ensure
236
240
  metaclass.send :undef_method, name
data/lib/minitest/spec.rb CHANGED
@@ -4,13 +4,14 @@ class Module # :nodoc:
4
4
  def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
5
5
  block = dont_flip == :block
6
6
  dont_flip = false if block
7
+ target_obj = block ? '_{obj.method}' : '_(obj)'
7
8
 
8
9
  # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
9
10
  self.class_eval <<-EOM, __FILE__, __LINE__ + 1
10
11
  def #{new_name} *args
11
12
  where = Minitest.filter_backtrace(caller).first
12
13
  where = where.split(/:in /, 2).first # clean up noise
13
- warn "DEPRECATED: global use of #{new_name} from #\{where}. Use _(obj).#{new_name} instead. This will fail in Minitest 6."
14
+ Kernel.warn "DEPRECATED: global use of #{new_name} from #\{where}. Use #{target_obj}.#{new_name} instead. This will fail in Minitest 6."
14
15
  Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
15
16
  end
16
17
  EOM
data/lib/minitest/test.rb CHANGED
@@ -198,7 +198,17 @@ module Minitest
198
198
  rescue Assertion => e
199
199
  self.failures << e
200
200
  rescue Exception => e
201
- self.failures << UnexpectedError.new(e)
201
+ self.failures << UnexpectedError.new(sanitize_exception e)
202
+ end
203
+
204
+ def sanitize_exception e # :nodoc:
205
+ Marshal.dump e
206
+ e
207
+ rescue TypeError
208
+ bt = e.backtrace
209
+ e = RuntimeError.new "Wrapped undumpable exception for: #{e.class}: #{e.message}"
210
+ e.set_backtrace bt
211
+ e
202
212
  end
203
213
 
204
214
  def with_info_handler &block # :nodoc:
data/lib/minitest.rb CHANGED
@@ -3,12 +3,13 @@ require "thread"
3
3
  require "mutex_m"
4
4
  require "minitest/parallel"
5
5
  require "stringio"
6
+ require "etc"
6
7
 
7
8
  ##
8
9
  # :include: README.rdoc
9
10
 
10
11
  module Minitest
11
- VERSION = "5.14.1" # :nodoc:
12
+ VERSION = "5.15.0" # :nodoc:
12
13
  ENCS = "".respond_to? :encoding # :nodoc:
13
14
 
14
15
  @@installed_at_exit ||= false
@@ -23,7 +24,7 @@ module Minitest
23
24
  mc.send :attr_accessor, :parallel_executor
24
25
 
25
26
  warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"]
26
- n_threads = (ENV["MT_CPU"] || ENV["N"] || 2).to_i
27
+ n_threads = (ENV["MT_CPU"] || ENV["N"] || Etc.nprocessors).to_i
27
28
  self.parallel_executor = Parallel::Executor.new n_threads
28
29
 
29
30
  ##
@@ -53,6 +54,10 @@ module Minitest
53
54
  # Registers Minitest to run at process exit
54
55
 
55
56
  def self.autorun
57
+ if Object.const_defined?(:Warning) && Warning.respond_to?(:[]=)
58
+ Warning[:deprecated] = true
59
+ end
60
+
56
61
  at_exit {
57
62
  next if $! and not ($!.kind_of? SystemExit and $!.success?)
58
63
 
@@ -199,6 +204,10 @@ module Minitest
199
204
  options[:exclude] = a
200
205
  end
201
206
 
207
+ opts.on "-S", "--skip CODES", String, "Skip reporting of certain types of results (eg E)." do |s|
208
+ options[:skip] = s.chars.to_a
209
+ end
210
+
202
211
  unless extensions.empty?
203
212
  opts.separator ""
204
213
  opts.separator "Known extensions: #{extensions.join(", ")}"
@@ -786,7 +795,11 @@ module Minitest
786
795
  filtered_results = results.dup
787
796
  filtered_results.reject!(&:skipped?) unless options[:verbose]
788
797
 
798
+ skip = options[:skip] || []
799
+
789
800
  filtered_results.each_with_index { |result, i|
801
+ next if skip.include? result.result_code
802
+
790
803
  io.puts "\n%3d) %s" % [i+1, result]
791
804
  }
792
805
  io.puts
@@ -28,6 +28,9 @@ class TestMinitestAssertions < Minitest::Test
28
28
 
29
29
  RUBY18 = !defined? Encoding
30
30
 
31
+ # not included in JRuby
32
+ RE_LEVELS = /\(\d+ levels\) /
33
+
31
34
  class DummyTest
32
35
  include Minitest::Assertions
33
36
  # include Minitest::Reportable # TODO: why do I really need this?
@@ -756,12 +759,12 @@ class TestMinitestAssertions < Minitest::Test
756
759
  Class: <SomeError>
757
760
  Message: <\"blah\">
758
761
  ---Backtrace---
759
- FILE:LINE:in \`test_assert_raises_default_triggered\'
762
+ FILE:LINE:in \`block in test_assert_raises_default_triggered\'
760
763
  ---------------
761
764
  EOM
762
765
 
763
766
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
764
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
767
+ actual.gsub!(RE_LEVELS, "") unless jruby?
765
768
 
766
769
  assert_equal expected, actual
767
770
  end
@@ -835,12 +838,12 @@ class TestMinitestAssertions < Minitest::Test
835
838
  Class: <AnError>
836
839
  Message: <\"some message\">
837
840
  ---Backtrace---
838
- FILE:LINE:in \`test_assert_raises_subclass_triggered\'
841
+ FILE:LINE:in \`block in test_assert_raises_subclass_triggered\'
839
842
  ---------------
840
843
  EOM
841
844
 
842
845
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
843
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
846
+ actual.gsub!(RE_LEVELS, "") unless jruby?
844
847
 
845
848
  assert_equal expected.chomp, actual
846
849
  end
@@ -857,12 +860,12 @@ class TestMinitestAssertions < Minitest::Test
857
860
  Class: <SyntaxError>
858
861
  Message: <\"icky\">
859
862
  ---Backtrace---
860
- FILE:LINE:in \`test_assert_raises_triggered_different\'
863
+ FILE:LINE:in \`block in test_assert_raises_triggered_different\'
861
864
  ---------------
862
865
  EOM
863
866
 
864
867
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
865
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
868
+ actual.gsub!(RE_LEVELS, "") unless jruby?
866
869
 
867
870
  assert_equal expected, actual
868
871
  end
@@ -880,12 +883,12 @@ class TestMinitestAssertions < Minitest::Test
880
883
  Class: <SyntaxError>
881
884
  Message: <\"icky\">
882
885
  ---Backtrace---
883
- FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
886
+ FILE:LINE:in \`block in test_assert_raises_triggered_different_msg\'
884
887
  ---------------
885
888
  EOM
886
889
 
887
890
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
888
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
891
+ actual.gsub!(RE_LEVELS, "") unless jruby?
889
892
 
890
893
  assert_equal expected.chomp, actual
891
894
  end
@@ -995,9 +998,19 @@ class TestMinitestAssertions < Minitest::Test
995
998
  end
996
999
 
997
1000
  def test_assert_throws
998
- @tc.assert_throws :blah do
1001
+ v = @tc.assert_throws :blah do
999
1002
  throw :blah
1000
1003
  end
1004
+
1005
+ assert_nil v
1006
+ end
1007
+
1008
+ def test_assert_throws_value
1009
+ v = @tc.assert_throws :blah do
1010
+ throw :blah, 42
1011
+ end
1012
+
1013
+ assert_equal 42, v
1001
1014
  end
1002
1015
 
1003
1016
  def test_assert_throws_argument_exception
@@ -1118,16 +1131,20 @@ class TestMinitestAssertions < Minitest::Test
1118
1131
  end
1119
1132
  end
1120
1133
 
1134
+ def assert_fail_after t
1135
+ @tc.fail_after t.year, t.month, t.day, "remove the deprecations"
1136
+ end
1137
+
1121
1138
  def test_fail_after
1122
- t = Time.now
1123
- y, m, d = t.year, t.month, t.day
1139
+ d0 = Time.now
1140
+ d1 = d0 + 86_400 # I am an idiot
1124
1141
 
1125
1142
  assert_silent do
1126
- @tc.fail_after y, m, d+1, "remove the deprecations"
1143
+ assert_fail_after d1
1127
1144
  end
1128
1145
 
1129
1146
  assert_triggered "remove the deprecations" do
1130
- @tc.fail_after y, m, d, "remove the deprecations"
1147
+ assert_fail_after d0
1131
1148
  end
1132
1149
  end
1133
1150
 
@@ -1342,18 +1359,22 @@ class TestMinitestAssertions < Minitest::Test
1342
1359
  end
1343
1360
  end
1344
1361
 
1362
+ def assert_skip_until t, msg
1363
+ @tc.skip_until t.year, t.month, t.day, msg
1364
+ end
1365
+
1345
1366
  def test_skip_until
1346
1367
  @assertion_count = 0
1347
1368
 
1348
- t = Time.now
1349
- y, m, d = t.year, t.month, t.day
1369
+ d0 = Time.now
1370
+ d1 = d0 + 86_400 # I am an idiot
1350
1371
 
1351
1372
  assert_output "", /Stale skip_until \"not yet\" at .*?:\d+$/ do
1352
- @tc.skip_until y, m, d, "not yet"
1373
+ assert_skip_until d0, "not yet"
1353
1374
  end
1354
1375
 
1355
1376
  assert_triggered "not ready yet", Minitest::Skip do
1356
- @tc.skip_until y, m, d+1, "not ready yet"
1377
+ assert_skip_until d1, "not ready yet"
1357
1378
  end
1358
1379
  end
1359
1380
 
@@ -133,7 +133,7 @@ class TestMinitestMock < Minitest::Test
133
133
  @mock.expect :blah, 3, false
134
134
  end
135
135
 
136
- assert_equal "args must be an array", e.message
136
+ assert_match "args must be an array", e.message
137
137
  end
138
138
 
139
139
  def test_respond_appropriately
@@ -150,7 +150,7 @@ class TestMinitestMock < Minitest::Test
150
150
 
151
151
  expected = "unmocked method :bar, expected one of [:foo, :meaning_of_life]"
152
152
 
153
- assert_equal expected, e.message
153
+ assert_match expected, e.message
154
154
  end
155
155
 
156
156
  def test_assign_per_mock_return_values
@@ -309,7 +309,7 @@ class TestMinitestMock < Minitest::Test
309
309
 
310
310
  exp = "args ignored when block given"
311
311
 
312
- assert_equal exp, e.message
312
+ assert_match exp, e.message
313
313
  end
314
314
 
315
315
  def test_mock_returns_retval_when_called_with_block
@@ -499,7 +499,8 @@ class TestMinitestStub < Minitest::Test
499
499
  end
500
500
  end
501
501
 
502
- exp = /undefined method `nope_nope_nope' for( class)? `#{self.class}::Time'/
502
+ exp = jruby? ? /Undefined method nope_nope_nope for '#{self.class}::Time'/ :
503
+ /undefined method `nope_nope_nope' for( class)? `#{self.class}::Time'/
503
504
  assert_match exp, e.message
504
505
  end
505
506
 
@@ -591,6 +592,18 @@ class TestMinitestStub < Minitest::Test
591
592
  end
592
593
  end
593
594
 
595
+ class Keywords
596
+ def self.args req, kw1:, kw2:24
597
+ [req, kw1, kw2]
598
+ end
599
+ end
600
+
601
+ def test_stub_callable_keyword_args
602
+ Keywords.stub :args, ->(*args, **kws) { [args, kws] } do
603
+ @tc.assert_equal [["woot"], { kw1: 42 }], Keywords.args("woot", kw1: 42)
604
+ end
605
+ end
606
+
594
607
  def test_stub_callable_block_5 # from tenderlove
595
608
  @assertion_count += 1
596
609
  Foo.stub5 :blocking, Bar.new do
@@ -810,7 +823,7 @@ class TestMinitestStub < Minitest::Test
810
823
  end
811
824
  end
812
825
  exp = "undefined method `write' for nil:NilClass"
813
- assert_equal exp, e.message
826
+ assert_match exp, e.message
814
827
  end
815
828
 
816
829
  def test_stub_value_block_args_6
@@ -1,5 +1,6 @@
1
1
  require "minitest/autorun"
2
2
  require "minitest/metametameta"
3
+ require "forwardable"
3
4
 
4
5
  class Runnable
5
6
  def woot
@@ -12,25 +13,18 @@ class TestMinitestReporter < MetaMetaMetaTestCase
12
13
  attr_accessor :r, :io
13
14
 
14
15
  def new_composite_reporter
16
+ # Ruby bug in older versions of 2.2 & 2.3 on all platforms
17
+ # Latest Windows builds were 2.2.6 and 2.3.3. Latest Ruby releases were
18
+ # 2.2.10 and 2.3.8.
19
+ skip if windows? && RUBY_VERSION < '2.4'
15
20
  reporter = Minitest::CompositeReporter.new
16
21
  reporter << Minitest::SummaryReporter.new(self.io)
17
22
  reporter << Minitest::ProgressReporter.new(self.io)
18
23
 
19
- def reporter.first
20
- reporters.first
21
- end
22
-
23
- def reporter.results
24
- first.results
25
- end
26
-
27
- def reporter.count
28
- first.count
29
- end
30
-
31
- def reporter.assertions
32
- first.assertions
33
- end
24
+ # eg reporter.results -> reporters.first.results
25
+ reporter.extend Forwardable
26
+ reporter.delegate :first => :reporters
27
+ reporter.delegate %i[results count assertions options to_s] => :first
34
28
 
35
29
  reporter
36
30
  end
@@ -86,7 +80,25 @@ class TestMinitestReporter < MetaMetaMetaTestCase
86
80
  def test_to_s
87
81
  r.record passing_test
88
82
  r.record fail_test
89
- assert_match "woot", r.first.to_s
83
+ assert_match "woot", r.to_s
84
+ end
85
+
86
+ def test_options_skip_F
87
+ r.options[:skip] = "F"
88
+
89
+ r.record passing_test
90
+ r.record fail_test
91
+
92
+ refute_match "woot", r.to_s
93
+ end
94
+
95
+ def test_options_skip_E
96
+ r.options[:skip] = "E"
97
+
98
+ r.record passing_test
99
+ r.record error_test
100
+
101
+ refute_match "RuntimeError: no", r.to_s
90
102
  end
91
103
 
92
104
  def test_passed_eh_empty
@@ -126,7 +138,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
126
138
  end
127
139
 
128
140
  def test_passed_eh_skipped_verbose
129
- r.first.options[:verbose] = true
141
+ r.options[:verbose] = true
130
142
 
131
143
  r.start
132
144
  r.results << skip_test
@@ -590,9 +590,10 @@ describe Minitest::Spec do
590
590
  end
591
591
 
592
592
  it "needs to verify throw" do
593
- @assertion_count += 2 # 2 extra tests
593
+ @assertion_count += 4 # 2 extra tests
594
594
 
595
- assert_success expect { throw :blah }.must_throw(:blah)
595
+ assert_nil expect { throw :blah }.must_throw(:blah)
596
+ assert_equal 42, expect { throw :blah, 42 }.must_throw(:blah)
596
597
 
597
598
  assert_triggered "Expected :blah to have been thrown." do
598
599
  expect {}.must_throw :blah
@@ -803,6 +803,25 @@ class TestMinitestRunnable < Minitest::Test
803
803
  assert_equal @tc.failures, over_the_wire.failures
804
804
  assert_equal @tc.klass, over_the_wire.klass
805
805
  end
806
+
807
+ def test_spec_marshal_with_exception
808
+ klass = describe("whatever") { it("passes") { raise Class.new(StandardError)} }
809
+ rm = klass.runnable_methods.first
810
+
811
+ # Run the test
812
+ @tc = klass.new(rm).run
813
+
814
+ assert_kind_of Minitest::Result, @tc
815
+
816
+ # Pass it over the wire
817
+ over_the_wire = Marshal.load Marshal.dump @tc
818
+
819
+ assert_equal @tc.time, over_the_wire.time
820
+ assert_equal @tc.name, over_the_wire.name
821
+ assert_equal @tc.assertions, over_the_wire.assertions
822
+ assert_equal @tc.failures, over_the_wire.failures
823
+ assert_equal @tc.klass, over_the_wire.klass
824
+ end
806
825
  end
807
826
 
808
827
  class TestMinitestTest < TestMinitestRunnable
@@ -848,19 +867,25 @@ class TestMinitestUnitTestCase < Minitest::Test
848
867
  $VERBOSE = orig_verbose
849
868
  end
850
869
 
870
+ def sample_test_case(rand)
871
+ srand rand
872
+ Class.new FakeNamedTest do
873
+ 100.times do |i|
874
+ define_method("test_#{i}") { assert true }
875
+ end
876
+ end.runnable_methods
877
+ end
878
+
879
+ # srand varies with OS
851
880
  def test_runnable_methods_random
852
881
  @assertion_count = 0
853
882
 
854
- sample_test_case = Class.new FakeNamedTest do
855
- def self.test_order; :random; end
856
- def test_test1; assert "does not matter" end
857
- def test_test2; assert "does not matter" end
858
- def test_test3; assert "does not matter" end
859
- end
883
+ random_tests_1 = sample_test_case 42
884
+ random_tests_2 = sample_test_case 42
885
+ random_tests_3 = sample_test_case 1_000
860
886
 
861
- srand 42
862
- expected = %w[test_test2 test_test1 test_test3]
863
- assert_equal expected, sample_test_case.runnable_methods
887
+ assert_equal random_tests_1, random_tests_2
888
+ refute_equal random_tests_1, random_tests_3
864
889
  end
865
890
 
866
891
  def test_runnable_methods_sorted
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.14.1
4
+ version: 5.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBBDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE5MTIxMzAwMDIwNFoXDTIwMTIxMjAwMDIwNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIwMTIyMjIwMzgzMFoXDTIxMTIyMjIwMzgzMFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCkkcHqAa6IKLYGl93rn78J3L+LnqyxaA059n4IGMHWN5bv9KBQnIjOrpLadtYZ
26
- vhWkunWDKdfVapBEq5+T4HzqnsEXC3aCv6JEKJY6Zw7iSzl0M8hozuzRr+w46wvT
27
- fV2yTN6QTVxqbMsJJyjosks4ZdQYov2zdvQpt1HsLi+Qmckmg8SPZsd+T8uiiBCf
28
- b+1ORSM5eEfBQenPXy83LZcoQz8i6zVB4aAfTGGdhxjoMGUEmSZ6xpkOzmnGa9QK
29
- m5x9IDiApM+vCELNwDXXGNFEnQBBK+wAe4Pek8o1V1TTOxL1kGPewVOitX1p3xoN
30
- h7iEjga8iM1LbZUfiISZ+WrB
25
+ AQAE3XRm1YZcCVjAJy5yMZvTOFrS7B2SYErc+0QwmKYbHztTTDY2m5Bii+jhpuxh
26
+ H+ETcU1z8TUKLpsBUP4kUpIRowkVN1p/jKapV8T3Rbwq+VuYFe+GMKsf8wGZSecG
27
+ oMQ8DzzauZfbvhe2kDg7G9BBPU0wLQlY25rDcCy9bLnD7R0UK3ONqpwvsI5I7x5X
28
+ ZIMXR0a9/DG+55mawwdGzCQobDKiSNLK89KK7OcNTALKU0DfgdTkktdgKchzKHqZ
29
+ d/AHw/kcnU6iuMUoJEcGiJd4gVCTn1l3cDcIvxakGslCA88Jubw0Sqatan0TnC9g
30
+ KToW560QIey7SPfHWduzFJnV
31
31
  -----END CERTIFICATE-----
32
- date: 2020-05-16 00:00:00.000000000 Z
32
+ date: 2021-12-15 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -161,7 +161,7 @@ licenses:
161
161
  metadata:
162
162
  homepage_uri: https://github.com/seattlerb/minitest
163
163
  bug_tracker_uri: https://github.com/seattlerb/minitest/issues
164
- post_install_message:
164
+ post_install_message:
165
165
  rdoc_options:
166
166
  - "--main"
167
167
  - README.rdoc
@@ -169,17 +169,20 @@ require_paths:
169
169
  - lib
170
170
  required_ruby_version: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - "~>"
172
+ - - ">="
173
173
  - !ruby/object:Gem::Version
174
174
  version: '2.2'
175
+ - - "<"
176
+ - !ruby/object:Gem::Version
177
+ version: '4.0'
175
178
  required_rubygems_version: !ruby/object:Gem::Requirement
176
179
  requirements:
177
180
  - - ">="
178
181
  - !ruby/object:Gem::Version
179
182
  version: '0'
180
183
  requirements: []
181
- rubygems_version: 3.0.3
182
- signing_key:
184
+ rubygems_version: 3.2.16
185
+ signing_key:
183
186
  specification_version: 4
184
187
  summary: minitest provides a complete suite of testing facilities supporting TDD,
185
188
  BDD, mocking, and benchmarking
metadata.gz.sig CHANGED
Binary file