minitest 5.10.3 → 5.11.0b1

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
  SHA1:
3
- metadata.gz: 32d4df1397bf8fc366b4b18555936d7c92853121
4
- data.tar.gz: 4000474506d5056f3117b1a93e1bc4019dfd15af
3
+ metadata.gz: 4d31a9fcb7d45a7e535a4fbc93165ba08405b925
4
+ data.tar.gz: 3b62db8a5bfa1b7d232bd76d3254510c3d839c4c
5
5
  SHA512:
6
- metadata.gz: 195277b6093c3650634809f445c274d8df6bfafb4f32be448f4cdde07de9edf47c64e4f05cdf3572bf79f61e2597ce33c2b7821cd147d4c8bd2f251451e86098
7
- data.tar.gz: a8a16930df76274303310ba4faf115914913bea38b559ec4edfad8ae2a835fb22e7d6308c88eadf93044ea422b334d65e33c8c59f15f0ece27a962b1fc8d7e9c
6
+ metadata.gz: ad77547e5e3721e327d6bb96c664cce839acef498c0f059df1fd36211d35644ec040e75212c8a421430ee05adb7d5525b3aefc54e480f3cb33afb6004917077f
7
+ data.tar.gz: f153926171b7040a9626f029747202678e32798c2572e18bcf4f9cab5ce10e80faa074ccc3f460c56ba2027c35af0b541440e9e8a8dfce740af47211646bd2db
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,26 @@
1
+ === 5.11.0b1 / 2017-12-20
2
+
3
+ * 2 major enhancements:
4
+
5
+ * Added Minitest::Result and Minitest::Result.from(runnable).
6
+ * Changed Minitest::Test to subclass Result and refactored methods up.
7
+
8
+ * 6 minor enhancements:
9
+
10
+ * Added --no-plugins and MT_NO_PLUGINS to bypass MT plugin autoloading. Helps with bad actors installed globally.
11
+ * Added bench_performance_{logarithmic,power} for spec-style benchmarks. (rickhull)
12
+ * Minitest.run_one_method now checks for instance of Result, not exact same class.
13
+ * Minitest::Test.run returns a Result version of self, not self.
14
+ * ProgressReporter#prerecord now explicitly prints klass.name. Allows for fakers.
15
+ * Removed Runnable.marshal_dump/load.
16
+
17
+ * 4 bug fixes:
18
+
19
+ * Object.stub no longer calls the passed block if stubbed with a callable.
20
+ * Object.stub now passes blocks down to the callable result.
21
+ * Pushed Minitest::Test#time & #time_it up to Runnable.
22
+ * Test nil equality directly in assert_equal. Fixes #679. (voxik)
23
+
1
24
  === 5.10.3 / 2017-07-21
2
25
 
3
26
  * 1 minor enhancement:
@@ -434,11 +434,26 @@ you want to extend your test using setup/teardown via a module, just
434
434
  make sure you ALWAYS call super. before/after automatically call super
435
435
  for you, so make sure you don't do it twice.
436
436
 
437
+ === How to run code before a group of tests?
438
+
439
+ Use a constant with begin...end like this:
440
+
441
+ describe Blah do
442
+ SETUP = begin
443
+ # ... this runs once when describe Blah starts
444
+ end
445
+ # ...
446
+ end
447
+
448
+ This can be useful for expensive initializations or sharing state.
449
+ Remember, this is just ruby code, so you need to make sure this
450
+ technique and sharing state doesn't interfere with your tests.
451
+
437
452
  === Why am I seeing <tt>uninitialized constant MiniTest::Test (NameError)</tt>?
438
453
 
439
- Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
454
+ Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
440
455
  in order to require minitest, you must first add the <tt>gem 'minitest'</tt>
441
- to your Gemfile and run +bundle+. Once it's installed, you should be
456
+ to your Gemfile and run +bundle+. Once it's installed, you should be
442
457
  able to require minitest and run your tests.
443
458
 
444
459
  == Prominent Projects using Minitest:
@@ -506,7 +521,7 @@ If you see failures like either of these, you are probably missing diff tool:
506
521
 
507
522
 
508
523
  If you use Cygwin or MSYS2 or similar there are packages that include a
509
- GNU diff for Widnows. If you don't, you can download GNU diffutils from
524
+ GNU diff for Windows. If you don't, you can download GNU diffutils from
510
525
  http://gnuwin32.sourceforge.net/packages/diffutils.htm
511
526
  (make sure to add it to your PATH).
512
527
 
@@ -578,7 +593,7 @@ minitest-great_expectations :: Generally useful additions to minitest's
578
593
  assertions and expectations.
579
594
  minitest-growl :: Test notifier for minitest via growl.
580
595
  minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
581
- minitest-have_tag :: Adds Minitest assertions to test for the existence of
596
+ minitest-have_tag :: Adds Minitest assertions to test for the existence of
582
597
  HTML tags, including contents, within a provided string.
583
598
  minitest-hooks :: Around and before_all/after_all/around_all hooks
584
599
  minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
@@ -588,6 +603,7 @@ minitest-instrument :: Instrument ActiveSupport::Notifications when
588
603
  minitest-instrument-db :: Store information about speed of test execution
589
604
  provided by minitest-instrument in database.
590
605
  minitest-junit :: JUnit-style XML reporter for minitest.
606
+ minitest-keyword :: Use Minitest assertions with keyword arguments.
591
607
  minitest-libnotify :: Test notifier for minitest via libnotify.
