minitest 5.9.1 → 5.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45b2bfd6246154ea0c90600c09def193d9521a93
4
- data.tar.gz: 25c490162019763e15b7c701d550034102d5a907
3
+ metadata.gz: 48297af06eab4424d8838e3313b009557efd6d89
4
+ data.tar.gz: 55fc554fbf6475f7d1f59e101b0deedc81c7dd54
5
5
  SHA512:
6
- metadata.gz: 41ce137f8c906c21cd21742bdab148f90e6e595202133edabda0ad20a75164f2a0d06338892734d4e1f72b31a496cfe8df64d1d3e3bec9f6ce12743e3b99bfab
7
- data.tar.gz: 5c3cac4d95858c58afe7ab572b31a369a51dcb205189584bb8f9604290b8e8942ee2a2d17eeb727924691fd0b63600745a165a07d09143bff54b5cf2c4d01923
6
+ metadata.gz: 4a43c8e38da3dc9b26147b7e0242d7d95875b35c23be0965a8811bf16754cb58eab55ec763cfaa34c5f2a056c0defe9a4460b79005a36f48f73949d6fdf68081
7
+ data.tar.gz: 0aefd1de07da46c5f4e90b43946f88c64740503ec003f27869804c0a380b071e06d9648a6b6c3c339d588a02e9ab26cac269092a0f7fb4783f7df5d6eaaff103
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,14 @@
1
+ === 5.10.0 / 2016-11-30
2
+
3
+ * 2 minor enhancements:
4
+
5
+ * Added AbstractReporter#prerecord and extended ProgressReporter and CompositeReporter to use it.
6
+ * Minor optimization: remove runnables with no runnable methods before run.
7
+
8
+ * 1 bug fix:
9
+
10
+ * 2.4: removed deprecation warnings when referring to Fixnum.
11
+
1
12
  === 5.9.1 / 2016-09-25
2
13
 
3
14
  * 2 bug fixes:
@@ -325,7 +325,7 @@ bogus example:
325
325
 
326
326
  Minitest uses composite reporter to output test results using multiple
327
327
  reporter instances. You can add new reporters to the composite during
328
- the init_plugins phase. As we saw in +plugin_bonus_init+ above, you
328
+ the init_plugins phase. As we saw in +plugin_bogus_init+ above, you
329
329
  simply add your reporter instance to the composite via <tt><<</tt>.
330
330
 
331
331
  +AbstractReporter+ defines the API for reporters. You may subclass it
@@ -466,7 +466,7 @@ minitest-around :: Around block for minitest. An alternative to
466
466
  setup/teardown dance.
467
467
  minitest-assert_errors :: Adds Minitest assertions to test for errors raised
468
468
  or not raised by Minitest itself.
469
- minitest-autotest :: autotest is a continous testing facility meant to
469
+ minitest-autotest :: autotest is a continuous testing facility meant to
470
470
  be used during development.
471
471
  minitest-bacon :: minitest-bacon extends minitest with bacon-like
472
472
  functionality.
@@ -605,6 +605,10 @@ Authors... Please send me a pull request with a description of your minitest ext
605
605
  * minitest-sugar
606
606
  * spork-minitest
607
607
 
608
+ == Minitest related goods
609
+
610
+ * minitest/pride fabric: http://www.spoonflower.com/fabric/3928730-again-by-katie_allen
611
+
608
612
  == REQUIREMENTS:
609
613
 
610
614
  * Ruby 1.8.7+. No magic is involved. I hope.
data/Rakefile CHANGED
@@ -11,13 +11,27 @@ Hoe.spec "minitest" do
11
11
 
12
12
  license "MIT"
13
13
 
14
- self.testlib = :minitest
14
+ ## TODO: uncomment this on the last point release on 5.x
15
+ #
16
+ # self.post_install_message = <<-"EOM"
17
+ # NOTE: minitest 5 will be the last in the minitest family to support
18
+ # ruby 1.8 and 1.9 (and maybe 2.0?). If you need to keep using 1.8
19
+ # or 1.9, you need to pin your dependency to minitest with
20
+ # something like "~> 5.0".
21
+ #
22
+ # Further, minitest 6 will be dropping the following:
23
+ #
24
+ # + MiniTest (it's been Minitest for *years*)
25
+ # + MiniTest::Unit
26
+ # + MiniTest::Unit::TestCase
27
+ # + assert_send (unless you argue for it well)
28
+ # EOM
15
29
  end
16
30
 
17
31
  desc "Find missing expectations"
18
32
  task :specs do
19
33
  $:.unshift "lib"
20
- require "minitest/unit"
34
+ require "minitest/test"
21
35
  require "minitest/spec"
22
36
 
23
37
  pos_prefix, neg_prefix = "must", "wont"
@@ -7,7 +7,7 @@ require "minitest/parallel"
7
7
  # :include: README.rdoc
8
8
 
9
9
  module Minitest
