minitest 5.23.1 → 5.25.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +48 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +64 -69
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +10 -10
- data/lib/minitest/error_on_warning.rb +3 -3
- data/lib/minitest/mock.rb +16 -13
- data/lib/minitest/parallel.rb +4 -4
- data/lib/minitest/pride_plugin.rb +10 -14
- data/lib/minitest/spec.rb +13 -12
- data/lib/minitest/test.rb +10 -22
- data/lib/minitest/test_task.rb +16 -10
- data/lib/minitest.rb +181 -143
- data/test/minitest/metametameta.rb +6 -9
- data/test/minitest/test_minitest_assertions.rb +115 -115
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +67 -64
- data/test/minitest/test_minitest_reporter.rb +17 -21
- data/test/minitest/test_minitest_spec.rb +52 -38
- data/test/minitest/test_minitest_test.rb +80 -99
- data/test/minitest/test_minitest_test_task.rb +18 -9
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
@@ -10,8 +10,9 @@ end
|
|
10
10
|
|
11
11
|
class TestMinitestMock < Minitest::Test
|
12
12
|
def setup
|
13
|
-
@mock = Minitest::Mock.new
|
14
|
-
|
13
|
+
@mock = Minitest::Mock.new
|
14
|
+
.expect(:foo, nil)
|
15
|
+
.expect(:meaning_of_life, 42)
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_create_stub_method
|
@@ -36,14 +37,14 @@ class TestMinitestMock < Minitest::Test
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def test_allow_expectations_to_be_added_after_creation
|
39
|
-
@mock.expect
|
40
|
+
@mock.expect :bar, true
|
40
41
|
assert @mock.bar
|
41
42
|
end
|
42
43
|
|
43
44
|
def test_not_verify_if_new_expected_method_is_not_called
|
44
45
|
@mock.foo
|
45
46
|
@mock.meaning_of_life
|
46
|
-
@mock.expect
|
47
|
+
@mock.expect :bar, true
|
47
48
|
|
48
49
|
util_verify_bad "expected bar() => true"
|
49
50
|
end
|
@@ -51,7 +52,7 @@ class TestMinitestMock < Minitest::Test
|
|
51
52
|
def test_blow_up_on_wrong_number_of_arguments
|
52
53
|
@mock.foo
|
53
54
|
@mock.meaning_of_life
|
54
|
-
@mock.expect
|
55
|
+
@mock.expect :sum, 3, [1, 2]
|
55
56
|
|
56
57
|
e = assert_raises ArgumentError do
|
57
58
|
@mock.sum
|
@@ -63,7 +64,7 @@ class TestMinitestMock < Minitest::Test
|
|
63
64
|
def test_return_mock_does_not_raise
|
64
65
|
retval = Minitest::Mock.new
|
65
66
|
mock = Minitest::Mock.new
|
66
|
-
mock.expect
|
67
|
+
mock.expect :foo, retval
|
67
68
|
mock.foo
|
68
69
|
|
69
70
|
assert_mock mock
|
@@ -72,8 +73,8 @@ class TestMinitestMock < Minitest::Test
|
|
72
73
|
def test_mock_args_does_not_raise
|
73
74
|
arg = Minitest::Mock.new
|
74
75
|
mock = Minitest::Mock.new
|
75
|
-
mock.expect
|
76
|
-
mock.foo
|
76
|
+
mock.expect :foo, nil, [arg]
|
77
|
+
mock.foo arg
|
77
78
|
|
78
79
|
assert_mock mock
|
79
80
|
end
|
@@ -113,8 +114,6 @@ class TestMinitestMock < Minitest::Test
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def test_expectations_can_be_satisfied_via_public_send
|
116
|
-
skip "Doesn't run on 1.8" if RUBY_VERSION < "1.9"
|
117
|
-
|
118
117
|
@mock.public_send :foo
|
119
118
|
@mock.public_send :meaning_of_life
|
120
119
|
|
@@ -124,10 +123,10 @@ class TestMinitestMock < Minitest::Test
|
|
124
123
|
def test_blow_up_on_wrong_arguments
|
125
124
|
@mock.foo
|
126
125
|
@mock.meaning_of_life
|
127
|
-
@mock.expect
|
126
|
+
@mock.expect :sum, 3, [1, 2]
|
128
127
|
|
129
128
|
e = assert_raises MockExpectationError do
|
130
|
-
@mock.sum
|
129
|
+
@mock.sum 2, 4
|
131
130
|
end
|
132
131
|
|
133
132
|
exp = "mocked method :sum called with unexpected arguments [2, 4]"
|
@@ -163,8 +162,8 @@ class TestMinitestMock < Minitest::Test
|
|
163
162
|
a = Minitest::Mock.new
|
164
163
|
b = Minitest::Mock.new
|
165
164
|
|
166
|
-
a.expect
|
167
|
-
b.expect
|
165
|
+
a.expect :foo, :a
|
166
|
+
b.expect :foo, :b
|
168
167
|
|
169
168
|
assert_equal :a, a.foo
|
170
169
|
assert_equal :b, b.foo
|
@@ -172,7 +171,7 @@ class TestMinitestMock < Minitest::Test
|
|
172
171
|
|
173
172
|
def test_do_not_create_stub_method_on_new_mocks
|
174
173
|
a = Minitest::Mock.new
|
175
|
-
a.expect
|
174
|
+
a.expect :foo, :a
|
176
175
|
|
177
176
|
assert !Minitest::Mock.new.respond_to?(:foo)
|
178
177
|
end
|
@@ -181,7 +180,7 @@ class TestMinitestMock < Minitest::Test
|
|
181
180
|
@mock.expect :kind_of?, true, [String]
|
182
181
|
@mock.expect :==, true, [1]
|
183
182
|
|
184
|
-
assert @mock.kind_of?(String), "didn't mock :kind_of
|
183
|
+
assert @mock.kind_of?(String), "didn't mock :kind_of?"
|
185
184
|
assert @mock == 1, "didn't mock :=="
|
186
185
|
end
|
187
186
|
|
@@ -277,9 +276,10 @@ class TestMinitestMock < Minitest::Test
|
|
277
276
|
|
278
277
|
e = assert_raises(MockExpectationError) { mock.verify }
|
279
278
|
|
280
|
-
exp = "expected foo(
|
279
|
+
exp = "expected foo(%p) => nil, got [foo(%p) => nil]" \
|
280
|
+
% [{ :kw => false }, { :kw => true }]
|
281
281
|
|
282
|
-
assert_equal exp, e.message
|
282
|
+
assert_equal exp.delete("{}"), e.message
|
283
283
|
end
|
284
284
|
|
285
285
|
def test_verify_passes_when_mock_block_returns_true
|
@@ -318,7 +318,7 @@ class TestMinitestMock < Minitest::Test
|
|
318
318
|
k1 == arg1 && k2 == arg2 && k3 == arg3
|
319
319
|
end
|
320
320
|
|
321
|
-
mock.foo
|
321
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
322
322
|
|
323
323
|
assert_mock mock
|
324
324
|
end
|
@@ -331,7 +331,7 @@ class TestMinitestMock < Minitest::Test
|
|
331
331
|
end
|
332
332
|
|
333
333
|
e = assert_raises ArgumentError do
|
334
|
-
mock.foo
|
334
|
+
mock.foo k1: arg1, k2: arg2
|
335
335
|
end
|
336
336
|
|
337
337
|
# basically testing ruby ... need ? for ruby < 2.7 :(
|
@@ -346,7 +346,7 @@ class TestMinitestMock < Minitest::Test
|
|
346
346
|
end
|
347
347
|
|
348
348
|
e = assert_raises ArgumentError do
|
349
|
-
mock.foo
|
349
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
350
350
|
end
|
351
351
|
|
352
352
|
# basically testing ruby ... need ? for ruby < 2.7 :(
|
@@ -361,10 +361,12 @@ class TestMinitestMock < Minitest::Test
|
|
361
361
|
end
|
362
362
|
|
363
363
|
e = assert_raises MockExpectationError do
|
364
|
-
mock.foo
|
364
|
+
mock.foo k1: arg1, k2: arg2, k3: :BAD!
|
365
365
|
end
|
366
366
|
|
367
|
-
exp = "mocked method :foo failed block w/ []
|
367
|
+
exp = "mocked method :foo failed block w/ [] %p" \
|
368
|
+
% [{ :k1 => :bar, :k2 => [1, 2, 3], :k3 => :BAD! }]
|
369
|
+
|
368
370
|
assert_equal exp, e.message
|
369
371
|
end
|
370
372
|
|
@@ -373,7 +375,7 @@ class TestMinitestMock < Minitest::Test
|
|
373
375
|
mock = Minitest::Mock.new
|
374
376
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
375
377
|
|
376
|
-
mock.foo
|
378
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
377
379
|
|
378
380
|
assert_mock mock
|
379
381
|
end
|
@@ -397,10 +399,10 @@ class TestMinitestMock < Minitest::Test
|
|
397
399
|
def test_mock_block_is_passed_keyword_args__args__old_style_bad
|
398
400
|
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
399
401
|
mock = Minitest::Mock.new
|
400
|
-
mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
|
402
|
+
mock.expect :foo, nil, [{ k1: arg1, k2: arg2, k3: arg3 }]
|
401
403
|
|
402
404
|
e = assert_raises ArgumentError do
|
403
|
-
mock.foo
|
405
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
404
406
|
end
|
405
407
|
|
406
408
|
assert_equal "mocked method :foo expects 1 arguments, got []", e.message
|
@@ -410,9 +412,9 @@ class TestMinitestMock < Minitest::Test
|
|
410
412
|
with_kwargs_env do
|
411
413
|
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
412
414
|
mock = Minitest::Mock.new
|
413
|
-
mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
|
415
|
+
mock.expect :foo, nil, [{ k1: arg1, k2: arg2, k3: arg3 }]
|
414
416
|
|
415
|
-
mock.foo
|
417
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
416
418
|
|
417
419
|
assert_mock mock
|
418
420
|
end
|
@@ -441,10 +443,10 @@ class TestMinitestMock < Minitest::Test
|
|
441
443
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
442
444
|
|
443
445
|
e = assert_raises ArgumentError do
|
444
|
-
mock.foo
|
446
|
+
mock.foo k1: arg1, k2: arg2
|
445
447
|
end
|
446
448
|
|
447
|
-
assert_equal "mocked method :foo expects 3 keyword arguments, got %p" % {k1: arg1, k2: arg2}, e.message
|
449
|
+
assert_equal "mocked method :foo expects 3 keyword arguments, got %p" % { k1: arg1, k2: arg2 }, e.message
|
448
450
|
end
|
449
451
|
|
450
452
|
def test_mock_block_is_passed_keyword_args__args_bad_extra
|
@@ -453,10 +455,10 @@ class TestMinitestMock < Minitest::Test
|
|
453
455
|
mock.expect :foo, nil, k1: arg1, k2: arg2
|
454
456
|
|
455
457
|
e = assert_raises ArgumentError do
|
456
|
-
mock.foo
|
458
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
457
459
|
end
|
458
460
|
|
459
|
-
assert_equal "mocked method :foo expects 2 keyword arguments, got %p" % {k1: arg1, k2: arg2, k3: arg3}, e.message
|
461
|
+
assert_equal "mocked method :foo expects 2 keyword arguments, got %p" % { k1: arg1, k2: arg2, k3: arg3 }, e.message
|
460
462
|
end
|
461
463
|
|
462
464
|
def test_mock_block_is_passed_keyword_args__args_bad_key
|
@@ -465,7 +467,7 @@ class TestMinitestMock < Minitest::Test
|
|
465
467
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
466
468
|
|
467
469
|
e = assert_raises MockExpectationError do
|
468
|
-
mock.foo
|
470
|
+
mock.foo k1: arg1, k2: arg2, BAD: arg3
|
469
471
|
end
|
470
472
|
|
471
473
|
assert_includes e.message, "unexpected keywords [:k1, :k2, :k3]"
|
@@ -478,18 +480,18 @@ class TestMinitestMock < Minitest::Test
|
|
478
480
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
479
481
|
|
480
482
|
e = assert_raises MockExpectationError do
|
481
|
-
mock.foo
|
483
|
+
mock.foo k1: arg1, k2: :BAD!, k3: arg3
|
482
484
|
end
|
483
485
|
|
484
|
-
|
486
|
+
bad = { :k2 => :BAD! }.inspect.delete "{}"
|
487
|
+
assert_match(/unexpected keyword arguments.* vs .*#{bad}/, e.message)
|
485
488
|
end
|
486
489
|
|
487
490
|
def test_mock_block_is_passed_function_block
|
488
491
|
mock = Minitest::Mock.new
|
489
492
|
block = proc { "bar" }
|
490
493
|
mock.expect :foo, nil do |arg, &blk|
|
491
|
-
arg == "foo" &&
|
492
|
-
blk == block
|
494
|
+
arg == "foo" && blk == block
|
493
495
|
end
|
494
496
|
mock.foo "foo", &block
|
495
497
|
assert_mock mock
|
@@ -497,8 +499,8 @@ class TestMinitestMock < Minitest::Test
|
|
497
499
|
|
498
500
|
def test_mock_forward_keyword_arguments
|
499
501
|
mock = Minitest::Mock.new
|
500
|
-
mock.expect(:foo, nil) { |bar:| bar ==
|
501
|
-
mock.foo
|
502
|
+
mock.expect(:foo, nil) { |bar:| bar == "bar" }
|
503
|
+
mock.foo bar: "bar"
|
502
504
|
assert_mock mock
|
503
505
|
end
|
504
506
|
|
@@ -517,7 +519,7 @@ class TestMinitestMock < Minitest::Test
|
|
517
519
|
def test_mock_block_raises_if_args_passed
|
518
520
|
mock = Minitest::Mock.new
|
519
521
|
|
520
|
-
e = assert_raises
|
522
|
+
e = assert_raises ArgumentError do
|
521
523
|
mock.expect :foo, nil, [:a, :b, :c] do
|
522
524
|
true
|
523
525
|
end
|
@@ -531,8 +533,8 @@ class TestMinitestMock < Minitest::Test
|
|
531
533
|
def test_mock_block_raises_if_kwargs_passed
|
532
534
|
mock = Minitest::Mock.new
|
533
535
|
|
534
|
-
e = assert_raises
|
535
|
-
mock.expect :foo, nil, kwargs:1 do
|
536
|
+
e = assert_raises ArgumentError do
|
537
|
+
mock.expect :foo, nil, kwargs: 1 do
|
536
538
|
true
|
537
539
|
end
|
538
540
|
end
|
@@ -544,7 +546,7 @@ class TestMinitestMock < Minitest::Test
|
|
544
546
|
|
545
547
|
def test_mock_returns_retval_when_called_with_block
|
546
548
|
mock = Minitest::Mock.new
|
547
|
-
mock.expect
|
549
|
+
mock.expect :foo, 32 do
|
548
550
|
true
|
549
551
|
end
|
550
552
|
|
@@ -563,7 +565,7 @@ class TestMinitestMock < Minitest::Test
|
|
563
565
|
|
564
566
|
def test_mock_called_via_send
|
565
567
|
mock = Minitest::Mock.new
|
566
|
-
mock.expect
|
568
|
+
mock.expect :foo, true
|
567
569
|
|
568
570
|
mock.send :foo
|
569
571
|
assert_mock mock
|
@@ -571,7 +573,7 @@ class TestMinitestMock < Minitest::Test
|
|
571
573
|
|
572
574
|
def test_mock_called_via___send__
|
573
575
|
mock = Minitest::Mock.new
|
574
|
-
mock.expect
|
576
|
+
mock.expect :foo, true
|
575
577
|
|
576
578
|
mock.__send__ :foo
|
577
579
|
assert_mock mock
|
@@ -579,9 +581,9 @@ class TestMinitestMock < Minitest::Test
|
|
579
581
|
|
580
582
|
def test_mock_called_via_send_with_args
|
581
583
|
mock = Minitest::Mock.new
|
582
|
-
mock.expect
|
584
|
+
mock.expect :foo, true, [1, 2, 3]
|
583
585
|
|
584
|
-
mock.send
|
586
|
+
mock.send :foo, 1, 2, 3
|
585
587
|
assert_mock mock
|
586
588
|
end
|
587
589
|
|
@@ -657,7 +659,7 @@ class TestMinitestStub < Minitest::Test
|
|
657
659
|
end
|
658
660
|
end
|
659
661
|
|
660
|
-
def
|
662
|
+
def test_stub_value__literal
|
661
663
|
assert_stub 42
|
662
664
|
end
|
663
665
|
|
@@ -714,7 +716,7 @@ class TestMinitestStub < Minitest::Test
|
|
714
716
|
end
|
715
717
|
end
|
716
718
|
|
717
|
-
val = dynamic.stub
|
719
|
+
val = dynamic.stub :found, true do |s|
|
718
720
|
s.found
|
719
721
|
end
|
720
722
|
|
@@ -729,14 +731,17 @@ class TestMinitestStub < Minitest::Test
|
|
729
731
|
end
|
730
732
|
end
|
731
733
|
|
732
|
-
exp = jruby?
|
733
|
-
|
734
|
+
exp = if jruby? then
|
735
|
+
/Undefined method nope_nope_nope for '#{self.class}::Time'/
|
736
|
+
else
|
737
|
+
/undefined method [`']nope_nope_nope' for( class)? [`']#{self.class}::Time'/
|
738
|
+
end
|
734
739
|
assert_match exp, e.message
|
735
740
|
end
|
736
741
|
|
737
742
|
def test_mock_with_yield
|
738
743
|
mock = Minitest::Mock.new
|
739
|
-
mock.expect
|
744
|
+
mock.expect :write, true do
|
740
745
|
true
|
741
746
|
end
|
742
747
|
rs = nil
|
@@ -753,7 +758,7 @@ class TestMinitestStub < Minitest::Test
|
|
753
758
|
mock = Minitest::Mock.new
|
754
759
|
rs = nil
|
755
760
|
|
756
|
-
File.stub :open, true, mock, kw:42 do
|
761
|
+
File.stub :open, true, mock, kw: 42 do
|
757
762
|
File.open "foo.txt", "r" do |f, kw:|
|
758
763
|
rs = kw
|
759
764
|
end
|
@@ -762,8 +767,6 @@ class TestMinitestStub < Minitest::Test
|
|
762
767
|
@tc.assert_equal 42, rs
|
763
768
|
end
|
764
769
|
|
765
|
-
alias test_stub_value__old test_stub_value # TODO: remove/rename
|
766
|
-
|
767
770
|
## Permutation Sets:
|
768
771
|
|
769
772
|
# [:value, :lambda]
|
@@ -818,7 +821,7 @@ class TestMinitestStub < Minitest::Test
|
|
818
821
|
# [:value, :block_call, :args] => N/A
|
819
822
|
|
820
823
|
class Bar
|
821
|
-
def call
|
824
|
+
def call &_ # to ignore unused block
|
822
825
|
puts "hi"
|
823
826
|
end
|
824
827
|
end
|
@@ -836,7 +839,7 @@ class TestMinitestStub < Minitest::Test
|
|
836
839
|
end
|
837
840
|
|
838
841
|
class Keywords
|
839
|
-
def self.args req, kw1:, kw2:24
|
842
|
+
def self.args req, kw1:, kw2: 24
|
840
843
|
[req, kw1, kw2]
|
841
844
|
end
|
842
845
|
end
|
@@ -850,7 +853,7 @@ class TestMinitestStub < Minitest::Test
|
|
850
853
|
def test_stub__hash_as_last_real_arg
|
851
854
|
with_kwargs_env do
|
852
855
|
token = Object.new
|
853
|
-
def token.create_with_retry
|
856
|
+
def token.create_with_retry _u, _p; raise "shouldn't see this"; end
|
854
857
|
|
855
858
|
controller = Object.new
|
856
859
|
controller.define_singleton_method :create do |u, p|
|
@@ -976,7 +979,7 @@ class TestMinitestStub < Minitest::Test
|
|
976
979
|
io = StringIO.new(+"", "w")
|
977
980
|
File.stub6 :open, lambda { |p, m, &blk| blk.call io } do
|
978
981
|
File.open "foo.txt", "r" do |f|
|
979
|
-
rs = f.write
|
982
|
+
rs = f.write "woot"
|
980
983
|
end
|
981
984
|
end
|
982
985
|
@tc.assert_equal 4, rs
|
@@ -989,7 +992,7 @@ class TestMinitestStub < Minitest::Test
|
|
989
992
|
io = StringIO.new(+"", "w")
|
990
993
|
File.stub5(:open, lambda { |p, m, &blk| blk and blk.call io }, :WTF?) do
|
991
994
|
File.open "foo.txt", "r" do |f|
|
992
|
-
rs = f.write
|
995
|
+
rs = f.write "woot"
|
993
996
|
end
|
994
997
|
end
|
995
998
|
@tc.assert_equal 4, rs
|
@@ -1004,7 +1007,7 @@ class TestMinitestStub < Minitest::Test
|
|
1004
1007
|
io = StringIO.new(+"", "w")
|
1005
1008
|
File.stub6(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
|
1006
1009
|
File.open "foo.txt", "r" do |f|
|
1007
|
-
rs = f.write
|
1010
|
+
rs = f.write "woot"
|
1008
1011
|
end
|
1009
1012
|
end
|
1010
1013
|
@tc.assert_equal 4, rs
|
@@ -1020,7 +1023,7 @@ class TestMinitestStub < Minitest::Test
|
|
1020
1023
|
@tc.assert_raises ArgumentError do
|
1021
1024
|
File.stub6_2(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
|
1022
1025
|
File.open "foo.txt", "r" do |f|
|
1023
|
-
rs = f.write
|
1026
|
+
rs = f.write "woot"
|
1024
1027
|
end
|
1025
1028
|
end
|
1026
1029
|
end
|
@@ -1069,7 +1072,7 @@ class TestMinitestStub < Minitest::Test
|
|
1069
1072
|
io = StringIO.new(+"", "w")
|
1070
1073
|
File.stub5 :open, :value, io do
|
1071
1074
|
result = File.open "foo.txt", "r" do |f|
|
1072
|
-
rs = f.write
|
1075
|
+
rs = f.write "woot"
|
1073
1076
|
end
|
1074
1077
|
@tc.assert_equal :value, result
|
1075
1078
|
end
|
@@ -1098,7 +1101,7 @@ class TestMinitestStub < Minitest::Test
|
|
1098
1101
|
assert_deprecated do
|
1099
1102
|
File.stub6 :open, :value, io do
|
1100
1103
|
result = File.open "foo.txt", "r" do |f|
|
1101
|
-
rs = f.write
|
1104
|
+
rs = f.write "woot"
|
1102
1105
|
end
|
1103
1106
|
@tc.assert_equal :value, result
|
1104
1107
|
end
|
@@ -2,7 +2,7 @@ require "minitest/autorun"
|
|
2
2
|
require "minitest/metametameta"
|
3
3
|
require "forwardable"
|
4
4
|
|
5
|
-
class
|
5
|
+
class FakeTest < Minitest::Test
|
6
6
|
def woot
|
7
7
|
assert true
|
8
8
|
end
|
@@ -13,10 +13,6 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
13
13
|
attr_accessor :r, :io
|
14
14
|
|
15
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'
|
20
16
|
reporter = Minitest::CompositeReporter.new
|
21
17
|
reporter << Minitest::SummaryReporter.new(self.io)
|
22
18
|
reporter << Minitest::ProgressReporter.new(self.io)
|
@@ -37,7 +33,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
37
33
|
|
38
34
|
def error_test
|
39
35
|
unless defined? @et then
|
40
|
-
@et =
|
36
|
+
@et = FakeTest.new :woot
|
41
37
|
@et.failures << Minitest::UnexpectedError.new(begin
|
42
38
|
raise "no"
|
43
39
|
rescue => e
|
@@ -60,7 +56,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
60
56
|
|
61
57
|
ex.set_backtrace ary
|
62
58
|
|
63
|
-
@sse =
|
59
|
+
@sse = FakeTest.new :woot
|
64
60
|
@sse.failures << Minitest::UnexpectedError.new(ex)
|
65
61
|
@sse = Minitest::Result.from @sse
|
66
62
|
end
|
@@ -69,7 +65,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
69
65
|
|
70
66
|
def fail_test
|
71
67
|
unless defined? @ft then
|
72
|
-
@ft =
|
68
|
+
@ft = FakeTest.new :woot
|
73
69
|
@ft.failures << begin
|
74
70
|
raise Minitest::Assertion, "boo"
|
75
71
|
rescue Minitest::Assertion => e
|
@@ -81,18 +77,18 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
81
77
|
end
|
82
78
|
|
83
79
|
def passing_test
|
84
|
-
@pt ||= Minitest::Result.from
|
80
|
+
@pt ||= Minitest::Result.from FakeTest.new(:woot)
|
85
81
|
end
|
86
82
|
|
87
83
|
def passing_test_with_metadata
|
88
|
-
test =
|
84
|
+
test = FakeTest.new :woot
|
89
85
|
test.metadata[:meta] = :data
|
90
86
|
@pt ||= Minitest::Result.from test
|
91
87
|
end
|
92
88
|
|
93
89
|
def skip_test
|
94
90
|
unless defined? @st then
|
95
|
-
@st =
|
91
|
+
@st = FakeTest.new :woot
|
96
92
|
@st.failures << begin
|
97
93
|
raise Minitest::Skip
|
98
94
|
rescue Minitest::Assertion => e
|
@@ -248,7 +244,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
248
244
|
r.start
|
249
245
|
r.report
|
250
246
|
|
251
|
-
exp =
|
247
|
+
exp = <<~EOM
|
252
248
|
Run options:
|
253
249
|
|
254
250
|
# Running:
|
@@ -268,7 +264,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
268
264
|
r.record passing_test
|
269
265
|
r.report
|
270
266
|
|
271
|
-
exp =
|
267
|
+
exp = <<~EOM
|
272
268
|
Run options:
|
273
269
|
|
274
270
|
# Running:
|
@@ -288,7 +284,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
288
284
|
r.record fail_test
|
289
285
|
r.report
|
290
286
|
|
291
|
-
exp =
|
287
|
+
exp = <<~EOM
|
292
288
|
Run options:
|
293
289
|
|
294
290
|
# Running:
|
@@ -298,7 +294,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
298
294
|
Finished in 0.00
|
299
295
|
|
300
296
|
1) Failure:
|
301
|
-
|
297
|
+
FakeTest#woot [FILE:LINE]:
|
302
298
|
boo
|
303
299
|
|
304
300
|
1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
|
@@ -312,7 +308,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
312
308
|
r.record error_test
|
313
309
|
r.report
|
314
310
|
|
315
|
-
exp =
|
311
|
+
exp = <<~EOM
|
316
312
|
Run options:
|
317
313
|
|
318
314
|
# Running:
|
@@ -322,7 +318,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
322
318
|
Finished in 0.00
|
323
319
|
|
324
320
|
1) Error:
|
325
|
-
|
321
|
+
FakeTest#woot:
|
326
322
|
RuntimeError: no
|
327
323
|
FILE:LINE:in 'error_test'
|
328
324
|
FILE:LINE:in 'test_report_error'
|
@@ -338,7 +334,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
338
334
|
r.record system_stack_error_test
|
339
335
|
r.report
|
340
336
|
|
341
|
-
exp =
|
337
|
+
exp = <<~EOM
|
342
338
|
Run options:
|
343
339
|
|
344
340
|
# Running:
|
@@ -348,7 +344,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
348
344
|
Finished in 0.00
|
349
345
|
|
350
346
|
1) Error:
|
351
|
-
|
347
|
+
FakeTest#woot:
|
352
348
|
SystemStackError: 274 -> 12
|
353
349
|
a
|
354
350
|
b
|
@@ -377,7 +373,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
377
373
|
r.report
|
378
374
|
end
|
379
375
|
|
380
|
-
exp =
|
376
|
+
exp = <<~EOM
|
381
377
|
Run options:
|
382
378
|
|
383
379
|
# Running:
|
@@ -406,7 +402,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
406
402
|
r.report
|
407
403
|
end
|
408
404
|
|
409
|
-
exp = "
|
405
|
+
exp = "FakeTest#woot [foo.rb:123]"
|
410
406
|
|
411
407
|
assert_includes io.string, exp
|
412
408
|
end
|