592
608
  minitest-line :: Run test at line number.
593
609
  minitest-logger :: Define assert_log and enable minitest to test log messages.
@@ -614,10 +630,10 @@ minitest-rails-capybara :: Capybara integration for Minitest::Rails.
614
630
  minitest-reporters :: Create customizable Minitest output formats.
615
631
  minitest-rg :: Colored red/green output for Minitest.
616
632
  minitest-rspec_mocks :: Use RSpec Mocks with Minitest.
617
- minitest-server :: minitest-server provides a client/server setup
618
- with your minitest process, allowing your test
633
+ minitest-server :: minitest-server provides a client/server setup
634
+ with your minitest process, allowing your test
619
635
  run to send its results directly to a handler.
620
- minitest-sequel :: Minitest assertions to speed-up development and
636
+ minitest-sequel :: Minitest assertions to speed-up development and
621
637
  testing of Ruby Sequel database setups.
622
638
  minitest-shared_description :: Support for shared specs and shared spec
623
639
  subclasses
@@ -8,7 +8,7 @@ require "stringio"
8
8
  # :include: README.rdoc
9
9
 
10
10
  module Minitest
11
- VERSION = "5.10.3" # :nodoc:
11
+ VERSION = "5.11.0b1" # :nodoc:
12
12
  ENCS = "".respond_to? :encoding # :nodoc:
13
13
 
14
14
  @@installed_at_exit ||= false
@@ -118,7 +118,7 @@ module Minitest
118
118
  # klass.new(runnable_method).run
119
119
 
120
120
  def self.run args = []
121
- self.load_plugins
121
+ self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
122
122
 
123
123
  options = process_args args
124
124
 
@@ -175,6 +175,8 @@ module Minitest
175
175
  exit
176
176
  end
177
177
 
178
+ opts.on "--no-plugins", "Bypass minitest plugin auto-loading (or set $MT_NO_PLUGINS)."
179
+
178
180
  desc = "Sets random seed. Also via env. Eg: SEED=n rake"
179
181
  opts.on "-s", "--seed SEED", Integer, desc do |m|
180
182
  options[:seed] = m.to_i
@@ -252,6 +254,19 @@ module Minitest
252
254
 
253
255
  attr_accessor :failures
254
256
 
257
+ ##
258
+ # The time it took to run.
259
+
260
+ attr_accessor :time
261
+
262
+ def time_it # :nodoc:
263
+ t0 = Minitest.clock_time
264
+
265
+ yield
266
+ ensure
267
+ self.time = Minitest.clock_time - t0
268
+ end
269
+
255
270
  ##
256
271
  # Name of the run.
257
272
 
@@ -266,11 +281,6 @@ module Minitest
266
281
  @NAME = o
267
282
  end
268
283
 
269
- def self.inherited klass # :nodoc:
270
- self.runnables << klass
271
- super
272
- end
273
-
274
284
  ##
275
285
  # Returns all instance methods matching the pattern +re+.
276
286
 
@@ -367,14 +377,6 @@ module Minitest
367
377
  @@runnables
368
378
  end
369
379
 
370
- def marshal_dump # :nodoc:
371
- [self.name, self.failures, self.assertions]
372
- end
373
-
374
- def marshal_load ary # :nodoc:
375
- self.name, self.failures, self.assertions = ary
376
- end
377
-
378
380
  def failure # :nodoc:
379
381
  self.failures.first
380
382
  end
@@ -418,6 +420,94 @@ module Minitest
418
420
  end
419
421
  end
420
422
 
423
+ ##
424
+ # This represents a test result in a clean way that can be
425
+ # marshalled over a wire. Tests can do anything they want to the
426
+ # test instance and can create conditions that cause Marshal.dump to
427
+ # blow up. By using Result.from(a_test) you can be reasonably sure
428
+ # that the test result can be marshalled.
429
+
430
+ class Result < Runnable
431
+ ##
432
+ # The class name of the test result.
433
+
434
+ attr_accessor :klass
435
+
436
+ ##
437
+ # The test name of the test result.
438
+
439
+ attr_accessor :name
440
+
441
+ ##
442
+ # The location of the test method.
443
+
444
+ attr_accessor :source_location
445
+
446
+ ##
447
+ # Create a new test result from a Runnable instance.
448
+
449
+ def self.from runnable
450
+ o = runnable
451
+
452
+ r = self.new o.name
453
+ r.klass = o.class.name
454
+ r.assertions = o.assertions
455
+ r.failures = o.failures.dup
456
+ r.time = o.time
457
+
458
+ r.source_location = o.method(o.name).source_location rescue ["unknown", -1]
459
+
460
+ r
461
+ end
462
+
463
+ ##
464
+ # Did this run error?
465
+
466
+ def error?
467
+ self.failures.any? { |f| UnexpectedError === f }
468
+ end
469
+
470
+ ##
471
+ # The location identifier of this test.
472
+
473
+ def location
474
+ loc = " [#{self.failure.location}]" unless passed? or error?
475
+ "#{self.klass}##{self.name}#{loc}"
476
+ end
477
+
478
+ ##
479
+ # Did this run pass?
480
+ #
481
+ # Note: skipped runs are not considered passing, but they don't
482
+ # cause the process to exit non-zero.
483
+
484
+ def passed?
485
+ not self.failure
486
+ end
487
+
488
+ ##
489
+ # Returns ".", "F", or "E" based on the result of the run.
490
+
491
+ def result_code
492
+ self.failure and self.failure.result_code or "."
493
+ end
494
+
495
+ ##
496
+ # Was this run skipped?
497
+
498
+ def skipped?
499
+ self.failure and Skip === self.failure
500
+ end
501
+
502
+ def to_s # :nodoc:
503
+ return location if passed? and not skipped?
504
+
505
+ failures.map { |failure|
506
+ "#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n"
507
+ }.join "\n"
508
+ end
509
+ end
510
+
421
511
  ##