10
- VERSION = "5.9.1" # :nodoc:
10
+ VERSION = "5.10.0" # :nodoc:
11
11
  ENCS = "".respond_to? :encoding # :nodoc:
12
12
 
13
13
  @@installed_at_exit ||= false
@@ -147,7 +147,7 @@ module Minitest
147
147
  # sub-classes to run.
148
148
 
149
149
  def self.__run reporter, options
150
- suites = Runnable.runnables.shuffle
150
+ suites = Runnable.runnables.reject { |s| s.runnable_methods.empty? }.shuffle
151
151
  parallel, serial = suites.partition { |s| s.test_order == :parallel }
152
152
 
153
153
  # If we run the parallel tests before the serial tests, the parallel tests
@@ -319,6 +319,7 @@ module Minitest
319
319
  # test. See Minitest::ParallelTest::ClassMethods for an example.
320
320
 
321
321
  def self.run_one_method klass, method_name, reporter
322
+ reporter.prerecord klass, method_name
322
323
  reporter.record Minitest.run_one_method(klass, method_name)
323
324
  end
324
325
 
@@ -429,6 +430,13 @@ module Minitest
429
430
  def start
430
431
  end
431
432
 
433
+ ##
434
+ # About to start running a test. This allows a reporter to show
435
+ # that it is starting or that we are in the middle of a test run.
436
+
437
+ def prerecord klass, name
438
+ end
439
+
432
440
  ##
433
441
  # Record a result and output the Runnable#result_code. Stores the
434
442
  # result of the run if the run did not pass.
@@ -477,9 +485,15 @@ module Minitest
477
485
  # own.
478
486
 
479
487
  class ProgressReporter < Reporter
488
+ def prerecord klass, name
489
+ if options[:verbose] then
490
+ io.print "%s#%s = " % [klass, name]
491
+ io.flush
492
+ end
493
+ end
494
+
480
495
  def record result # :nodoc:
481
- io.print "%s#%s = %.2f s = " % [result.class, result.name, result.time] if
482
- options[:verbose]
496
+ io.print "%.2f s = " % [result.time] if options[:verbose]
483
497
  io.print result.result_code
484
498
  io.puts if options[:verbose]
485
499
  end
@@ -648,6 +662,12 @@ module Minitest
648
662
  self.reporters.each(&:start)
649
663
  end
650
664
 
665
+ def prerecord klass, name # :nodoc:
666
+ self.reporters.each do |reporter|
667
+ reporter.prerecord klass, name
668
+ end
669
+ end
670
+
651
671
  def record result # :nodoc:
652
672
  self.reporters.each do |reporter|
653
673
  reporter.record result
@@ -785,9 +805,11 @@ module Minitest
785
805
 
786
806
  return bt.dup if $DEBUG
787
807
 
788
- new_bt = bt.take_while { |line| line !~ /lib\/minitest/ }
789
- new_bt = bt.select { |line| line !~ /lib\/minitest/ } if new_bt.empty?
790
- new_bt = bt.dup if new_bt.empty?
808
+ mt_re = %r%lib/minitest%
809
+
810
+ new_bt = bt.take_while { |line| line !~ mt_re }
811
+ new_bt = bt.select { |line| line !~ mt_re } if new_bt.empty?
812
+ new_bt = bt.dup if new_bt.empty?
791
813
 
792
814
  new_bt
793
815
  end
@@ -801,7 +823,9 @@ module Minitest
801
823
  result
802
824
  end
803
825
 
804
- if defined? Process::CLOCK_MONOTONIC
826
+ # :stopdoc:
827
+
828
+ if defined? Process::CLOCK_MONOTONIC # :nodoc:
805
829
  def self.clock_time
806
830
  Process.clock_gettime Process::CLOCK_MONOTONIC
807
831
  end
@@ -810,6 +834,8 @@ module Minitest
810
834
  Time.now
811
835
  end
812
836
  end
837
+
838
+ # :startdoc:
813
839
  end
814
840
 
815
841
  require "minitest/test"
@@ -171,7 +171,17 @@ module Minitest
171
171
 
172
172
  def assert_equal exp, act, msg = nil
173
173
  msg = message(msg, E) { diff exp, act }
174
- assert exp == act, msg
174
+ result = assert exp == act, msg
175
+
176
+ if exp.nil? then
177
+ if Minitest::VERSION =~ /^6/ then
178
+ refute_nil exp, "Use assert_nil if expecting nil."
179
+ else
180
+ $stderr.puts "Use assert_nil if expecting nil from #{caller.first}. This will fail in MT6."
181
+ end
182
+ end
183
+
184
+ result
175
185
  end
176
186
 
177
187
  ##
@@ -357,6 +367,8 @@ module Minitest
357
367
  # Fails unless the call returns a true value
358
368
 
359
369
  def assert_send send_ary, m = nil
370
+ warn "DEPRECATED: assert_send. From #{caller.first}"
371
+
360
372
  recv, msg, *args = send_ary
