minitest 5.20.0 → 5.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +130 -3
- data/Manifest.txt +3 -0
- data/README.rdoc +16 -13
- data/Rakefile +6 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +77 -80
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +17 -15
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +16 -23
- data/lib/minitest/spec.rb +5 -5
- data/lib/minitest/test.rb +14 -25
- data/lib/minitest/test_task.rb +17 -12
- data/lib/minitest.rb +257 -144
- data/test/minitest/metametameta.rb +32 -18
- data/test/minitest/test_minitest_assertions.rb +159 -140
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +80 -75
- data/test/minitest/test_minitest_reporter.rb +111 -16
- data/test/minitest/test_minitest_spec.rb +54 -55
- data/test/minitest/test_minitest_test.rb +191 -117
- data/test/minitest/test_minitest_test_task.rb +18 -7
- data.tar.gz.sig +0 -0
- metadata +17 -13
- 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
|
@@ -423,10 +425,12 @@ class TestMinitestMock < Minitest::Test
|
|
423
425
|
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
424
426
|
mock = Minitest::Mock.new
|
425
427
|
|
426
|
-
|
428
|
+
assert_deprecation(/Using MT_KWARGS_HAC. yet passing kwargs/) do
|
427
429
|
mock.expect :foo, nil, [{}], k1: arg1, k2: arg2, k3: arg3
|
428
430
|
end
|
429
431
|
|
432
|
+
skip "-Werror" if error_on_warn? # mock above raised, so this is dead
|
433
|
+
|
430
434
|
mock.foo({}, k1: arg1, k2: arg2, k3: arg3)
|
431
435
|
|
432
436
|
assert_mock mock
|
@@ -439,10 +443,10 @@ class TestMinitestMock < Minitest::Test
|
|
439
443
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
440
444
|
|
441
445
|
e = assert_raises ArgumentError do
|
442
|
-
mock.foo
|
446
|
+
mock.foo k1: arg1, k2: arg2
|
443
447
|
end
|
444
448
|
|
445
|
-
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
|
446
450
|
end
|
447
451
|
|
448
452
|
def test_mock_block_is_passed_keyword_args__args_bad_extra
|
@@ -451,10 +455,10 @@ class TestMinitestMock < Minitest::Test
|
|
451
455
|
mock.expect :foo, nil, k1: arg1, k2: arg2
|
452
456
|
|
453
457
|
e = assert_raises ArgumentError do
|
454
|
-
mock.foo
|
458
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
455
459
|
end
|
456
460
|
|
457
|
-
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
|
458
462
|
end
|
459
463
|
|
460
464
|
def test_mock_block_is_passed_keyword_args__args_bad_key
|
@@ -463,7 +467,7 @@ class TestMinitestMock < Minitest::Test
|
|
463
467
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
464
468
|
|
465
469
|
e = assert_raises MockExpectationError do
|
466
|
-
mock.foo
|
470
|
+
mock.foo k1: arg1, k2: arg2, BAD: arg3
|
467
471
|
end
|
468
472
|
|
469
473
|
assert_includes e.message, "unexpected keywords [:k1, :k2, :k3]"
|
@@ -476,18 +480,18 @@ class TestMinitestMock < Minitest::Test
|
|
476
480
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
477
481
|
|
478
482
|
e = assert_raises MockExpectationError do
|
479
|
-
mock.foo
|
483
|
+
mock.foo k1: arg1, k2: :BAD!, k3: arg3
|
480
484
|
end
|
481
485
|
|
482
|
-
|
486
|
+
bad = { :k2 => :BAD! }.inspect.delete "{}"
|
487
|
+
assert_match(/unexpected keyword arguments.* vs .*#{bad}/, e.message)
|
483
488
|
end
|
484
489
|
|
485
490
|
def test_mock_block_is_passed_function_block
|
486
491
|
mock = Minitest::Mock.new
|
487
492
|
block = proc { "bar" }
|
488
493
|
mock.expect :foo, nil do |arg, &blk|
|
489
|
-
arg == "foo" &&
|
490
|
-
blk == block
|
494
|
+
arg == "foo" && blk == block
|
491
495
|
end
|
492
496
|
mock.foo "foo", &block
|
493
497
|
assert_mock mock
|
@@ -495,8 +499,8 @@ class TestMinitestMock < Minitest::Test
|
|
495
499
|
|
496
500
|
def test_mock_forward_keyword_arguments
|
497
501
|
mock = Minitest::Mock.new
|
498
|
-
mock.expect(:foo, nil) { |bar:| bar ==
|
499
|
-
mock.foo
|
502
|
+
mock.expect(:foo, nil) { |bar:| bar == "bar" }
|
503
|
+
mock.foo bar: "bar"
|
500
504
|
assert_mock mock
|
501
505
|
end
|
502
506
|
|
@@ -515,7 +519,7 @@ class TestMinitestMock < Minitest::Test
|
|
515
519
|
def test_mock_block_raises_if_args_passed
|
516
520
|
mock = Minitest::Mock.new
|
517
521
|
|
518
|
-
e = assert_raises
|
522
|
+
e = assert_raises ArgumentError do
|
519
523
|
mock.expect :foo, nil, [:a, :b, :c] do
|
520
524
|
true
|
521
525
|
end
|
@@ -529,8 +533,8 @@ class TestMinitestMock < Minitest::Test
|
|
529
533
|
def test_mock_block_raises_if_kwargs_passed
|
530
534
|
mock = Minitest::Mock.new
|
531
535
|
|
532
|
-
e = assert_raises
|
533
|
-
mock.expect :foo, nil, kwargs:1 do
|
536
|
+
e = assert_raises ArgumentError do
|
537
|
+
mock.expect :foo, nil, kwargs: 1 do
|
534
538
|
true
|
535
539
|
end
|
536
540
|
end
|
@@ -542,7 +546,7 @@ class TestMinitestMock < Minitest::Test
|
|
542
546
|
|
543
547
|
def test_mock_returns_retval_when_called_with_block
|
544
548
|
mock = Minitest::Mock.new
|
545
|
-
mock.expect
|
549
|
+
mock.expect :foo, 32 do
|
546
550
|
true
|
547
551
|
end
|
548
552
|
|
@@ -561,7 +565,7 @@ class TestMinitestMock < Minitest::Test
|
|
561
565
|
|
562
566
|
def test_mock_called_via_send
|
563
567
|
mock = Minitest::Mock.new
|
564
|
-
mock.expect
|
568
|
+
mock.expect :foo, true
|
565
569
|
|
566
570
|
mock.send :foo
|
567
571
|
assert_mock mock
|
@@ -569,7 +573,7 @@ class TestMinitestMock < Minitest::Test
|
|
569
573
|
|
570
574
|
def test_mock_called_via___send__
|
571
575
|
mock = Minitest::Mock.new
|
572
|
-
mock.expect
|
576
|
+
mock.expect :foo, true
|
573
577
|
|
574
578
|
mock.__send__ :foo
|
575
579
|
assert_mock mock
|
@@ -577,9 +581,9 @@ class TestMinitestMock < Minitest::Test
|
|
577
581
|
|
578
582
|
def test_mock_called_via_send_with_args
|
579
583
|
mock = Minitest::Mock.new
|
580
|
-
mock.expect
|
584
|
+
mock.expect :foo, true, [1, 2, 3]
|
581
585
|
|
582
|
-
mock.send
|
586
|
+
mock.send :foo, 1, 2, 3
|
583
587
|
assert_mock mock
|
584
588
|
end
|
585
589
|
|
@@ -655,7 +659,7 @@ class TestMinitestStub < Minitest::Test
|
|
655
659
|
end
|
656
660
|
end
|
657
661
|
|
658
|
-
def
|
662
|
+
def test_stub_value__literal
|
659
663
|
assert_stub 42
|
660
664
|
end
|
661
665
|
|
@@ -686,7 +690,7 @@ class TestMinitestStub < Minitest::Test
|
|
686
690
|
end
|
687
691
|
|
688
692
|
def test_stub_yield_self
|
689
|
-
obj = "foo"
|
693
|
+
obj = +"foo"
|
690
694
|
|
691
695
|
val = obj.stub :to_s, "bar" do |s|
|
692
696
|
s.to_s
|
@@ -712,7 +716,7 @@ class TestMinitestStub < Minitest::Test
|
|
712
716
|
end
|
713
717
|
end
|
714
718
|
|
715
|
-
val = dynamic.stub
|
719
|
+
val = dynamic.stub :found, true do |s|
|
716
720
|
s.found
|
717
721
|
end
|
718
722
|
|
@@ -727,14 +731,17 @@ class TestMinitestStub < Minitest::Test
|
|
727
731
|
end
|
728
732
|
end
|
729
733
|
|
730
|
-
exp = jruby?
|
731
|
-
|
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
|
732
739
|
assert_match exp, e.message
|
733
740
|
end
|
734
741
|
|
735
742
|
def test_mock_with_yield
|
736
743
|
mock = Minitest::Mock.new
|
737
|
-
mock.expect
|
744
|
+
mock.expect :write, true do
|
738
745
|
true
|
739
746
|
end
|
740
747
|
rs = nil
|
@@ -751,7 +758,7 @@ class TestMinitestStub < Minitest::Test
|
|
751
758
|
mock = Minitest::Mock.new
|
752
759
|
rs = nil
|
753
760
|
|
754
|
-
File.stub :open, true, mock, kw:42 do
|
761
|
+
File.stub :open, true, mock, kw: 42 do
|
755
762
|
File.open "foo.txt", "r" do |f, kw:|
|
756
763
|
rs = kw
|
757
764
|
end
|
@@ -760,8 +767,6 @@ class TestMinitestStub < Minitest::Test
|
|
760
767
|
@tc.assert_equal 42, rs
|
761
768
|
end
|
762
769
|
|
763
|
-
alias test_stub_value__old test_stub_value # TODO: remove/rename
|
764
|
-
|
765
770
|
## Permutation Sets:
|
766
771
|
|
767
772
|
# [:value, :lambda]
|
@@ -816,7 +821,7 @@ class TestMinitestStub < Minitest::Test
|
|
816
821
|
# [:value, :block_call, :args] => N/A
|
817
822
|
|
818
823
|
class Bar
|
819
|
-
def call
|
824
|
+
def call &_ # to ignore unused block
|
820
825
|
puts "hi"
|
821
826
|
end
|
822
827
|
end
|
@@ -834,7 +839,7 @@ class TestMinitestStub < Minitest::Test
|
|
834
839
|
end
|
835
840
|
|
836
841
|
class Keywords
|
837
|
-
def self.args req, kw1:, kw2:24
|
842
|
+
def self.args req, kw1:, kw2: 24
|
838
843
|
[req, kw1, kw2]
|
839
844
|
end
|
840
845
|
end
|
@@ -848,7 +853,7 @@ class TestMinitestStub < Minitest::Test
|
|
848
853
|
def test_stub__hash_as_last_real_arg
|
849
854
|
with_kwargs_env do
|
850
855
|
token = Object.new
|
851
|
-
def token.create_with_retry
|
856
|
+
def token.create_with_retry _u, _p; raise "shouldn't see this"; end
|
852
857
|
|
853
858
|
controller = Object.new
|
854
859
|
controller.define_singleton_method :create do |u, p|
|
@@ -956,7 +961,7 @@ class TestMinitestStub < Minitest::Test
|
|
956
961
|
def test_stub_lambda_block_call_5
|
957
962
|
@assertion_count += 1
|
958
963
|
rs = nil
|
959
|
-
io = StringIO.new
|
964
|
+
io = StringIO.new(+"", "w")
|
960
965
|
File.stub5 :open, lambda { |p, m, &blk| blk and blk.call io } do
|
961
966
|
File.open "foo.txt", "r" do |f|
|
962
967
|
rs = f && f.write("woot")
|
@@ -971,10 +976,10 @@ class TestMinitestStub < Minitest::Test
|
|
971
976
|
|
972
977
|
@assertion_count += 1
|
973
978
|
rs = nil
|
974
|
-
io = StringIO.new
|
979
|
+
io = StringIO.new(+"", "w")
|
975
980
|
File.stub6 :open, lambda { |p, m, &blk| blk.call io } do
|
976
981
|
File.open "foo.txt", "r" do |f|
|
977
|
-
rs = f.write
|
982
|
+
rs = f.write "woot"
|
978
983
|
end
|
979
984
|
end
|
980
985
|
@tc.assert_equal 4, rs
|
@@ -984,10 +989,10 @@ class TestMinitestStub < Minitest::Test
|
|
984
989
|
def test_stub_lambda_block_call_args_5
|
985
990
|
@assertion_count += 1
|
986
991
|
rs = nil
|
987
|
-
io = StringIO.new
|
992
|
+
io = StringIO.new(+"", "w")
|
988
993
|
File.stub5(:open, lambda { |p, m, &blk| blk and blk.call io }, :WTF?) do
|
989
994
|
File.open "foo.txt", "r" do |f|
|
990
|
-
rs = f.write
|
995
|
+
rs = f.write "woot"
|
991
996
|
end
|
992
997
|
end
|
993
998
|
@tc.assert_equal 4, rs
|
@@ -999,10 +1004,10 @@ class TestMinitestStub < Minitest::Test
|
|
999
1004
|
|
1000
1005
|
@assertion_count += 1
|
1001
1006
|
rs = nil
|
1002
|
-
io = StringIO.new
|
1007
|
+
io = StringIO.new(+"", "w")
|
1003
1008
|
File.stub6(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
|
1004
1009
|
File.open "foo.txt", "r" do |f|
|
1005
|
-
rs = f.write
|
1010
|
+
rs = f.write "woot"
|
1006
1011
|
end
|
1007
1012
|
end
|
1008
1013
|
@tc.assert_equal 4, rs
|
@@ -1014,11 +1019,11 @@ class TestMinitestStub < Minitest::Test
|
|
1014
1019
|
|
1015
1020
|
@assertion_count += 2
|
1016
1021
|
rs = nil
|
1017
|
-
io = StringIO.new
|
1022
|
+
io = StringIO.new(+"", "w")
|
1018
1023
|
@tc.assert_raises ArgumentError do
|
1019
1024
|
File.stub6_2(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
|
1020
1025
|
File.open "foo.txt", "r" do |f|
|
1021
|
-
rs = f.write
|
1026
|
+
rs = f.write "woot"
|
1022
1027
|
end
|
1023
1028
|
end
|
1024
1029
|
end
|
@@ -1064,10 +1069,10 @@ class TestMinitestStub < Minitest::Test
|
|
1064
1069
|
def test_stub_value_block_args_5
|
1065
1070
|
@assertion_count += 2
|
1066
1071
|
rs = nil
|
1067
|
-
io = StringIO.new
|
1072
|
+
io = StringIO.new(+"", "w")
|
1068
1073
|
File.stub5 :open, :value, io do
|
1069
1074
|
result = File.open "foo.txt", "r" do |f|
|
1070
|
-
rs = f.write
|
1075
|
+
rs = f.write "woot"
|
1071
1076
|
end
|
1072
1077
|
@tc.assert_equal :value, result
|
1073
1078
|
end
|
@@ -1083,7 +1088,7 @@ class TestMinitestStub < Minitest::Test
|
|
1083
1088
|
end
|
1084
1089
|
end
|
1085
1090
|
end
|
1086
|
-
exp = /undefined method `write' for nil/
|
1091
|
+
exp = /undefined method [`']write' for nil/
|
1087
1092
|
assert_match exp, e.message
|
1088
1093
|
end
|
1089
1094
|
|
@@ -1092,11 +1097,11 @@ class TestMinitestStub < Minitest::Test
|
|
1092
1097
|
|
1093
1098
|
@assertion_count += 2
|
1094
1099
|
rs = nil
|
1095
|
-
io = StringIO.new
|
1100
|
+
io = StringIO.new(+"", "w")
|
1096
1101
|
assert_deprecated do
|
1097
1102
|
File.stub6 :open, :value, io do
|
1098
1103
|
result = File.open "foo.txt", "r" do |f|
|
1099
|
-
rs = f.write
|
1104
|
+
rs = f.write "woot"
|
1100
1105
|
end
|
1101
1106
|
@tc.assert_equal :value, result
|
1102
1107
|
end
|
@@ -1110,7 +1115,7 @@ class TestMinitestStub < Minitest::Test
|
|
1110
1115
|
|
1111
1116
|
@assertion_count += 2
|
1112
1117
|
rs = nil
|
1113
|
-
io = StringIO.new
|
1118
|
+
io = StringIO.new(+"", "w")
|
1114
1119
|
@tc.assert_raises ArgumentError do
|
1115
1120
|
File.stub6_2 :open, :value, io do
|
1116
1121
|
result = File.open "foo.txt", "r" do |f|
|