422
512
  # Defines the API for Reporters. Subclass this and override whatever
423
513
  # you want. Go nuts.
@@ -488,7 +578,7 @@ module Minitest
488
578
  class ProgressReporter < Reporter
489
579
  def prerecord klass, name #:nodoc:
490
580
  if options[:verbose] then
491
- io.print "%s#%s = " % [klass, name]
581
+ io.print "%s#%s = " % [klass.name, name]
492
582
  io.flush
493
583
  end
494
584
  end
@@ -837,7 +927,7 @@ module Minitest
837
927
 
838
928
  def self.run_one_method klass, method_name # :nodoc:
839
929
  result = klass.new(method_name).run
840
- raise "#{klass}#run _must_ return self" unless klass === result
930
+ raise "#{klass}#run _must_ return a Result" unless Result === result
841
931
  result
842
932
  end
843
933
 
@@ -853,6 +943,13 @@ module Minitest
853
943
  end
854
944
  end
855
945
 
946
+ class Runnable # re-open
947
+ def self.inherited klass # :nodoc:
948
+ self.runnables << klass
949
+ super
950
+ end
951
+ end
952
+
856
953
  # :startdoc:
857
954
  end
858
955
 
@@ -173,7 +173,7 @@ module Minitest
173
173
  msg = message(msg, E) { diff exp, act }
174
174
  result = assert exp == act, msg
175
175
 
176
- if exp.nil? then
176
+ if nil == exp then
177
177
  if Minitest::VERSION =~ /^6/ then
178
178
  refute_nil exp, "Use assert_nil if expecting nil."
179
179
  else
@@ -205,8 +205,8 @@ module Minitest
205
205
  # For comparing Floats. Fails unless +exp+ and +act+ have a relative
206
206
  # error less than +epsilon+.
207
207
 
208
- def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
209
- assert_in_delta a, b, [a.abs, b.abs].min * epsilon, msg
208
+ def assert_in_epsilon exp, act, epsilon = 0.001, msg = nil
209
+ assert_in_delta exp, act, [exp.abs, act.abs].min * epsilon, msg
210
210
  end
211
211
 
212
212
  ##
@@ -318,7 +318,7 @@ module Minitest
318
318
  # Enumerates over +enum+ mapping +block+ if given, returning the
319
319
  # sum of the result. Eg:
320
320
  #
321
- # sigma([1, 2, 3]) # => 1 + 2 + 3 => 7
321
+ # sigma([1, 2, 3]) # => 1 + 2 + 3 => 6
322
322
  # sigma([1, 2, 3]) { |n| n ** 2 } # => 1 + 4 + 9 => 14
323
323
 
324
324
  def sigma enum, &block
@@ -418,6 +418,37 @@ module Minitest
418
418
  assert_performance_exponential threshold, &work
419
419
  end
420
420
  end
421
+
422
+
423
+ ##
424
+ # Create a benchmark that verifies that the performance is logarithmic.
425
+ #
426
+ # describe "my class Bench" do
427
+ # bench_performance_logarithmic "algorithm" do |n|
428
+ # @obj.algorithm(n)
429
+ # end
430
+ # end
431
+
432
+ def self.bench_performance_logarithmic name, threshold = 0.99, &work
433
+ bench name do
434
+ assert_performance_logarithmic threshold, &work
435
+ end
436
+ end
437
+
438
+ ##
439
+ # Create a benchmark that verifies that the performance is power.
440
+ #
441
+ # describe "my class Bench" do
442
+ # bench_performance_power "algorithm" do |n|
443
+ # @obj.algorithm(n)
444
+ # end
445
+ # end
446
+
447
+ def self.bench_performance_power name, threshold = 0.99, &work
448
+ bench name do
449
+ assert_performance_power threshold, &work
450
+ end
451
+ end
421
452
  end
422
453
 
423
454
  Minitest::Spec.register_spec_type(/Bench(mark)?$/, Minitest::BenchSpec)
@@ -223,15 +223,12 @@ class Object
223
223
  metaclass.send :alias_method, new_name, name
224
224
 
225
225
  metaclass.send :define_method, name do |*args, &blk|
226
- ret = if val_or_callable.respond_to? :call then
227
- val_or_callable.call(*args)
228
- else
229
- val_or_callable
230
- end
231
-
232
- blk.call(*block_args) if blk
233
-
234
- ret
226
+ if val_or_callable.respond_to? :call then
227
+ val_or_callable.call(*args, &blk)
228
+ else
229
+ blk.call(*block_args) if blk
230
+ val_or_callable
231
+ end
235
232
  end
236
233
 
237
234
  yield self
@@ -7,7 +7,7 @@ module Minitest
7
7
  #
8
8
  # See Minitest::Assertions
9
9
 
10
- class Test < Runnable
10
+ class Test < Result
11
11
  require "minitest/assertions"
12
12
  include Minitest::Assertions
13
13
 
@@ -79,20 +79,6 @@ module Minitest
79
79
  :random
80
80
  end
81
81
 