361
373
  m = message(m) {
362
374
  "Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
@@ -386,8 +398,10 @@ module Minitest
386
398
  rescue ThreadError => e # wtf?!? 1.8 + threads == suck
387
399
  default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
388
400
  rescue ArgumentError => e # 1.9 exception
401
+ raise e unless e.message.include?("uncaught throw")
389
402
  default += ", not #{e.message.split(/ /).last}"
390
403
  rescue NameError => e # 1.8 exception
404
+ raise e unless e.name == sym
391
405
  default += ", not #{e.name.inspect}"
392
406
  end
393
407
  caught = false
@@ -1,4 +1,4 @@
1
- require "minitest/unit"
1
+ require "minitest/test"
2
2
  require "minitest/spec"
3
3
 
4
4
  module Minitest
@@ -37,7 +37,7 @@ module Minitest # :nodoc:
37
37
  end
38
38
  end
39
39
 
40
- def initialize(delegator = nil) # :nodoc:
40
+ def initialize delegator = nil # :nodoc:
41
41
  @delegator = delegator
42
42
  @expected_calls = Hash.new { |calls, name| calls[name] = [] }
43
43
  @actual_calls = Hash.new { |calls, name| calls[name] = [] }
@@ -67,7 +67,7 @@ module Minitest # :nodoc:
67
67
  # @mock.expect(:uses_one_string, true, ["foo"])
68
68
  # @mock.uses_one_string("bar") # => raises MockExpectationError
69
69
 
70
- def expect(name, retval, args = [], &blk)
70
+ def expect name, retval, args = [], &blk
71
71
  name = name.to_sym
72
72
 
73
73
  if block_given?
@@ -104,7 +104,7 @@ module Minitest # :nodoc:
104
104
  true
105
105
  end
106
106
 
107
- def method_missing(sym, *args, &block) # :nodoc:
107
+ def method_missing sym, *args, &block # :nodoc:
108
108
  unless @expected_calls.key?(sym) then
109
109
  if @delegator && @delegator.respond_to?(sym)
110
110
  return @delegator.public_send(sym, *args, &block)
@@ -158,7 +158,7 @@ module Minitest # :nodoc:
158
158
  retval
159
159
  end
160
160
 
161
- def respond_to?(sym, include_private = false) # :nodoc:
161
+ def respond_to? sym, include_private = false # :nodoc:
162
162
  return true if @expected_calls.key? sym.to_sym
163
163
  return true if @delegator && @delegator.respond_to?(sym, include_private)
164
164
  __respond_to?(sym, include_private)
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
- module Parallel
2
+ module Parallel #:nodoc:
3
3
 
4
4
  ##
5
5
  # The engine used to run multiple tests in parallel.
@@ -70,7 +70,7 @@ module Minitest
70
70
  end
71
71
  end
72
72
 
73
- def puts(*o) # :nodoc:
73
+ def puts *o # :nodoc:
74
74
  o.map! { |s|
75
75
  s.to_s.sub(/Finished/) {
76
76
  @index = 0
@@ -132,7 +132,7 @@ class Minitest::Spec < Minitest::Test
132
132
  # desc.superclass == ActiveRecord::Base
133
133
  # end
134
134
 
135
- def register_spec_type(*args, &block)
135
+ def register_spec_type *args, &block
136
136
  if block then
137
137
  matcher, klass = block, args.first
138
138
  else
@@ -37,9 +37,7 @@ module Minitest
37
37
  def self.make_my_diffs_pretty!
38
38
  require "pp"
39
39
 
40
- define_method :mu_pp do |o|
41
- o.pretty_inspect
42
- end
40
+ define_method :mu_pp, &:pretty_inspect
43
41
  end
44
42
 
45
43
  ##
@@ -34,7 +34,7 @@ module Minitest
34
34
  Minitest.autorun
35
35
  end
36
36
 
37
- def self.after_tests(&b) # :nodoc:
37
+ def self.after_tests &b # :nodoc:
38
38
  from = caller.first
39
39
  warn "MiniTest::Unit.after_tests is now Minitest.after_run. From #{from}"
40
40
  Minitest.after_run(&b)
@@ -8,6 +8,17 @@ class Minitest::Test
8
8
  end
9
9
  end
10
10
 
11
+ class FakeNamedTest < Minitest::Test
12
+ @@count = 0
13
+
14
+ def self.name
15
+ @fake_name ||= begin
16
+ @@count += 1
17
+ "FakeNamedTest%02d" % @@count
18
+ end
19
+ end
20
+ end
21
+
11
22
  class MetaMetaMetaTestCase < Minitest::Test
12
23
  attr_accessor :reporter, :output, :tu
13
24
 
@@ -174,10 +174,10 @@ class TestMinitestMock < Minitest::Test
174
174
  end
175
175
 
176
176
  def test_mock_is_a_blank_slate
177
- @mock.expect :kind_of?, true, [Fixnum]
177
+ @mock.expect :kind_of?, true, [String]
178
178
  @mock.expect :==, true, [1]
179
179
 
180
- assert @mock.kind_of?(Fixnum), "didn't mock :kind_of\?"
180
+ assert @mock.kind_of?(String), "didn't mock :kind_of\?"
181
181
  assert @mock == 1, "didn't mock :=="
182
182
  end
183
183
 
@@ -473,11 +473,11 @@ class TestMinitestStub < Minitest::Test
473
473
  @assertion_count = 2
474
474
 
475
475
  dynamic = Class.new do
476
- def self.respond_to?(meth)
476
+ def self.respond_to? meth
477
477
  meth == :found
478
478
  end
479
479
 
480
- def self.method_missing(meth, *args, &block)
480
+ def self.method_missing meth, *args, &block
481
481
  if meth == :found
482
482
  false
483
483
  else
@@ -501,8 +501,8 @@ class TestMinitestStub < Minitest::Test
501
501
  end
502
502
  rs = nil
503
503
 
504
- File.stub(:open, true, mock) do
505
- File.open("foo.txt", "r") do |f|
504
+ File.stub :open, true, mock do
505
+ File.open "foo.txt", "r" do |f|
506
506
  rs = f.write
507
507
  end
508
508
  end
@@ -12,6 +12,9 @@ class ExampleA; end
12
12
  class ExampleB < ExampleA; end
13
13
 
14
14
  describe Minitest::Spec do
15
+ # helps to deal with 2.4 deprecation of Fixnum for Integer
16
+ Int = 1.class
17
+
15
18
  # do not parallelize this suite... it just can"t handle it.
16
19
 
17
20
  def assert_triggered expected = "blah", klass = Minitest::Assertion
@@ -115,7 +118,7 @@ describe Minitest::Spec do
115
118
  @assertion_count -= 1 # no msg
116
119
  @assertion_count += 2 # assert_output is 2 assertions
117
120
 
118
- proc { }.must_be_silent.must_equal true
121
+ proc {}.must_be_silent.must_equal true
119
122
 
120
123
  assert_triggered "In stdout.\nExpected: \"\"\n Actual: \"xxx\"" do
121
124
  proc { print "xxx" }.must_be_silent
@@ -304,7 +307,7 @@ describe Minitest::Spec do
304
307
  it "needs to verify inequality" do
305
308
  @assertion_count += 2
306
309
  42.wont_equal(6 * 9).must_equal false
307
- proc{}.wont_equal(42).must_equal false
310
+ proc {}.wont_equal(42).must_equal false
308
311
 
309
312
  assert_triggered "Expected 1 to not be equal to 1." do
310
313
  1.wont_equal 1
@@ -318,12 +321,12 @@ describe Minitest::Spec do
318
321
  it "needs to verify instances of a class" do
319
322
  42.wont_be_instance_of(String).must_equal false
320
323
 
321
- assert_triggered "Expected 42 to not be an instance of Fixnum." do
322
- 42.wont_be_instance_of Fixnum
324
+ assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
325
+ 42.wont_be_kind_of Int
323
326
  end
324
327
 
325
- assert_triggered "msg.\nExpected 42 to not be an instance of Fixnum." do
326
- 42.wont_be_instance_of Fixnum, "msg"
328
+ assert_triggered "msg.\nExpected 42 to not be an instance of #{Int.name}." do
329
+ 42.wont_be_instance_of Int, "msg"
327
330
  end
328
331
  end
329
332
 
@@ -331,34 +334,34 @@ describe Minitest::Spec do
331
334
  @assertion_count += 2
332
335
 
333
336
  42.wont_be_kind_of(String).must_equal false
334
- proc{}.wont_be_kind_of(String).must_equal false
337
+ proc {}.wont_be_kind_of(String).must_equal false
335
338
 
336
- assert_triggered "Expected 42 to not be a kind of Integer." do
337
- 42.wont_be_kind_of Integer
339
+ assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
340
+ 42.wont_be_kind_of Int
338
341
  end
339
342
 
340
- assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
341
- 42.wont_be_kind_of Integer, "msg"
343
+ assert_triggered "msg.\nExpected 42 to not be a kind of #{Int.name}." do
344
+ 42.wont_be_kind_of Int, "msg"
342
345
  end
343
346
  end
344
347
 
345
348
  it "needs to verify kinds of objects" do
346
349
  @assertion_count += 3 # extra test
347
350
 
348
- (6 * 7).must_be_kind_of(Fixnum).must_equal true
351
+ (6 * 7).must_be_kind_of(Int).must_equal true
349
352
  (6 * 7).must_be_kind_of(Numeric).must_equal true
350
353
 
351
- assert_triggered "Expected 42 to be a kind of String, not Fixnum." do
354
+ assert_triggered "Expected 42 to be a kind of String, not #{Int.name}." do
352
355
  (6 * 7).must_be_kind_of String
353
356
  end
354
357
 
355
- assert_triggered "msg.\nExpected 42 to be a kind of String, not Fixnum." do
358
+ assert_triggered "msg.\nExpected 42 to be a kind of String, not #{Int.name}." do
356
359
  (6 * 7).must_be_kind_of String, "msg"
357
360
  end
358
361
 
359
362
  exp = "Expected #<Proc:0xXXXXXX@PATH> to be a kind of String, not Proc."
360
363
  assert_triggered exp do
361
- proc{}.must_be_kind_of String
364
+ proc {}.must_be_kind_of String
362
365
  end
363
366
  end
364
367
 
@@ -502,7 +505,7 @@ describe Minitest::Spec do
502
505
  proc { throw :blah }.must_throw(:blah).must_equal true
503
506
 
504
507
  assert_triggered "Expected :blah to have been thrown." do
505
- proc { }.must_throw :blah
508
+ proc {}.must_throw :blah
506
509
  end
507
510
 
508
511
  assert_triggered "Expected :blah to have been thrown, not :xxx." do
@@ -510,7 +513,7 @@ describe Minitest::Spec do
510
513
  end
511
514
 
512
515
  assert_triggered "msg.\nExpected :blah to have been thrown." do
513
- proc { }.must_throw :blah, "msg"
516
+ proc {}.must_throw :blah, "msg"
514
517
  end
515
518
 
516
519
  assert_triggered "msg.\nExpected :blah to have been thrown, not :xxx." do
@@ -519,9 +522,9 @@ describe Minitest::Spec do
519
522
  end
520
523
 
521
524
  it "needs to verify types of objects" do
522
- (6 * 7).must_be_instance_of(Fixnum).must_equal true
525
+ (6 * 7).must_be_instance_of(Int).must_equal true
523
526
 
524
- exp = "Expected 42 to be an instance of String, not Fixnum."
527
+ exp = "Expected 42 to be an instance of String, not #{Int.name}."
525
528
 
526
529
  assert_triggered exp do
527
530
  (6 * 7).must_be_instance_of String
@@ -565,11 +568,11 @@ describe Minitest::Spec do
565
568
  it "needs to verify using respond_to" do
566
569
  42.must_respond_to(:+).must_equal true
567
570
 
568
- assert_triggered "Expected 42 (Fixnum) to respond to #clear." do
571
+ assert_triggered "Expected 42 (#{Int.name}) to respond to #clear." do
569
572
  42.must_respond_to :clear
570
573
  end
571
574
 
572
- assert_triggered "msg.\nExpected 42 (Fixnum) to respond to #clear." do
575
+ assert_triggered "msg.\nExpected 42 (#{Int.name}) to respond to #clear." do
573
576
  42.must_respond_to :clear, "msg"
574
577
  end
575
578
  end
@@ -626,7 +629,7 @@ describe Minitest::Spec, :let do
626
629
  end
627
630
 
628
631
  it "procs come after dont_flip" do
629
- p = proc { }
632
+ p = proc {}
630
633
  assert_respond_to p, :call
631
634
  p.must_respond_to :call
632
635
  end
@@ -947,21 +950,21 @@ class ValueMonadTest < Minitest::Test
947
950
  attr_accessor :struct
948
951
 
949
952
  def setup
950
- @struct = { :_ => 'a', :value => 'b', :expect => 'c' }
953
+ @struct = { :_ => "a", :value => "b", :expect => "c" }
951
954
  def @struct.method_missing k # think openstruct
952
955
  self[k]
953
956
  end
954
957
  end
955
958
 
956
959
  def test_value_monad_method
957
- assert_equal 'a', struct._
960
+ assert_equal "a", struct._
958
961
  end
959
962
 
960
963
  def test_value_monad_value_alias
961
- assert_equal 'b', struct.value
964
+ assert_equal "b", struct.value
962
965
  end
963
966
 
964
967
  def test_value_monad_expect_alias
965
- assert_equal 'c', struct.expect
968
+ assert_equal "c", struct.expect
966
969
  end
967
970
  end
@@ -67,7 +67,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
67
67
  # end
68
68
 
69
69
  def test_passed_eh_teardown_good
70
- test_class = Class.new Minitest::Test do
70
+ test_class = Class.new FakeNamedTest do
71
71
  def teardown; assert true; end
72
72
  def test_omg; assert true; end
73
73
  end
@@ -78,7 +78,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
78
78
  end
79
79
 
80
80
  def test_passed_eh_teardown_skipped
81
- test_class = Class.new Minitest::Test do
81
+ test_class = Class.new FakeNamedTest do
82
82
  def teardown; assert true; end
83
83
  def test_omg; skip "bork"; end
84
84
  end
@@ -91,7 +91,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
91
91
  end
92
92
 
93
93
  def test_passed_eh_teardown_flunked
94
- test_class = Class.new Minitest::Test do
94
+ test_class = Class.new FakeNamedTest do
95
95
  def teardown; flunk; end
96
96
  def test_omg; assert true; end
97
97
  end
@@ -138,7 +138,7 @@ class TestMinitestUnitInherited < MetaMetaMetaTestCase
138
138
  def test_inherited_hook_plays_nice_with_others
139
139
  with_overridden_include do
140
140
  assert_throws :inherited_hook do
141
- Class.new Minitest::Test
141
+ Class.new FakeNamedTest
142
142
  end
143
143
  end
144
144
  end
@@ -158,7 +158,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
158
158
 
159
159
  def test_run_test
160
160
  @tu =
161
- Class.new Minitest::Test do
161
+ Class.new FakeNamedTest do
162
162
  attr_reader :foo
163
163
 
164
164
  def run
@@ -187,7 +187,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
187
187
 
188
188
  def test_run_error
189
189
  @tu =
190
- Class.new Minitest::Test do
190
+ Class.new FakeNamedTest do
191
191
  def test_something
192
192
  assert true
193
193
  end
@@ -215,7 +215,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
215
215
 
216
216
  def test_run_error_teardown
217
217
  @tu =
218
- Class.new Minitest::Test do
218
+ Class.new FakeNamedTest do
219
219
  def test_something
220
220
  assert true
221
221
  end
@@ -261,7 +261,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
261
261
 
262
262
  def setup_basic_tu
263
263
  @tu =
264
- Class.new Minitest::Test do
264
+ Class.new FakeNamedTest do
265
265
  def test_something
266
266
  assert true
267
267
  end
@@ -289,14 +289,14 @@ class TestMinitestRunner < MetaMetaMetaTestCase
289
289
  def assert_filtering filter, name, expected, a = false
290
290
  args = %W[--#{filter} #{name} --seed 42]
291
291
 
292
- alpha = Class.new Minitest::Test do
292
+ alpha = Class.new FakeNamedTest do
293
293
  define_method :test_something do
294
294
  assert a
295
295
  end
296
296
  end
297
297
  Object.const_set(:Alpha, alpha)
298
298
 
299
- beta = Class.new Minitest::Test do
299
+ beta = Class.new FakeNamedTest do
300
300
  define_method :test_something do
301
301
  assert true
302
302
  end
@@ -320,7 +320,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
320
320
  1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
321
321
  EOM
322
322
 
323
- assert_filtering 'name', "/Beta#test_something/", expected
323
+ assert_filtering "name", "/Beta#test_something/", expected
324
324
  end
325
325
 
326
326
  def test_run_filtered_including_suite_name_string
@@ -332,7 +332,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
332
332
  1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
333
333
  EOM
334
334
 
335
- assert_filtering 'name', "Beta#test_something", expected
335
+ assert_filtering "name", "Beta#test_something", expected
336
336
  end
337
337
 
338
338
  def test_run_filtered_string_method_only
@@ -344,7 +344,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
344
344
  2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
345
345
  EOM
346
346
 
347
- assert_filtering 'name', "test_something", expected, :pass
347
+ assert_filtering "name", "test_something", expected, :pass
348
348
  end
349
349
 
350
350
  def test_run_failing_excluded
@@ -370,7 +370,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
370
370
  1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
371
371
  EOM
372
372
 
373
- assert_filtering 'exclude', "/Alpha#test_something/", expected
373
+ assert_filtering "exclude", "/Alpha#test_something/", expected
374
374
  end
375
375
 
376
376
  def test_run_filtered_excluding_suite_name_string
@@ -382,7 +382,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
382
382
  1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
383
383
  EOM
384
384
 
385
- assert_filtering 'exclude', "Alpha#test_something", expected
385
+ assert_filtering "exclude", "Alpha#test_something", expected
386
386
  end
387
387
 
388
388
  def test_run_filtered_excluding_string_method_only
@@ -394,12 +394,12 @@ class TestMinitestRunner < MetaMetaMetaTestCase
394
394
  0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
395
395
  EOM
396
396
 
397
- assert_filtering 'exclude', "test_something", expected, :pass
397
+ assert_filtering "exclude", "test_something", expected, :pass
398
398
  end
399
399
 
400
400
  def test_run_passing
401
401
  @tu =
402
- Class.new Minitest::Test do
402
+ Class.new FakeNamedTest do
403
403
  def test_something
404
404
  assert true
405
405
  end
@@ -418,7 +418,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
418
418
 
419
419
  def test_run_skip
420
420
  @tu =
421
- Class.new Minitest::Test do
421
+ Class.new FakeNamedTest do
422
422
  def test_something
423
423
  assert true
424
424
  end
@@ -445,7 +445,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
445
445
 
446
446
  def test_run_skip_verbose
447
447
  @tu =
448
- Class.new Minitest::Test do
448
+ Class.new FakeNamedTest do
449
449
  def test_something
450
450
  assert true
451
451
  end
@@ -473,7 +473,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
473
473
 
474
474
  def test_run_with_other_runner
475
475
  @tu =
476
- Class.new Minitest::Test do
476
+ Class.new FakeNamedTest do
477
477
  def self.run reporter, options = {}
478
478
  @reporter = reporter
479
479
  before_my_suite
@@ -548,7 +548,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
548
548
  }
549
549
 
550
550
  @tu =
551
- Class.new Minitest::Test do
551
+ Class.new FakeNamedTest do
552
552
  parallelize_me!
553
553
 
554
554
  test_count.times do |i|
@@ -596,7 +596,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
596
596
  def test_before_setup
597
597
  call_order = []
598
598
  @tu =
599
- Class.new Minitest::Test do
599
+ Class.new FakeNamedTest do
600
600
  define_method :setup do
601
601
  super()
602
602
  call_order << :setup
@@ -618,7 +618,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
618
618
  def test_after_teardown
619
619
  call_order = []
620
620
  @tu =
621
- Class.new Minitest::Test do
621
+ Class.new FakeNamedTest do
622
622
  define_method :teardown do
623
623
  super()
624
624
  call_order << :teardown
@@ -640,7 +640,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
640
640
  def test_all_teardowns_are_guaranteed_to_run
641
641
  call_order = []
642
642
  @tu =
643
- Class.new Minitest::Test do
643
+ Class.new FakeNamedTest do
644
644
  define_method :after_teardown do
645
645
  super()
646
646
  call_order << :after_teardown
@@ -671,7 +671,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
671
671
  def test_setup_and_teardown_survive_inheritance
672
672
  call_order = []
673
673
 
674
- @tu = Class.new Minitest::Test do
674
+ @tu = Class.new FakeNamedTest do
675
675
  define_method :setup do
676
676
  call_order << :setup_method
677
677
  end
@@ -979,6 +979,29 @@ class TestMinitestUnitTestCase < Minitest::Test
979
979
  end
980
980
  end
981
981
 
982
+ def test_assert_equal_does_not_allow_lhs_nil
983
+ if Minitest::VERSION =~ /^6/ then
984
+ warn "Time to strip the MT5 test"
985
+
986
+ @assertion_count += 1
987
+ assert_triggered(/Use assert_nil if expecting nil/) do
988
+ @tc.assert_equal nil, nil
989
+ end
990
+ else
991
+ err_re = /Use assert_nil if expecting nil from .*test_minitest_test.rb/
992
+
993
+ assert_output "", err_re do
994
+ @tc.assert_equal nil, nil
995
+ end
996
+ end
997
+ end
998
+
999
+ def test_assert_equal_does_not_allow_lhs_nil_triggered
1000
+ assert_triggered "Expected: nil\n Actual: false" do
1001
+ @tc.assert_equal nil, false
1002
+ end
1003
+ end
1004
+
982
1005
  def test_assert_in_delta
983
1006
  @tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
984
1007
  end
@@ -1088,7 +1111,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1088
1111
  @assertion_count = 2
1089
1112
 
1090
1113
  pattern = Object.new
1091
- def pattern.=~(_) true end
1114
+ def pattern.=~ _; true end
1092
1115
 
1093
1116
  @tc.assert_match pattern, 5
1094
1117
  end
@@ -1106,7 +1129,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1106
1129
  @assertion_count = 2
1107
1130
 
1108
1131
  pattern = Object.new
1109
- def pattern.=~(_) false end
1132
+ def pattern.=~ _; false end
1110
1133
  def pattern.inspect; "[Object]" end
1111
1134
 
1112
1135
  assert_triggered "Expected [Object] to match 5." do
@@ -1137,7 +1160,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1137
1160
 
1138
1161
  def test_assert_operator_bad_object
1139
1162
  bad = Object.new
1140
- def bad.==(_) true end
1163
+ def bad.== _; true end
1141
1164
 
1142
1165
  @tc.assert_operator bad, :equal?, bad
1143
1166
  end
@@ -1424,13 +1447,24 @@ class TestMinitestUnitTestCase < Minitest::Test
1424
1447
  end
1425
1448
  end
1426
1449
 
1450
+ def assert_deprecated name
1451
+ dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+:.*?/
1452
+ assert_output nil, dep do
1453
+ yield
1454
+ end
1455
+ end
1456
+
1427
1457
  def test_assert_send
1428
- @tc.assert_send [1, :<, 2]
1458
+ assert_deprecated :assert_send do
1459
+ @tc.assert_send [1, :<, 2]
1460
+ end
1429
1461
  end
1430
1462
 
1431
1463
  def test_assert_send_bad
1432
- assert_triggered "Expected 1.>(*[2]) to return true." do
1433
- @tc.assert_send [1, :>, 2]
1464
+ assert_deprecated :assert_send do
1465
+ assert_triggered "Expected 1.>(*[2]) to return true." do
1466
+ @tc.assert_send [1, :>, 2]
1467
+ end
1434
1468
  end
1435
1469
  end
1436
1470
 
@@ -1466,6 +1500,22 @@ class TestMinitestUnitTestCase < Minitest::Test
1466
1500
  end
1467
1501
  end
1468
1502
 
1503
+ def test_assert_throws_name_error
1504
+ @tc.assert_raises NameError do
1505
+ @tc.assert_throws :blah do
1506
+ raise NameError
1507
+ end
1508
+ end
1509
+ end
1510
+
1511
+ def test_assert_throws_argument_exception
1512
+ @tc.assert_raises ArgumentError do
1513
+ @tc.assert_throws :blah do
1514
+ raise ArgumentError
1515
+ end
1516
+ end
1517
+ end
1518
+
1469
1519
  def test_assert_throws_different
1470
1520
  assert_triggered "Expected :blah to have been thrown, not :not_blah." do
1471
1521
  @tc.assert_throws :blah do
@@ -1696,7 +1746,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1696
1746
  @assertion_count = 2
1697
1747
 
1698
1748
  pattern = Object.new
1699
- def pattern.=~(_) true end
1749
+ def pattern.=~ _; true end
1700
1750
  def pattern.inspect; "[Object]" end
1701
1751
 
1702
1752
  assert_triggered "Expected [Object] to not match 5." do
@@ -1737,7 +1787,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1737
1787
 
1738
1788
  def test_refute_operator_bad_object
1739
1789
  bad = Object.new
1740
- def bad.==(_) true end
1790
+ def bad.== _; true end
1741
1791
 
1742
1792
  @tc.refute_operator true, :equal?, bad
1743
1793
  end
@@ -1779,7 +1829,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1779
1829
  def test_runnable_methods_random
1780
1830
  @assertion_count = 0
1781
1831
 
1782
- sample_test_case = Class.new Minitest::Test do
1832
+ sample_test_case = Class.new FakeNamedTest do
1783
1833
  def self.test_order; :random; end
1784
1834
  def test_test1; assert "does not matter" end
1785
1835
  def test_test2; assert "does not matter" end
@@ -1799,7 +1849,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1799
1849
  def test_runnable_methods_sorted
1800
1850
  @assertion_count = 0
1801
1851
 
1802
- sample_test_case = Class.new Minitest::Test do
1852
+ sample_test_case = Class.new FakeNamedTest do
1803
1853
  def self.test_order; :sorted end
1804
1854
  def test_test3; assert "does not matter" end
1805
1855
  def test_test2; assert "does not matter" end
@@ -1813,7 +1863,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1813
1863
  def test_i_suck_and_my_tests_are_order_dependent_bang_sets_test_order_alpha
1814
1864
  @assertion_count = 0
1815
1865
 
1816
- shitty_test_case = Class.new Minitest::Test
1866
+ shitty_test_case = Class.new FakeNamedTest
1817
1867
 
1818
1868
  shitty_test_case.i_suck_and_my_tests_are_order_dependent!
1819
1869
 
@@ -1823,7 +1873,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1823
1873
  def test_i_suck_and_my_tests_are_order_dependent_bang_does_not_warn
1824
1874
  @assertion_count = 0
1825
1875
 
1826
- shitty_test_case = Class.new Minitest::Test
1876
+ shitty_test_case = Class.new FakeNamedTest
1827
1877
 
1828
1878
  def shitty_test_case.test_order; :lol end
1829
1879
 
@@ -1841,7 +1891,8 @@ class TestMinitestUnitTestCase < Minitest::Test
1841
1891
  msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
1842
1892
  msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
1843
1893
 
1844
- assert_equal expected, msg
1894
+ assert_msg = Regexp === expected ? :assert_match : :assert_equal
1895
+ self.send assert_msg, expected, msg
1845
1896
  end
1846
1897
 
1847
1898
  def util_msg exp, act, msg = nil
@@ -1887,8 +1938,8 @@ end
1887
1938
  class TestMinitestUnitRecording < MetaMetaMetaTestCase
1888
1939
  # do not parallelize this suite... it just can't handle it.
1889
1940
 
1890
- def assert_run_record(*expected, &block)
1891
- @tu = Class.new Minitest::Test, &block
1941
+ def assert_run_record *expected, &block
1942
+ @tu = Class.new FakeNamedTest, &block
1892
1943
 
1893
1944
  run_tu_with_fresh_reporter
1894
1945
 
@@ -1946,7 +1997,7 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
1946
1997
  end
1947
1998
 
1948
1999
  def test_to_s_error_in_test_and_teardown
1949
- @tu = Class.new Minitest::Test do
2000
+ @tu = Class.new FakeNamedTest do
1950
2001
  def test_method
1951
2002
  raise AnError
1952
2003
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.1
4
+ version: 5.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -30,7 +30,7 @@ cert_chain:
30
30
  E4oJcnPkJAr0rw504JGtlZtONZQblwmRJOIdXzolaE3NRGUzGVOUSptZppAKiavY
31
31
  fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==
32
32
  -----END CERTIFICATE-----
33
- date: 2016-09-26 00:00:00.000000000 Z
33
+ date: 2016-12-01 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rdoc
metadata.gz.sig CHANGED
Binary file