minitest 5.16.3 → 5.25.1
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 +176 -1
- data/Manifest.txt +3 -0
- data/README.rdoc +26 -25
- data/Rakefile +7 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +126 -79
- 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/expectations.rb +18 -0
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +23 -17
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +16 -23
- data/lib/minitest/spec.rb +10 -4
- data/lib/minitest/test.rb +22 -37
- data/lib/minitest/test_task.rb +24 -22
- data/lib/minitest.rb +296 -148
- data/test/minitest/metametameta.rb +32 -18
- data/test/minitest/test_minitest_assertions.rb +269 -140
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +89 -77
- data/test/minitest/test_minitest_reporter.rb +139 -15
- data/test/minitest/test_minitest_spec.rb +130 -55
- data/test/minitest/test_minitest_test.rb +200 -116
- data/test/minitest/test_minitest_test_task.rb +18 -7
- data.tar.gz.sig +0 -0
- metadata +20 -16
- metadata.gz.sig +0 -0
@@ -9,11 +9,10 @@ ensure
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class TestMinitestMock < Minitest::Test
|
12
|
-
parallelize_me!
|
13
|
-
|
14
12
|
def setup
|
15
|
-
@mock = Minitest::Mock.new
|
16
|
-
|
13
|
+
@mock = Minitest::Mock.new
|
14
|
+
.expect(:foo, nil)
|
15
|
+
.expect(:meaning_of_life, 42)
|
17
16
|
end
|
18
17
|
|
19
18
|
def test_create_stub_method
|
@@ -38,14 +37,14 @@ class TestMinitestMock < Minitest::Test
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def test_allow_expectations_to_be_added_after_creation
|
41
|
-
@mock.expect
|
40
|
+
@mock.expect :bar, true
|
42
41
|
assert @mock.bar
|
43
42
|
end
|
44
43
|
|
45
44
|
def test_not_verify_if_new_expected_method_is_not_called
|
46
45
|
@mock.foo
|
47
46
|
@mock.meaning_of_life
|
48
|
-
@mock.expect
|
47
|
+
@mock.expect :bar, true
|
49
48
|
|
50
49
|
util_verify_bad "expected bar() => true"
|
51
50
|
end
|
@@ -53,7 +52,7 @@ class TestMinitestMock < Minitest::Test
|
|
53
52
|
def test_blow_up_on_wrong_number_of_arguments
|
54
53
|
@mock.foo
|
55
54
|
@mock.meaning_of_life
|
56
|
-
@mock.expect
|
55
|
+
@mock.expect :sum, 3, [1, 2]
|
57
56
|
|
58
57
|
e = assert_raises ArgumentError do
|
59
58
|
@mock.sum
|
@@ -65,7 +64,7 @@ class TestMinitestMock < Minitest::Test
|
|
65
64
|
def test_return_mock_does_not_raise
|
66
65
|
retval = Minitest::Mock.new
|
67
66
|
mock = Minitest::Mock.new
|
68
|
-
mock.expect
|
67
|
+
mock.expect :foo, retval
|
69
68
|
mock.foo
|
70
69
|
|
71
70
|
assert_mock mock
|
@@ -74,8 +73,8 @@ class TestMinitestMock < Minitest::Test
|
|
74
73
|
def test_mock_args_does_not_raise
|
75
74
|
arg = Minitest::Mock.new
|
76
75
|
mock = Minitest::Mock.new
|
77
|
-
mock.expect
|
78
|
-
mock.foo
|
76
|
+
mock.expect :foo, nil, [arg]
|
77
|
+
mock.foo arg
|
79
78
|
|
80
79
|
assert_mock mock
|
81
80
|
end
|
@@ -115,8 +114,6 @@ class TestMinitestMock < Minitest::Test
|
|
115
114
|
end
|
116
115
|
|
117
116
|
def test_expectations_can_be_satisfied_via_public_send
|
118
|
-
skip "Doesn't run on 1.8" if RUBY_VERSION < "1.9"
|
119
|
-
|
120
117
|
@mock.public_send :foo
|
121
118
|
@mock.public_send :meaning_of_life
|
122
119
|
|
@@ -126,10 +123,10 @@ class TestMinitestMock < Minitest::Test
|
|
126
123
|
def test_blow_up_on_wrong_arguments
|
127
124
|
@mock.foo
|
128
125
|
@mock.meaning_of_life
|
129
|
-
@mock.expect
|
126
|
+
@mock.expect :sum, 3, [1, 2]
|
130
127
|
|
131
128
|
e = assert_raises MockExpectationError do
|
132
|
-
@mock.sum
|
129
|
+
@mock.sum 2, 4
|
133
130
|
end
|
134
131
|
|
135
132
|
exp = "mocked method :sum called with unexpected arguments [2, 4]"
|
@@ -165,8 +162,8 @@ class TestMinitestMock < Minitest::Test
|
|
165
162
|
a = Minitest::Mock.new
|
166
163
|
b = Minitest::Mock.new
|
167
164
|
|
168
|
-
a.expect
|
169
|
-
b.expect
|
165
|
+
a.expect :foo, :a
|
166
|
+
b.expect :foo, :b
|
170
167
|
|
171
168
|
assert_equal :a, a.foo
|
172
169
|
assert_equal :b, b.foo
|
@@ -174,7 +171,7 @@ class TestMinitestMock < Minitest::Test
|
|
174
171
|
|
175
172
|
def test_do_not_create_stub_method_on_new_mocks
|
176
173
|
a = Minitest::Mock.new
|
177
|
-
a.expect
|
174
|
+
a.expect :foo, :a
|
178
175
|
|
179
176
|
assert !Minitest::Mock.new.respond_to?(:foo)
|
180
177
|
end
|
@@ -183,7 +180,7 @@ class TestMinitestMock < Minitest::Test
|
|
183
180
|
@mock.expect :kind_of?, true, [String]
|
184
181
|
@mock.expect :==, true, [1]
|
185
182
|
|
186
|
-
assert @mock.kind_of?(String), "didn't mock :kind_of
|
183
|
+
assert @mock.kind_of?(String), "didn't mock :kind_of?"
|
187
184
|
assert @mock == 1, "didn't mock :=="
|
188
185
|
end
|
189
186
|
|
@@ -260,6 +257,15 @@ class TestMinitestMock < Minitest::Test
|
|
260
257
|
assert_equal exp, e.message
|
261
258
|
end
|
262
259
|
|
260
|
+
def test_delegator_calls_are_propagated
|
261
|
+
delegator = Object.new
|
262
|
+
mock = Minitest::Mock.new delegator
|
263
|
+
|
264
|
+
refute delegator.nil?
|
265
|
+
refute mock.nil?
|
266
|
+
assert_mock mock
|
267
|
+
end
|
268
|
+
|
263
269
|
def test_handles_kwargs_in_error_message
|
264
270
|
mock = Minitest::Mock.new
|
265
271
|
|
@@ -270,9 +276,10 @@ class TestMinitestMock < Minitest::Test
|
|
270
276
|
|
271
277
|
e = assert_raises(MockExpectationError) { mock.verify }
|
272
278
|
|
273
|
-
exp = "expected foo(
|
279
|
+
exp = "expected foo(%p) => nil, got [foo(%p) => nil]" \
|
280
|
+
% [{ :kw => false }, { :kw => true }]
|
274
281
|
|
275
|
-
assert_equal exp, e.message
|
282
|
+
assert_equal exp.delete("{}"), e.message
|
276
283
|
end
|
277
284
|
|
278
285
|
def test_verify_passes_when_mock_block_returns_true
|
@@ -311,7 +318,7 @@ class TestMinitestMock < Minitest::Test
|
|
311
318
|
k1 == arg1 && k2 == arg2 && k3 == arg3
|
312
319
|
end
|
313
320
|
|
314
|
-
mock.foo
|
321
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
315
322
|
|
316
323
|
assert_mock mock
|
317
324
|
end
|
@@ -324,7 +331,7 @@ class TestMinitestMock < Minitest::Test
|
|
324
331
|
end
|
325
332
|
|
326
333
|
e = assert_raises ArgumentError do
|
327
|
-
mock.foo
|
334
|
+
mock.foo k1: arg1, k2: arg2
|
328
335
|
end
|
329
336
|
|
330
337
|
# basically testing ruby ... need ? for ruby < 2.7 :(
|
@@ -339,7 +346,7 @@ class TestMinitestMock < Minitest::Test
|
|
339
346
|
end
|
340
347
|
|
341
348
|
e = assert_raises ArgumentError do
|
342
|
-
mock.foo
|
349
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
343
350
|
end
|
344
351
|
|
345
352
|
# basically testing ruby ... need ? for ruby < 2.7 :(
|
@@ -354,10 +361,12 @@ class TestMinitestMock < Minitest::Test
|
|
354
361
|
end
|
355
362
|
|
356
363
|
e = assert_raises MockExpectationError do
|
357
|
-
mock.foo
|
364
|
+
mock.foo k1: arg1, k2: arg2, k3: :BAD!
|
358
365
|
end
|
359
366
|
|
360
|
-
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
|
+
|
361
370
|
assert_equal exp, e.message
|
362
371
|
end
|
363
372
|
|
@@ -366,7 +375,7 @@ class TestMinitestMock < Minitest::Test
|
|
366
375
|
mock = Minitest::Mock.new
|
367
376
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
368
377
|
|
369
|
-
mock.foo
|
378
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
370
379
|
|
371
380
|
assert_mock mock
|
372
381
|
end
|
@@ -390,10 +399,10 @@ class TestMinitestMock < Minitest::Test
|
|
390
399
|
def test_mock_block_is_passed_keyword_args__args__old_style_bad
|
391
400
|
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
392
401
|
mock = Minitest::Mock.new
|
393
|
-
mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
|
402
|
+
mock.expect :foo, nil, [{ k1: arg1, k2: arg2, k3: arg3 }]
|
394
403
|
|
395
404
|
e = assert_raises ArgumentError do
|
396
|
-
mock.foo
|
405
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
397
406
|
end
|
398
407
|
|
399
408
|
assert_equal "mocked method :foo expects 1 arguments, got []", e.message
|
@@ -403,9 +412,9 @@ class TestMinitestMock < Minitest::Test
|
|
403
412
|
with_kwargs_env do
|
404
413
|
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
405
414
|
mock = Minitest::Mock.new
|
406
|
-
mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
|
415
|
+
mock.expect :foo, nil, [{ k1: arg1, k2: arg2, k3: arg3 }]
|
407
416
|
|
408
|
-
mock.foo
|
417
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
409
418
|
|
410
419
|
assert_mock mock
|
411
420
|
end
|
@@ -416,10 +425,12 @@ class TestMinitestMock < Minitest::Test
|
|
416
425
|
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
417
426
|
mock = Minitest::Mock.new
|
418
427
|
|
419
|
-
|
428
|
+
assert_deprecation(/Using MT_KWARGS_HAC. yet passing kwargs/) do
|
420
429
|
mock.expect :foo, nil, [{}], k1: arg1, k2: arg2, k3: arg3
|
421
430
|
end
|
422
431
|
|
432
|
+
skip "-Werror" if error_on_warn? # mock above raised, so this is dead
|
433
|
+
|
423
434
|
mock.foo({}, k1: arg1, k2: arg2, k3: arg3)
|
424
435
|
|
425
436
|
assert_mock mock
|
@@ -432,10 +443,10 @@ class TestMinitestMock < Minitest::Test
|
|
432
443
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
433
444
|
|
434
445
|
e = assert_raises ArgumentError do
|
435
|
-
mock.foo
|
446
|
+
mock.foo k1: arg1, k2: arg2
|
436
447
|
end
|
437
448
|
|
438
|
-
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
|
439
450
|
end
|
440
451
|
|
441
452
|
def test_mock_block_is_passed_keyword_args__args_bad_extra
|
@@ -444,10 +455,10 @@ class TestMinitestMock < Minitest::Test
|
|
444
455
|
mock.expect :foo, nil, k1: arg1, k2: arg2
|
445
456
|
|
446
457
|
e = assert_raises ArgumentError do
|
447
|
-
mock.foo
|
458
|
+
mock.foo k1: arg1, k2: arg2, k3: arg3
|
448
459
|
end
|
449
460
|
|
450
|
-
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
|
451
462
|
end
|
452
463
|
|
453
464
|
def test_mock_block_is_passed_keyword_args__args_bad_key
|
@@ -456,7 +467,7 @@ class TestMinitestMock < Minitest::Test
|
|
456
467
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
457
468
|
|
458
469
|
e = assert_raises MockExpectationError do
|
459
|
-
mock.foo
|
470
|
+
mock.foo k1: arg1, k2: arg2, BAD: arg3
|
460
471
|
end
|
461
472
|
|
462
473
|
assert_includes e.message, "unexpected keywords [:k1, :k2, :k3]"
|
@@ -469,18 +480,18 @@ class TestMinitestMock < Minitest::Test
|
|
469
480
|
mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
|
470
481
|
|
471
482
|
e = assert_raises MockExpectationError do
|
472
|
-
mock.foo
|
483
|
+
mock.foo k1: arg1, k2: :BAD!, k3: arg3
|
473
484
|
end
|
474
485
|
|
475
|
-
|
486
|
+
bad = { :k2 => :BAD! }.inspect.delete "{}"
|
487
|
+
assert_match(/unexpected keyword arguments.* vs .*#{bad}/, e.message)
|
476
488
|
end
|
477
489
|
|
478
490
|
def test_mock_block_is_passed_function_block
|
479
491
|
mock = Minitest::Mock.new
|
480
492
|
block = proc { "bar" }
|
481
493
|
mock.expect :foo, nil do |arg, &blk|
|
482
|
-
arg == "foo" &&
|
483
|
-
blk == block
|
494
|
+
arg == "foo" && blk == block
|
484
495
|
end
|
485
496
|
mock.foo "foo", &block
|
486
497
|
assert_mock mock
|
@@ -488,8 +499,8 @@ class TestMinitestMock < Minitest::Test
|
|
488
499
|
|
489
500
|
def test_mock_forward_keyword_arguments
|
490
501
|
mock = Minitest::Mock.new
|
491
|
-
mock.expect(:foo, nil) { |bar:| bar ==
|
492
|
-
mock.foo
|
502
|
+
mock.expect(:foo, nil) { |bar:| bar == "bar" }
|
503
|
+
mock.foo bar: "bar"
|
493
504
|
assert_mock mock
|
494
505
|
end
|
495
506
|
|
@@ -508,7 +519,7 @@ class TestMinitestMock < Minitest::Test
|
|
508
519
|
def test_mock_block_raises_if_args_passed
|
509
520
|
mock = Minitest::Mock.new
|
510
521
|
|
511
|
-
e = assert_raises
|
522
|
+
e = assert_raises ArgumentError do
|
512
523
|
mock.expect :foo, nil, [:a, :b, :c] do
|
513
524
|
true
|
514
525
|
end
|
@@ -522,8 +533,8 @@ class TestMinitestMock < Minitest::Test
|
|
522
533
|
def test_mock_block_raises_if_kwargs_passed
|
523
534
|
mock = Minitest::Mock.new
|
524
535
|
|
525
|
-
e = assert_raises
|
526
|
-
mock.expect :foo, nil, kwargs:1 do
|
536
|
+
e = assert_raises ArgumentError do
|
537
|
+
mock.expect :foo, nil, kwargs: 1 do
|
527
538
|
true
|
528
539
|
end
|
529
540
|
end
|
@@ -535,7 +546,7 @@ class TestMinitestMock < Minitest::Test
|
|
535
546
|
|
536
547
|
def test_mock_returns_retval_when_called_with_block
|
537
548
|
mock = Minitest::Mock.new
|
538
|
-
mock.expect
|
549
|
+
mock.expect :foo, 32 do
|
539
550
|
true
|
540
551
|
end
|
541
552
|
|
@@ -554,7 +565,7 @@ class TestMinitestMock < Minitest::Test
|
|
554
565
|
|
555
566
|
def test_mock_called_via_send
|
556
567
|
mock = Minitest::Mock.new
|
557
|
-
mock.expect
|
568
|
+
mock.expect :foo, true
|
558
569
|
|
559
570
|
mock.send :foo
|
560
571
|
assert_mock mock
|
@@ -562,7 +573,7 @@ class TestMinitestMock < Minitest::Test
|
|
562
573
|
|
563
574
|
def test_mock_called_via___send__
|
564
575
|
mock = Minitest::Mock.new
|
565
|
-
mock.expect
|
576
|
+
mock.expect :foo, true
|
566
577
|
|
567
578
|
mock.__send__ :foo
|
568
579
|
assert_mock mock
|
@@ -570,9 +581,9 @@ class TestMinitestMock < Minitest::Test
|
|
570
581
|
|
571
582
|
def test_mock_called_via_send_with_args
|
572
583
|
mock = Minitest::Mock.new
|
573
|
-
mock.expect
|
584
|
+
mock.expect :foo, true, [1, 2, 3]
|
574
585
|
|
575
|
-
mock.send
|
586
|
+
mock.send :foo, 1, 2, 3
|
576
587
|
assert_mock mock
|
577
588
|
end
|
578
589
|
|
@@ -648,7 +659,7 @@ class TestMinitestStub < Minitest::Test
|
|
648
659
|
end
|
649
660
|
end
|
650
661
|
|
651
|
-
def
|
662
|
+
def test_stub_value__literal
|
652
663
|
assert_stub 42
|
653
664
|
end
|
654
665
|
|
@@ -679,7 +690,7 @@ class TestMinitestStub < Minitest::Test
|
|
679
690
|
end
|
680
691
|
|
681
692
|
def test_stub_yield_self
|
682
|
-
obj = "foo"
|
693
|
+
obj = +"foo"
|
683
694
|
|
684
695
|
val = obj.stub :to_s, "bar" do |s|
|
685
696
|
s.to_s
|
@@ -705,7 +716,7 @@ class TestMinitestStub < Minitest::Test
|
|
705
716
|
end
|
706
717
|
end
|
707
718
|
|
708
|
-
val = dynamic.stub
|
719
|
+
val = dynamic.stub :found, true do |s|
|
709
720
|
s.found
|
710
721
|
end
|
711
722
|
|
@@ -720,14 +731,17 @@ class TestMinitestStub < Minitest::Test
|
|
720
731
|
end
|
721
732
|
end
|
722
733
|
|
723
|
-
exp = jruby?
|
724
|
-
|
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
|
725
739
|
assert_match exp, e.message
|
726
740
|
end
|
727
741
|
|
728
742
|
def test_mock_with_yield
|
729
743
|
mock = Minitest::Mock.new
|
730
|
-
mock.expect
|
744
|
+
mock.expect :write, true do
|
731
745
|
true
|
732
746
|
end
|
733
747
|
rs = nil
|
@@ -744,7 +758,7 @@ class TestMinitestStub < Minitest::Test
|
|
744
758
|
mock = Minitest::Mock.new
|
745
759
|
rs = nil
|
746
760
|
|
747
|
-
File.stub :open, true, mock, kw:42 do
|
761
|
+
File.stub :open, true, mock, kw: 42 do
|
748
762
|
File.open "foo.txt", "r" do |f, kw:|
|
749
763
|
rs = kw
|
750
764
|
end
|
@@ -753,8 +767,6 @@ class TestMinitestStub < Minitest::Test
|
|
753
767
|
@tc.assert_equal 42, rs
|
754
768
|
end
|
755
769
|
|
756
|
-
alias test_stub_value__old test_stub_value # TODO: remove/rename
|
757
|
-
|
758
770
|
## Permutation Sets:
|
759
771
|
|
760
772
|
# [:value, :lambda]
|
@@ -809,7 +821,7 @@ class TestMinitestStub < Minitest::Test
|
|
809
821
|
# [:value, :block_call, :args] => N/A
|
810
822
|
|
811
823
|
class Bar
|
812
|
-
def call
|
824
|
+
def call &_ # to ignore unused block
|
813
825
|
puts "hi"
|
814
826
|
end
|
815
827
|
end
|
@@ -827,7 +839,7 @@ class TestMinitestStub < Minitest::Test
|
|
827
839
|
end
|
828
840
|
|
829
841
|
class Keywords
|
830
|
-
def self.args req, kw1:, kw2:24
|
842
|
+
def self.args req, kw1:, kw2: 24
|
831
843
|
[req, kw1, kw2]
|
832
844
|
end
|
833
845
|
end
|
@@ -841,7 +853,7 @@ class TestMinitestStub < Minitest::Test
|
|
841
853
|
def test_stub__hash_as_last_real_arg
|
842
854
|
with_kwargs_env do
|
843
855
|
token = Object.new
|
844
|
-
def token.create_with_retry
|
856
|
+
def token.create_with_retry _u, _p; raise "shouldn't see this"; end
|
845
857
|
|
846
858
|
controller = Object.new
|
847
859
|
controller.define_singleton_method :create do |u, p|
|
@@ -949,7 +961,7 @@ class TestMinitestStub < Minitest::Test
|
|
949
961
|
def test_stub_lambda_block_call_5
|
950
962
|
@assertion_count += 1
|
951
963
|
rs = nil
|
952
|
-
io = StringIO.new
|
964
|
+
io = StringIO.new(+"", "w")
|
953
965
|
File.stub5 :open, lambda { |p, m, &blk| blk and blk.call io } do
|
954
966
|
File.open "foo.txt", "r" do |f|
|
955
967
|
rs = f && f.write("woot")
|
@@ -964,10 +976,10 @@ class TestMinitestStub < Minitest::Test
|
|
964
976
|
|
965
977
|
@assertion_count += 1
|
966
978
|
rs = nil
|
967
|
-
io = StringIO.new
|
979
|
+
io = StringIO.new(+"", "w")
|
968
980
|
File.stub6 :open, lambda { |p, m, &blk| blk.call io } do
|
969
981
|
File.open "foo.txt", "r" do |f|
|
970
|
-
rs = f.write
|
982
|
+
rs = f.write "woot"
|
971
983
|
end
|
972
984
|
end
|
973
985
|
@tc.assert_equal 4, rs
|
@@ -977,10 +989,10 @@ class TestMinitestStub < Minitest::Test
|
|
977
989
|
def test_stub_lambda_block_call_args_5
|
978
990
|
@assertion_count += 1
|
979
991
|
rs = nil
|
980
|
-
io = StringIO.new
|
992
|
+
io = StringIO.new(+"", "w")
|
981
993
|
File.stub5(:open, lambda { |p, m, &blk| blk and blk.call io }, :WTF?) do
|
982
994
|
File.open "foo.txt", "r" do |f|
|
983
|
-
rs = f.write
|
995
|
+
rs = f.write "woot"
|
984
996
|
end
|
985
997
|
end
|
986
998
|
@tc.assert_equal 4, rs
|
@@ -992,10 +1004,10 @@ class TestMinitestStub < Minitest::Test
|
|
992
1004
|
|
993
1005
|
@assertion_count += 1
|
994
1006
|
rs = nil
|
995
|
-
io = StringIO.new
|
1007
|
+
io = StringIO.new(+"", "w")
|
996
1008
|
File.stub6(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
|
997
1009
|
File.open "foo.txt", "r" do |f|
|
998
|
-
rs = f.write
|
1010
|
+
rs = f.write "woot"
|
999
1011
|
end
|
1000
1012
|
end
|
1001
1013
|
@tc.assert_equal 4, rs
|
@@ -1007,11 +1019,11 @@ class TestMinitestStub < Minitest::Test
|
|
1007
1019
|
|
1008
1020
|
@assertion_count += 2
|
1009
1021
|
rs = nil
|
1010
|
-
io = StringIO.new
|
1022
|
+
io = StringIO.new(+"", "w")
|
1011
1023
|
@tc.assert_raises ArgumentError do
|
1012
1024
|
File.stub6_2(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
|
1013
1025
|
File.open "foo.txt", "r" do |f|
|
1014
|
-
rs = f.write
|
1026
|
+
rs = f.write "woot"
|
1015
1027
|
end
|
1016
1028
|
end
|
1017
1029
|
end
|
@@ -1057,10 +1069,10 @@ class TestMinitestStub < Minitest::Test
|
|
1057
1069
|
def test_stub_value_block_args_5
|
1058
1070
|
@assertion_count += 2
|
1059
1071
|
rs = nil
|
1060
|
-
io = StringIO.new
|
1072
|
+
io = StringIO.new(+"", "w")
|
1061
1073
|
File.stub5 :open, :value, io do
|
1062
1074
|
result = File.open "foo.txt", "r" do |f|
|
1063
|
-
rs = f.write
|
1075
|
+
rs = f.write "woot"
|
1064
1076
|
end
|
1065
1077
|
@tc.assert_equal :value, result
|
1066
1078
|
end
|
@@ -1076,7 +1088,7 @@ class TestMinitestStub < Minitest::Test
|
|
1076
1088
|
end
|
1077
1089
|
end
|
1078
1090
|
end
|
1079
|
-
exp =
|
1091
|
+
exp = /undefined method [`']write' for nil/
|
1080
1092
|
assert_match exp, e.message
|
1081
1093
|
end
|
1082
1094
|
|
@@ -1085,11 +1097,11 @@ class TestMinitestStub < Minitest::Test
|
|
1085
1097
|
|
1086
1098
|
@assertion_count += 2
|
1087
1099
|
rs = nil
|
1088
|
-
io = StringIO.new
|
1100
|
+
io = StringIO.new(+"", "w")
|
1089
1101
|
assert_deprecated do
|
1090
1102
|
File.stub6 :open, :value, io do
|
1091
1103
|
result = File.open "foo.txt", "r" do |f|
|
1092
|
-
rs = f.write
|
1104
|
+
rs = f.write "woot"
|
1093
1105
|
end
|
1094
1106
|
@tc.assert_equal :value, result
|
1095
1107
|
end
|
@@ -1103,7 +1115,7 @@ class TestMinitestStub < Minitest::Test
|
|
1103
1115
|
|
1104
1116
|
@assertion_count += 2
|
1105
1117
|
rs = nil
|
1106
|
-
io = StringIO.new
|
1118
|
+
io = StringIO.new(+"", "w")
|
1107
1119
|
@tc.assert_raises ArgumentError do
|
1108
1120
|
File.stub6_2 :open, :value, io do
|
1109
1121
|
result = File.open "foo.txt", "r" do |f|
|