82
- ##
83
- # The time it took to run this test.
84
-
85
- attr_accessor :time
86
-
87
- def marshal_dump # :nodoc:
88
- super << self.time
89
- end
90
-
91
- def marshal_load ary # :nodoc:
92
- self.time = ary.pop
93
- super
94
- end
95
-
96
82
  TEARDOWN_METHODS = %w[ before_teardown teardown after_teardown ] # :nodoc:
97
83
 
98
84
  ##
@@ -115,7 +101,7 @@ module Minitest
115
101
  end
116
102
  end
117
103
 
118
- self # per contract
104
+ Result.from self # per contract
119
105
  end
120
106
 
121
107
  ##
@@ -210,61 +196,6 @@ module Minitest
210
196
  self.failures << UnexpectedError.new(e)
211
197
  end
212
198
 
213
- ##
214
- # Did this run error?
215
-
216
- def error?
217
- self.failures.any? { |f| UnexpectedError === f }
218
- end
219
-
220
- ##
221
- # The location identifier of this test.
222
-
223
- def location
224
- loc = " [#{self.failure.location}]" unless passed? or error?
225
- "#{self.class}##{self.name}#{loc}"
226
- end
227
-
228
- ##
229
- # Did this run pass?
230
- #
231
- # Note: skipped runs are not considered passing, but they don't
232
- # cause the process to exit non-zero.
233
-
234
- def passed?
235
- not self.failure
236
- end
237
-
238
- ##
239
- # Returns ".", "F", or "E" based on the result of the run.
240
-
241
- def result_code
242
- self.failure and self.failure.result_code or "."
243
- end
244
-
245
- ##
246
- # Was this run skipped?
247
-
248
- def skipped?
249
- self.failure and Skip === self.failure
250
- end
251
-
252
- def time_it # :nodoc:
253
- t0 = Minitest.clock_time
254
-
255
- yield
256
- ensure
257
- self.time = Minitest.clock_time - t0
258
- end
259
-
260
- def to_s # :nodoc:
261
- return location if passed? and not skipped?
262
-
263
- failures.map { |failure|
264
- "#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n"
265
- }.join "\n"
266
- end
267
-
268
199
  def with_info_handler &block # :nodoc:
269
200
  t0 = Minitest.clock_time
270
201
 
@@ -68,6 +68,7 @@ class MetaMetaMetaTestCase < Minitest::Test
68
68
  output.sub!(/Finished in .*/, "Finished in 0.00")
69
69
  output.sub!(/Loaded suite .*/, "Loaded suite blah")
70
70
 
71
+ output.gsub!(/FakeNamedTest\d+/, "FakeNamedTestXX")
71
72
  output.gsub!(/ = \d+.\d\d s = /, " = 0.00 s = ")
72
73
  output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
73
74
  output.gsub!(/ +$/, "")
@@ -494,6 +494,17 @@ class TestMinitestStub < Minitest::Test
494
494
  @tc.assert_equal false, dynamic.found
495
495
  end
496
496
 
497
+ def test_stub_NameError
498
+ e = @tc.assert_raises NameError do
499
+ Time.stub :nope_nope_nope, 42 do
500
+ # do nothing
501
+ end
502
+ end
503
+
504
+ exp = /undefined method `nope_nope_nope' for( class)? `#{self.class}::Time'/
505
+ assert_match exp, e.message
506
+ end
507
+
497
508
  def test_mock_with_yield
498
509
  mock = Minitest::Mock.new
499
510
  mock.expect(:write, true) do
@@ -509,4 +520,355 @@ class TestMinitestStub < Minitest::Test
509
520
  @tc.assert_equal true, rs
510
521
  end
511
522
 
523
+ alias test_stub_value__old test_stub_value # TODO: remove/rename
524
+
525
+ ## Permutation Sets:
526
+
527
+ # [:value, :lambda]
528
+ # [:*, :block, :block_call]
529
+ # [:**, :block_args]
530
+ #
531
+ # Where:
532
+ #
533
+ # :value = a normal value
534
+ # :lambda = callable or lambda
535
+ # :* = no block
536
+ # :block = normal block
537
+ # :block_call = :lambda invokes the block (N/A for :value)
538
+ # :** = no args
539
+ # :args = args passed to stub
540
+
541
+ ## Permutations
542
+
543
+ # [:call, :*, :**] =>5 callable+block FIX: CALL BOTH (bug)
544
+ # [:call, :*, :**] =>6 callable
545
+
546
+ # [:lambda, :*, :**] => lambda result
547
+
548
+ # [:lambda, :*, :args] => lambda result NO ARGS
549
+
550
+ # [:lambda, :block, :**] =>5 lambda result FIX: CALL BOTH (bug)
551
+ # [:lambda, :block, :**] =>6 lambda result
552
+
553
+ # [:lambda, :block, :args] =>5 lambda result FIX: CALL BOTH (bug)
554
+ # [:lambda, :block, :args] =>6 lambda result
555
+ # [:lambda, :block, :args] =>7 raise ArgumentError
556
+
557
+ # [:lambda, :block_call, :**] =>5 lambda FIX: BUG!-not passed block to lambda
558
+ # [:lambda, :block_call, :**] =>6 lambda+block result
559
+
560
+ # [:lambda, :block_call, :args] =>5 lambda FIX: BUG!-not passed block to lambda
561
+ # [:lambda, :block_call, :args] =>6 lambda+block result
562
+
563
+ # [:value, :*, :**] => value
564
+
565
+ # [:value, :*, :args] => value, ignore args
566
+
567
+ # [:value, :block, :**] =>5 value, call block
568
+ # [:value, :block, :**] =>6 value
569
+
570
+ # [:value, :block, :args] =>5 value, call block w/ args
571
+ # [:value, :block, :args] =>6 value, call block w/ args, deprecated
572
+ # [:value, :block, :args] =>7 raise ArgumentError
573
+
574
+ # [:value, :block_call, :**] => N/A
575
+
576
+ # [:value, :block_call, :args] => N/A
577
+
578
+ class Bar
579
+ def call
580
+ puts "hi"
581
+ end
582
+ end
583
+
584
+ class Foo
585
+ def self.blocking
586
+ yield
587
+ end
588
+ end
589
+
590
+ class Thingy
591
+ def self.identity arg
592
+ arg
593
+ end
594
+ end
595
+
596
+ def test_stub_callable_block_5 # from tenderlove
597
+ @assertion_count += 1
598
+ Foo.stub5 :blocking, Bar.new do
599
+ @tc.assert_output "hi\n", "" do
600
+ Foo.blocking do
601
+ @tc.flunk "shouldn't ever hit this"
602
+ end
603
+ end
604
+ end
605
+ end
606
+
607
+ def test_stub_callable_block_6 # from tenderlove
608
+ skip_stub6
609
+
610
+ @assertion_count += 1
611
+ Foo.stub6 :blocking, Bar.new do
612
+ @tc.assert_output "hi\n", "" do
613
+ Foo.blocking do
614
+ @tc.flunk "shouldn't ever hit this"
615
+ end
616
+ end
617
+ end
618
+ end
619
+
620
+ def test_stub_lambda
621
+ Thread.stub :new, lambda { 21+21 } do
622
+ @tc.assert_equal 42, Thread.new
623
+ end
624
+ end
625
+
626
+ def test_stub_lambda_args
627
+ Thread.stub :new, lambda { 21+21 }, :wtf do
628
+ @tc.assert_equal 42, Thread.new
629
+ end
630
+ end
631
+
632
+ def test_stub_lambda_block_5
633
+ Thread.stub5 :new, lambda { 21+21 } do
634
+ result = Thread.new do
635
+ @tc.flunk "shouldn't ever hit this"
636
+ end
637
+ @tc.assert_equal 42, result
638
+ end
639
+ end
640
+
641
+ def test_stub_lambda_block_6
642
+ skip_stub6
643
+
644
+ Thread.stub6 :new, lambda { 21+21 } do
645
+ result = Thread.new do
646
+ @tc.flunk "shouldn't ever hit this"
647
+ end
648
+ @tc.assert_equal 42, result
649
+ end
650
+ end
651
+
652
+ def test_stub_lambda_block_args_5
653
+ @assertion_count += 1
654
+ Thingy.stub5 :identity, lambda { |y| @tc.assert_equal :nope, y; 21+21 }, :WTF? do
655
+ result = Thingy.identity :nope do |x|
656
+ @tc.flunk "shouldn't reach this"
657
+ end
658
+ @tc.assert_equal 42, result
659
+ end
660
+ end
661
+
662
+ def test_stub_lambda_block_args_6
663
+ skip_stub6
664
+
665
+ @assertion_count += 1
666
+ Thingy.stub6 :identity, lambda { |y| @tc.assert_equal :nope, y; 21+21 }, :WTF? do
667
+ result = Thingy.identity :nope do |x|
668
+ @tc.flunk "shouldn't reach this"
669
+ end
670
+ @tc.assert_equal 42, result
671
+ end
672
+ end
673
+
674
+ def test_stub_lambda_block_args_6_2
675
+ skip_stub6
676
+
677
+ @tc.assert_raises ArgumentError do
678
+ Thingy.stub6_2 :identity, lambda { |y| :__not_run__ }, :WTF? do
679
+ # doesn't matter
680
+ end
681
+ end
682
+ end
683
+
684
+ def test_stub_lambda_block_call_5
685
+ @assertion_count += 1
686
+ rs = nil
687
+ io = StringIO.new "", "w"
688
+ File.stub5 :open, lambda { |p, m, &blk| blk and blk.call io } do
689
+ File.open "foo.txt", "r" do |f|
690
+ rs = f && f.write("woot")
691
+ end
692
+ end
693
+ @tc.assert_equal 4, rs
694
+ @tc.assert_equal "woot", io.string
695
+ end
696
+
697
+ def test_stub_lambda_block_call_6
698
+ skip_stub6
699
+
700
+ @assertion_count += 1
701
+ rs = nil
702
+ io = StringIO.new "", "w"
703
+ File.stub6 :open, lambda { |p, m, &blk| blk.call io } do
704
+ File.open "foo.txt", "r" do |f|
705
+ rs = f.write("woot")
706
+ end
707
+ end
708
+ @tc.assert_equal 4, rs
709
+ @tc.assert_equal "woot", io.string
710
+ end
711
+
712
+ def test_stub_lambda_block_call_args_5
713
+ @assertion_count += 1
714
+ rs = nil
715
+ io = StringIO.new "", "w"
716
+ File.stub5(:open, lambda { |p, m, &blk| blk and blk.call io }, :WTF?) do
717
+ File.open "foo.txt", "r" do |f|
718
+ rs = f.write("woot")
719
+ end
720
+ end
721
+ @tc.assert_equal 4, rs
722
+ @tc.assert_equal "woot", io.string
723
+ end
724
+
725
+ def test_stub_lambda_block_call_args_6
726
+ skip_stub6
727
+
728
+ @assertion_count += 1
729
+ rs = nil
730
+ io = StringIO.new "", "w"
731
+ File.stub6(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
732
+ File.open "foo.txt", "r" do |f|
733
+ rs = f.write("woot")
734
+ end
735
+ end
736
+ @tc.assert_equal 4, rs
737
+ @tc.assert_equal "woot", io.string
738
+ end
739
+
740
+ def test_stub_lambda_block_call_args_6_2
741
+ skip_stub6
742
+
743
+ @assertion_count += 2
744
+ rs = nil
745
+ io = StringIO.new "", "w"
746
+ @tc.assert_raises ArgumentError do
747
+ File.stub6_2(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
748
+ File.open "foo.txt", "r" do |f|
749
+ rs = f.write("woot")
750
+ end
751
+ end
752
+ end
753
+ @tc.assert_nil rs
754
+ @tc.assert_equal "", io.string
755
+ end
756
+
757
+ def test_stub_value
758
+ Thread.stub :new, 42 do
759
+ result = Thread.new
760
+ @tc.assert_equal 42, result
761
+ end
762
+ end
763
+
764
+ def test_stub_value_args
765
+ Thread.stub :new, 42, :WTF? do
766
+ result = Thread.new
767
+ @tc.assert_equal 42, result
768
+ end
769
+ end
770
+
771
+ def test_stub_value_block_5
772
+ @assertion_count += 1
773
+ Thread.stub5 :new, 42 do
774
+ result = Thread.new do
775
+ @tc.assert true
776
+ end
777
+ @tc.assert_equal 42, result
778
+ end
779
+ end
780
+
781
+ def test_stub_value_block_6
782
+ skip_stub6
783
+
784
+ Thread.stub6 :new, 42 do
785
+ result = Thread.new do
786
+ @tc.flunk "shouldn't hit this"
787
+ end
788
+ @tc.assert_equal 42, result
789
+ end
790
+ end
791
+
792
+ def test_stub_value_block_args_5
793
+ @assertion_count += 2
794
+ rs = nil
795
+ io = StringIO.new "", "w"
796
+ File.stub5 :open, :value, io do
797
+ result = File.open "foo.txt", "r" do |f|
798
+ rs = f.write("woot")
799
+ end
800
+ @tc.assert_equal :value, result
801
+ end
802
+ @tc.assert_equal 4, rs
803
+ @tc.assert_equal "woot", io.string
804
+ end
805
+
806
+ def test_stub_value_block_args_5__break_if_not_passed
807
+ e = @tc.assert_raises NoMethodError do
808
+ File.stub5 :open, :return_value do # intentionally bad setup w/ no args
809
+ File.open "foo.txt", "r" do |f|
810
+ f.write "woot"
811
+ end
812
+ end
813
+ end
814
+ exp = "undefined method `write' for nil:NilClass"
815
+ assert_equal exp, e.message
816
+ end
817
+
818
+ def test_stub_value_block_args_6
819
+ skip_stub6
820
+
821
+ @assertion_count += 2
822
+ rs = nil
823
+ io = StringIO.new "", "w"
824
+ assert_deprecated do
825
+ File.stub6 :open, :value, io do
826
+ result = File.open "foo.txt", "r" do |f|
827
+ rs = f.write("woot")
828
+ end
829
+ @tc.assert_equal :value, result
830
+ end
831
+ end
832
+ @tc.assert_equal 4, rs
833
+ @tc.assert_equal "woot", io.string
834
+ end
835
+
836
+ def test_stub_value_block_args_6_2
837
+ skip_stub6
838
+
839
+ @assertion_count += 2
840
+ rs = nil
841
+ io = StringIO.new "", "w"
842
+ @tc.assert_raises ArgumentError do
843
+ File.stub6_2 :open, :value, io do
844
+ result = File.open "foo.txt", "r" do |f|
845
+ @tc.flunk "shouldn't hit this"
846
+ end
847
+ @tc.assert_equal :value, result
848
+ end
849
+ end
850
+ @tc.assert_nil rs
851
+ @tc.assert_equal "", io.string
852
+ end
853
+
854
+ def assert_deprecated re = /deprecated/
855
+ assert_output "", re do
856
+ yield
857
+ end
858
+ end
859
+
860
+ def skip_stub6
861
+ skip "not yet" unless STUB6
862
+ end
863
+ end
864
+
865
+ STUB6 = ENV["STUB6"]
866
+
867
+ if STUB6 then
868
+ require "minitest/mock6" if STUB6
869
+ else
870
+ class Object
871
+ alias stub5 stub
872
+ alias stub6 stub
873
+ end
512
874
  end
@@ -1,6 +1,12 @@
1
1
  require "minitest/autorun"
2
2
  require "minitest/metametameta"
3
3
 
4
+ class Runnable
5
+ def woot
6
+ assert true
7
+ end
8
+ end
9
+
4
10
  class TestMinitestReporter < MetaMetaMetaTestCase
5
11
 
6
12
  attr_accessor :r, :io
@@ -42,6 +48,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
42
48
  rescue => e
43
49
  e
44
50
  end)
51
+ @et = Minitest::Result.from @et
45
52
  end
46
53
  @et
47
54
  end
@@ -54,12 +61,13 @@ class TestMinitestReporter < MetaMetaMetaTestCase
54
61
  rescue Minitest::Assertion => e
55
62
  e
56
63
  end
64
+ @ft = Minitest::Result.from @ft
57
65
  end
58
66
  @ft
59
67
  end
60
68
 
61
69
  def passing_test
62
- @pt ||= Minitest::Test.new(:woot)
70
+ @pt ||= Minitest::Result.from Minitest::Test.new(:woot)
63
71
  end
64
72
 
65
73
  def skip_test
@@ -70,6 +78,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
70
78
  rescue Minitest::Assertion => e
71
79
  e
72
80
  end
81
+ @st = Minitest::Result.from @st
73
82
  end
74
83
  @st
75
84
  end
@@ -145,6 +154,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
145
154
  end
146
155
 
147
156
  def test_record_fail
157
+ fail_test = self.fail_test
148
158
  r.record fail_test
149
159
 
150
160
  assert_equal "F", io.string
@@ -154,6 +164,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
154
164
  end
155
165
 
156
166
  def test_record_error
167
+ error_test = self.error_test
157
168
  r.record error_test
158
169
 
159
170
  assert_equal "E", io.string
@@ -163,6 +174,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
163
174
  end
164
175
 
165
176
  def test_record_skip
177
+ skip_test = self.skip_test
166
178
  r.record skip_test
167
179
 
168
180
  assert_equal "S", io.string
@@ -20,6 +20,12 @@ class AnError < StandardError; include MyModule; end
20
20
  class ImmutableString < String; def inspect; super.freeze; end; end
21
21
  SomeError = Class.new Exception
22
22
 
23
+ class Minitest::Runnable
24
+ def whatever # faked for testing
25
+ assert true
26
+ end
27
+ end
28
+
23
29
  class TestMinitestUnit < MetaMetaMetaTestCase
24
30
  parallelize_me!
25
31
 
@@ -79,7 +85,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
79
85
  # end
80
86
 
81
87
  def test_infectious_binary_encoding
82
- @tu = Class.new Minitest::Test do
88
+ @tu = Class.new FakeNamedTest do
83
89
  def test_this_is_not_ascii_assertion
84
90
  assert_equal "ЁЁЁ", "ёёё"
85
91
  end
@@ -95,12 +101,12 @@ class TestMinitestUnit < MetaMetaMetaTestCase
95
101
  Finished in 0.00
96
102
 
97
103
  1) Error:
98
- #<Class:0xXXX>#test_this_is_non_ascii_failure_message:
104
+ FakeNamedTestXX#test_this_is_non_ascii_failure_message:
99
105
  RuntimeError: ЁЁЁ
100
106
  FILE:LINE:in `test_this_is_non_ascii_failure_message'
101
107
 
102
108
  2) Failure:
103
- #<Class:0xXXX>#test_this_is_not_ascii_assertion [FILE:LINE]:
109
+ FakeNamedTestXX#test_this_is_not_ascii_assertion [FILE:LINE]:
104
110
  Expected: \"ЁЁЁ\"
105
111
  Actual: \"ёёё\"
106
112
 
@@ -207,10 +213,10 @@ class TestMinitestRunner < MetaMetaMetaTestCase
207
213
 
208
214
  def run
209
215
  @foo = "hi mom!"
210
- super
216
+ r = super
211
217
  @foo = "okay"
212
218
 
213
- self # per contract
219
+ r
214
220
  end
215
221
 
216
222
  def test_something
@@ -247,7 +253,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
247
253
  Finished in 0.00
248
254
 
249
255
  1) Error:
250
- #<Class:0xXXX>#test_error:
256
+ FakeNamedTestXX#test_error:
251
257
  RuntimeError: unhandled exception
252
258
  FILE:LINE:in \`test_error\'
253
259
 
@@ -275,7 +281,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
275
281
  Finished in 0.00
276
282
 
277
283
  1) Error:
278
- #<Class:0xXXX>#test_something:
284
+ FakeNamedTestXX#test_something:
279
285
  RuntimeError: unhandled exception
280
286
  FILE:LINE:in \`teardown\'
281
287
 
@@ -294,7 +300,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
294
300
  Finished in 0.00
295
301
 
296
302
  1) Failure:
297
- #<Class:0xXXX>#test_failure [FILE:LINE]:
303
+ FakeNamedTestXX#test_failure [FILE:LINE]:
298
304
  Expected false to be truthy.
299
305
 
300
306
  2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
@@ -500,13 +506,13 @@ class TestMinitestRunner < MetaMetaMetaTestCase
500
506
  end
501
507
 
502
508
  expected = clean <<-EOM
503
- #<Class:0xXXX>#test_skip = 0.00 s = S
504
- #<Class:0xXXX>#test_something = 0.00 s = .
509
+ FakeNamedTestXX#test_skip = 0.00 s = S
510
+ FakeNamedTestXX#test_something = 0.00 s = .
505
511
 
506
512
  Finished in 0.00
507
513
 
508
514
  1) Skipped:
509
- #<Class:0xXXX>#test_skip [FILE:LINE]:
515
+ FakeNamedTestXX#test_skip [FILE:LINE]:
510
516
  not yet
511
517
 
512
518
  2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
@@ -754,7 +760,7 @@ class TestMinitestRunnable < Minitest::Test
754
760
  end
755
761
  tc.setup
756
762
 
757
- @tc = tc
763
+ @tc = Minitest::Result.from tc
758
764
  end
759
765
 
760
766
  def assert_marshal expected_ivars
@@ -772,7 +778,26 @@ class TestMinitestRunnable < Minitest::Test
772
778
  def test_marshal
773
779
  setup_marshal Minitest::Runnable
774
780
 
775
- assert_marshal %w[@NAME @assertions @failures]
781
+ assert_marshal %w[@assertions @failures @klass @name @source_location @time]
782
+ end
783
+
784
+ def test_spec_marshal
785
+ klass = describe("whatever") { it("passes") { assert true } }
786
+ rm = klass.runnable_methods.first
787
+
788
+ # Run the test
789
+ @tc = klass.new(rm).run
790
+
791
+ assert_kind_of Minitest::Result, @tc
792
+
793
+ # Pass it over the wire
794
+ over_the_wire = Marshal.load Marshal.dump @tc
795
+
796
+ assert_equal @tc.time, over_the_wire.time
797
+ assert_equal @tc.name, over_the_wire.name
798
+ assert_equal @tc.assertions, over_the_wire.assertions
799
+ assert_equal @tc.failures, over_the_wire.failures
800
+ assert_equal @tc.klass, over_the_wire.klass
776
801
  end
777
802
  end
778
803
 
@@ -782,7 +807,7 @@ class TestMinitestTest < TestMinitestRunnable
782
807
  tc.time = 3.14
783
808
  end
784
809
 
785
- assert_marshal %w[@NAME @assertions @failures @time] do |new_tc|
810
+ assert_marshal %w[@assertions @failures @klass @name @source_location @time] do |new_tc|
786
811
  assert_in_epsilon 3.14, new_tc.time
787
812
  end
788
813
  end
@@ -2087,12 +2112,12 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
2087
2112
 
2088
2113
  exp = clean "
2089
2114
  Error:
2090
- #<Class:0xXXX>#test_method:
2115
+ FakeNamedTestXX#test_method:
2091
2116
  AnError: AnError
2092
2117
  FILE:LINE:in `test_method'
2093
2118
 
2094
2119
  Error:
2095
- #<Class:0xXXX>#test_method:
2120
+ FakeNamedTestXX#test_method:
2096
2121
  RuntimeError: unhandled exception
2097
2122
  FILE:LINE:in `teardown'
2098
2123
  "
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.10.3
4
+ version: 5.11.0b1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDijCCAnKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBAjANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE2MDkyNjAxNTczNVoXDTE3MDkyNjAxNTczNVowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTE3MTEyMTIxMTExMFoXDTE4MTEyMTIxMTExMFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -20,17 +20,16 @@ cert_chain:
20
20
  oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
21
21
  GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
- gBEfoTEGr7Zii72cx+sCAwEAAaOBhDCBgTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
24
- sDAdBgNVHQ4EFgQUR8V72Z3+v+2P9abCnL4wjx32T+EwIwYDVR0RBBwwGoEYcnlh
25
- bmQtcnVieUB6ZW5zcGlkZXIuY29tMCMGA1UdEgQcMBqBGHJ5YW5kLXJ1YnlAemVu
26
- c3BpZGVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAIGzgp0aZ2W9+v96ujmBcQHoC
27
- buy0iU68MVj2VlxMyfr1KPZIh1OyhU4UO4zrkREcH8ML70v9cYHNvOd9oynRHnvC
28
- l2tj/fD3YJ0AEkJxGrYwRWQmvMfC4bJ02bC1+rVOUIXXKp3+cUmiN4sTniof8VFo
29
- bo/YYP4c7erpERa+9hrqygg6WQbJlk2YRlH3JXPFjmu869i2dcbR5ZLOAeEy+axH
30
- E4oJcnPkJAr0rw504JGtlZtONZQblwmRJOIdXzolaE3NRGUzGVOUSptZppAKiavY
31
- fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==
23
+ gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
+ HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
25
+ AQAfAXSQpsW7YSxd1csRtA/M4Zt0AMXFMd76GJ8Lgtg8G0+VFbdChRyDuDb0kPlW
26
+ h9QQX/YABfCW8vxmssbMGrP+VGBAn7BbdTcfTlgCWrvMX1uL5aRL74nA4urKXqdW
27
+ a0nP70K4958P3GffBdtE3KGkU5xstFnXGajxuBRnL66E15KU0BNehVxdG258bdPu
28
+ EKN6MqBPftFiev3tuwqDV11r2GquDpniYcT+Mi8/PgeAgVT/afBeVgbB3KaZeTRR
29
+ AhXhF6Wi2GTMezlj5jlI5XV7WsJUSwTp/YiVvcmT74ZaCRvexm6EnNhkrvJJ1Xeu
30
+ V+HB+LYYhXWitInO/eXxDrFB
32
31
  -----END CERTIFICATE-----
33
- date: 2017-07-21 00:00:00.000000000 Z
32
+ date: 2017-12-21 00:00:00.000000000 Z
34
33
  dependencies:
35
34
  - !ruby/object:Gem::Dependency
36
35
  name: rdoc
@@ -166,12 +165,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
165
  version: '0'
167
166
  required_rubygems_version: !ruby/object:Gem::Requirement
168
167
  requirements:
169
- - - ">="
168
+ - - ">"
170
169
  - !ruby/object:Gem::Version
171
- version: '0'
170
+ version: 1.3.1
172
171
  requirements: []
173
172
  rubyforge_project:
174
- rubygems_version: 2.6.8
173
+ rubygems_version: 2.6.13
175
174
  signing_key:
176
175
  specification_version: 4
177
176
  summary: minitest provides a complete suite of testing facilities supporting TDD,
metadata.gz.sig CHANGED
Binary file