minitest 5.14.0 → 5.17.0
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 +117 -4
- data/Manifest.txt +2 -0
- data/README.rdoc +78 -11
- data/Rakefile +4 -2
- data/lib/hoe/minitest.rb +0 -4
- data/lib/minitest/assertions.rb +8 -7
- data/lib/minitest/benchmark.rb +5 -5
- data/lib/minitest/expectations.rb +29 -29
- data/lib/minitest/mock.rb +119 -32
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/spec.rb +9 -2
- data/lib/minitest/test.rb +42 -6
- data/lib/minitest/test_task.rb +305 -0
- data/lib/minitest/unit.rb +5 -8
- data/lib/minitest.rb +51 -26
- data/test/minitest/metametameta.rb +20 -1
- data/test/minitest/test_minitest_assertions.rb +49 -25
- data/test/minitest/test_minitest_benchmark.rb +2 -2
- data/test/minitest/test_minitest_mock.rb +286 -12
- data/test/minitest/test_minitest_reporter.rb +30 -17
- data/test/minitest/test_minitest_spec.rb +114 -50
- data/test/minitest/test_minitest_test.rb +225 -33
- data/test/minitest/test_minitest_test_task.rb +46 -0
- data.tar.gz.sig +0 -0
- metadata +23 -18
- metadata.gz.sig +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
require "minitest/autorun"
|
2
2
|
require "minitest/metametameta"
|
3
|
+
require "forwardable"
|
3
4
|
|
4
5
|
class Runnable
|
5
6
|
def woot
|
@@ -12,30 +13,24 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
12
13
|
attr_accessor :r, :io
|
13
14
|
|
14
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'
|
15
20
|
reporter = Minitest::CompositeReporter.new
|
16
21
|
reporter << Minitest::SummaryReporter.new(self.io)
|
17
22
|
reporter << Minitest::ProgressReporter.new(self.io)
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def reporter.results
|
24
|
-
first.results
|
25
|
-
end
|
26
|
-
|
27
|
-
def reporter.count
|
28
|
-
first.count
|
29
|
-
end
|
30
|
-
|
31
|
-
def reporter.assertions
|
32
|
-
first.assertions
|
33
|
-
end
|
24
|
+
# eg reporter.results -> reporters.first.results
|
25
|
+
reporter.extend Forwardable
|
26
|
+
reporter.delegate :first => :reporters
|
27
|
+
reporter.delegate %i[results count assertions options to_s] => :first
|
34
28
|
|
35
29
|
reporter
|
36
30
|
end
|
37
31
|
|
38
32
|
def setup
|
33
|
+
super
|
39
34
|
self.io = StringIO.new("")
|
40
35
|
self.r = new_composite_reporter
|
41
36
|
end
|
@@ -86,7 +81,25 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
86
81
|
def test_to_s
|
87
82
|
r.record passing_test
|
88
83
|
r.record fail_test
|
89
|
-
assert_match "woot", r.
|
84
|
+
assert_match "woot", r.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_options_skip_F
|
88
|
+
r.options[:skip] = "F"
|
89
|
+
|
90
|
+
r.record passing_test
|
91
|
+
r.record fail_test
|
92
|
+
|
93
|
+
refute_match "woot", r.to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_options_skip_E
|
97
|
+
r.options[:skip] = "E"
|
98
|
+
|
99
|
+
r.record passing_test
|
100
|
+
r.record error_test
|
101
|
+
|
102
|
+
refute_match "RuntimeError: no", r.to_s
|
90
103
|
end
|
91
104
|
|
92
105
|
def test_passed_eh_empty
|
@@ -126,7 +139,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
126
139
|
end
|
127
140
|
|
128
141
|
def test_passed_eh_skipped_verbose
|
129
|
-
r.
|
142
|
+
r.options[:verbose] = true
|
130
143
|
|
131
144
|
r.start
|
132
145
|
r.results << skip_test
|
@@ -43,6 +43,10 @@ describe Minitest::Spec do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def assert_success spec
|
47
|
+
assert_equal true, spec
|
48
|
+
end
|
49
|
+
|
46
50
|
before do
|
47
51
|
@assertion_count = 4
|
48
52
|
end
|
@@ -62,7 +66,7 @@ describe Minitest::Spec do
|
|
62
66
|
it "needs to check for file existence" do
|
63
67
|
@assertion_count = 3
|
64
68
|
|
65
|
-
_(
|
69
|
+
assert_success _(__FILE__).path_must_exist
|
66
70
|
|
67
71
|
assert_triggered "Expected path 'blah' to exist." do
|
68
72
|
_("blah").path_must_exist
|
@@ -72,7 +76,7 @@ describe Minitest::Spec do
|
|
72
76
|
it "needs to check for file non-existence" do
|
73
77
|
@assertion_count = 3
|
74
78
|
|
75
|
-
_(
|
79
|
+
assert_success _("blah").path_wont_exist
|
76
80
|
|
77
81
|
assert_triggered "Expected path '#{__FILE__}' to not exist." do
|
78
82
|
_(__FILE__).path_wont_exist
|
@@ -82,7 +86,7 @@ describe Minitest::Spec do
|
|
82
86
|
it "needs to be sensible about must_include order" do
|
83
87
|
@assertion_count += 3 # must_include is 2 assertions
|
84
88
|
|
85
|
-
_(
|
89
|
+
assert_success _([1, 2, 3]).must_include(2)
|
86
90
|
|
87
91
|
assert_triggered "Expected [1, 2, 3] to include 5." do
|
88
92
|
_([1, 2, 3]).must_include 5
|
@@ -96,7 +100,7 @@ describe Minitest::Spec do
|
|
96
100
|
it "needs to be sensible about wont_include order" do
|
97
101
|
@assertion_count += 3 # wont_include is 2 assertions
|
98
102
|
|
99
|
-
_(
|
103
|
+
assert_success _([1, 2, 3]).wont_include(5)
|
100
104
|
|
101
105
|
assert_triggered "Expected [1, 2, 3] to not include 2." do
|
102
106
|
_([1, 2, 3]).wont_include 2
|
@@ -137,7 +141,7 @@ describe Minitest::Spec do
|
|
137
141
|
@assertion_count -= 1 # no msg
|
138
142
|
@assertion_count += 2 # assert_output is 2 assertions
|
139
143
|
|
140
|
-
|
144
|
+
assert_success expect {}.must_be_silent
|
141
145
|
|
142
146
|
assert_triggered "In stdout.\nExpected: \"\"\n Actual: \"xxx\"" do
|
143
147
|
expect { print "xxx" }.must_be_silent
|
@@ -195,7 +199,7 @@ describe Minitest::Spec do
|
|
195
199
|
end
|
196
200
|
|
197
201
|
it "needs to verify binary messages" do
|
198
|
-
_(
|
202
|
+
assert_success _(42).wont_be(:<, 24)
|
199
203
|
|
200
204
|
assert_triggered "Expected 24 to not be < 42." do
|
201
205
|
_(24).wont_be :<, 42
|
@@ -209,7 +213,7 @@ describe Minitest::Spec do
|
|
209
213
|
it "needs to verify emptyness" do
|
210
214
|
@assertion_count += 3 # empty is 2 assertions
|
211
215
|
|
212
|
-
_(
|
216
|
+
assert_success _([]).must_be_empty
|
213
217
|
|
214
218
|
assert_triggered "Expected [42] to be empty." do
|
215
219
|
_([42]).must_be_empty
|
@@ -223,7 +227,7 @@ describe Minitest::Spec do
|
|
223
227
|
it "needs to verify equality" do
|
224
228
|
@assertion_count += 1
|
225
229
|
|
226
|
-
_(
|
230
|
+
assert_success _(6 * 7).must_equal(42)
|
227
231
|
|
228
232
|
assert_triggered "Expected: 42\n Actual: 54" do
|
229
233
|
_(6 * 9).must_equal 42
|
@@ -242,7 +246,7 @@ describe Minitest::Spec do
|
|
242
246
|
@assertion_count += 1 # extra test
|
243
247
|
|
244
248
|
out, err = capture_io do
|
245
|
-
_(
|
249
|
+
assert_success _(nil).must_equal(nil)
|
246
250
|
end
|
247
251
|
|
248
252
|
exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
|
@@ -256,7 +260,7 @@ describe Minitest::Spec do
|
|
256
260
|
it "needs to verify floats outside a delta" do
|
257
261
|
@assertion_count += 1 # extra test
|
258
262
|
|
259
|
-
_(
|
263
|
+
assert_success _(24).wont_be_close_to(42)
|
260
264
|
|
261
265
|
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.001." do
|
262
266
|
_(6 * 7.0).wont_be_close_to 42
|
@@ -275,7 +279,7 @@ describe Minitest::Spec do
|
|
275
279
|
it "needs to verify floats outside an epsilon" do
|
276
280
|
@assertion_count += 1 # extra test
|
277
281
|
|
278
|
-
_(
|
282
|
+
assert_success _(24).wont_be_within_epsilon(42)
|
279
283
|
|
280
284
|
x = "0.042"
|
281
285
|
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
@@ -295,7 +299,7 @@ describe Minitest::Spec do
|
|
295
299
|
it "needs to verify floats within a delta" do
|
296
300
|
@assertion_count += 1 # extra test
|
297
301
|
|
298
|
-
_(
|
302
|
+
assert_success _(6.0 * 7).must_be_close_to(42.0)
|
299
303
|
|
300
304
|
assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.001." do
|
301
305
|
_(1.0 / 100).must_be_close_to 0.0
|
@@ -314,7 +318,7 @@ describe Minitest::Spec do
|
|
314
318
|
it "needs to verify floats within an epsilon" do
|
315
319
|
@assertion_count += 1 # extra test
|
316
320
|
|
317
|
-
_(
|
321
|
+
assert_success _(6.0 * 7).must_be_within_epsilon(42.0)
|
318
322
|
|
319
323
|
assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.0." do
|
320
324
|
_(1.0 / 100).must_be_within_epsilon 0.0
|
@@ -330,7 +334,7 @@ describe Minitest::Spec do
|
|
330
334
|
end
|
331
335
|
|
332
336
|
it "needs to verify identity" do
|
333
|
-
_(
|
337
|
+
assert_success _(1).must_be_same_as(1)
|
334
338
|
|
335
339
|
assert_triggered "Expected 1 (oid=N) to be the same as 2 (oid=N)." do
|
336
340
|
_(1).must_be_same_as 2
|
@@ -343,8 +347,8 @@ describe Minitest::Spec do
|
|
343
347
|
|
344
348
|
it "needs to verify inequality" do
|
345
349
|
@assertion_count += 2
|
346
|
-
_(
|
347
|
-
_(
|
350
|
+
assert_success _(42).wont_equal(6 * 9)
|
351
|
+
assert_success _(proc {}).wont_equal(42)
|
348
352
|
|
349
353
|
assert_triggered "Expected 1 to not be equal to 1." do
|
350
354
|
_(1).wont_equal 1
|
@@ -356,7 +360,7 @@ describe Minitest::Spec do
|
|
356
360
|
end
|
357
361
|
|
358
362
|
it "needs to verify instances of a class" do
|
359
|
-
_(
|
363
|
+
assert_success _(42).wont_be_instance_of(String)
|
360
364
|
|
361
365
|
assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
|
362
366
|
_(42).wont_be_kind_of Int
|
@@ -370,8 +374,8 @@ describe Minitest::Spec do
|
|
370
374
|
it "needs to verify kinds of a class" do
|
371
375
|
@assertion_count += 2
|
372
376
|
|
373
|
-
_(
|
374
|
-
_(
|
377
|
+
assert_success _(42).wont_be_kind_of(String)
|
378
|
+
assert_success _(proc {}).wont_be_kind_of(String)
|
375
379
|
|
376
380
|
assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
|
377
381
|
_(42).wont_be_kind_of Int
|
@@ -385,8 +389,8 @@ describe Minitest::Spec do
|
|
385
389
|
it "needs to verify kinds of objects" do
|
386
390
|
@assertion_count += 3 # extra test
|
387
391
|
|
388
|
-
_(
|
389
|
-
_(
|
392
|
+
assert_success _(6 * 7).must_be_kind_of(Int)
|
393
|
+
assert_success _(6 * 7).must_be_kind_of(Numeric)
|
390
394
|
|
391
395
|
assert_triggered "Expected 42 to be a kind of String, not #{Int.name}." do
|
392
396
|
_(6 * 7).must_be_kind_of String
|
@@ -405,7 +409,7 @@ describe Minitest::Spec do
|
|
405
409
|
it "needs to verify mismatch" do
|
406
410
|
@assertion_count += 3 # match is 2
|
407
411
|
|
408
|
-
_(
|
412
|
+
assert_success _("blah").wont_match(/\d+/)
|
409
413
|
|
410
414
|
assert_triggered "Expected /\\w+/ to not match \"blah\"." do
|
411
415
|
_("blah").wont_match(/\w+/)
|
@@ -417,7 +421,7 @@ describe Minitest::Spec do
|
|
417
421
|
end
|
418
422
|
|
419
423
|
it "needs to verify nil" do
|
420
|
-
_(
|
424
|
+
assert_success _(nil).must_be_nil
|
421
425
|
|
422
426
|
assert_triggered "Expected 42 to be nil." do
|
423
427
|
_(42).must_be_nil
|
@@ -431,7 +435,7 @@ describe Minitest::Spec do
|
|
431
435
|
it "needs to verify non-emptyness" do
|
432
436
|
@assertion_count += 3 # empty is 2 assertions
|
433
437
|
|
434
|
-
_(
|
438
|
+
assert_success _(["some item"]).wont_be_empty
|
435
439
|
|
436
440
|
assert_triggered "Expected [] to not be empty." do
|
437
441
|
_([]).wont_be_empty
|
@@ -443,7 +447,7 @@ describe Minitest::Spec do
|
|
443
447
|
end
|
444
448
|
|
445
449
|
it "needs to verify non-identity" do
|
446
|
-
_(
|
450
|
+
assert_success _(1).wont_be_same_as(2)
|
447
451
|
|
448
452
|
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
449
453
|
_(1).wont_be_same_as 1
|
@@ -455,7 +459,7 @@ describe Minitest::Spec do
|
|
455
459
|
end
|
456
460
|
|
457
461
|
it "needs to verify non-nil" do
|
458
|
-
_(
|
462
|
+
assert_success _(42).wont_be_nil
|
459
463
|
|
460
464
|
assert_triggered "Expected nil to not be nil." do
|
461
465
|
_(nil).wont_be_nil
|
@@ -467,7 +471,7 @@ describe Minitest::Spec do
|
|
467
471
|
end
|
468
472
|
|
469
473
|
it "needs to verify objects not responding to a message" do
|
470
|
-
_(
|
474
|
+
assert_success _("").wont_respond_to(:woot!)
|
471
475
|
|
472
476
|
assert_triggered "Expected \"\" to not respond to to_s." do
|
473
477
|
_("").wont_respond_to :to_s
|
@@ -481,7 +485,7 @@ describe Minitest::Spec do
|
|
481
485
|
it "needs to verify output in stderr" do
|
482
486
|
@assertion_count -= 1 # no msg
|
483
487
|
|
484
|
-
|
488
|
+
assert_success expect { $stderr.print "blah" }.must_output(nil, "blah")
|
485
489
|
|
486
490
|
assert_triggered "In stderr.\nExpected: \"blah\"\n Actual: \"xxx\"" do
|
487
491
|
expect { $stderr.print "xxx" }.must_output(nil, "blah")
|
@@ -491,7 +495,7 @@ describe Minitest::Spec do
|
|
491
495
|
it "needs to verify output in stdout" do
|
492
496
|
@assertion_count -= 1 # no msg
|
493
497
|
|
494
|
-
|
498
|
+
assert_success expect { print "blah" }.must_output("blah")
|
495
499
|
|
496
500
|
assert_triggered "In stdout.\nExpected: \"blah\"\n Actual: \"xxx\"" do
|
497
501
|
expect { print "xxx" }.must_output("blah")
|
@@ -501,7 +505,7 @@ describe Minitest::Spec do
|
|
501
505
|
it "needs to verify regexp matches" do
|
502
506
|
@assertion_count += 3 # must_match is 2 assertions
|
503
507
|
|
504
|
-
_(
|
508
|
+
assert_kind_of MatchData, _("blah").must_match(/\w+/)
|
505
509
|
|
506
510
|
assert_triggered "Expected /\\d+/ to match \"blah\"." do
|
507
511
|
_("blah").must_match(/\d+/)
|
@@ -567,12 +571,29 @@ describe Minitest::Spec do
|
|
567
571
|
(1 + 1).must_equal 2
|
568
572
|
end
|
569
573
|
end
|
574
|
+
|
575
|
+
# https://github.com/seattlerb/minitest/issues/837
|
576
|
+
# https://github.com/rails/rails/pull/39304
|
577
|
+
it "deprecates expectation used without _ with empty backtrace_filter" do
|
578
|
+
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
579
|
+
|
580
|
+
@assertion_count += 3
|
581
|
+
|
582
|
+
exp = /DEPRECATED: global use of must_equal from/
|
583
|
+
|
584
|
+
with_empty_backtrace_filter do
|
585
|
+
assert_output "", exp do
|
586
|
+
(1 + 1).must_equal 2
|
587
|
+
end
|
588
|
+
end
|
589
|
+
end
|
570
590
|
end
|
571
591
|
|
572
592
|
it "needs to verify throw" do
|
573
|
-
@assertion_count +=
|
593
|
+
@assertion_count += 4 # 2 extra tests
|
574
594
|
|
575
|
-
|
595
|
+
assert_nil expect { throw :blah }.must_throw(:blah)
|
596
|
+
assert_equal 42, expect { throw :blah, 42 }.must_throw(:blah)
|
576
597
|
|
577
598
|
assert_triggered "Expected :blah to have been thrown." do
|
578
599
|
expect {}.must_throw :blah
|
@@ -592,7 +613,7 @@ describe Minitest::Spec do
|
|
592
613
|
end
|
593
614
|
|
594
615
|
it "needs to verify types of objects" do
|
595
|
-
_(
|
616
|
+
assert_success _(6 * 7).must_be_instance_of(Int)
|
596
617
|
|
597
618
|
exp = "Expected 42 to be an instance of String, not #{Int.name}."
|
598
619
|
|
@@ -608,7 +629,7 @@ describe Minitest::Spec do
|
|
608
629
|
it "needs to verify using any (negative) predicate" do
|
609
630
|
@assertion_count -= 1 # doesn"t take a message
|
610
631
|
|
611
|
-
_(
|
632
|
+
assert_success _("blah").wont_be(:empty?)
|
612
633
|
|
613
634
|
assert_triggered "Expected \"\" to not be empty?." do
|
614
635
|
_("").wont_be :empty?
|
@@ -618,7 +639,7 @@ describe Minitest::Spec do
|
|
618
639
|
it "needs to verify using any binary operator" do
|
619
640
|
@assertion_count -= 1 # no msg
|
620
641
|
|
621
|
-
_(
|
642
|
+
assert_success _(41).must_be(:<, 42)
|
622
643
|
|
623
644
|
assert_triggered "Expected 42 to be < 41." do
|
624
645
|
_(42).must_be(:<, 41)
|
@@ -628,7 +649,7 @@ describe Minitest::Spec do
|
|
628
649
|
it "needs to verify using any predicate" do
|
629
650
|
@assertion_count -= 1 # no msg
|
630
651
|
|
631
|
-
_(
|
652
|
+
assert_success _("").must_be(:empty?)
|
632
653
|
|
633
654
|
assert_triggered "Expected \"blah\" to be empty?." do
|
634
655
|
_("blah").must_be :empty?
|
@@ -636,7 +657,7 @@ describe Minitest::Spec do
|
|
636
657
|
end
|
637
658
|
|
638
659
|
it "needs to verify using respond_to" do
|
639
|
-
_(
|
660
|
+
assert_success _(42).must_respond_to(:+)
|
640
661
|
|
641
662
|
assert_triggered "Expected 42 (#{Int.name}) to respond to #clear." do
|
642
663
|
_(42).must_respond_to :clear
|
@@ -723,6 +744,10 @@ describe Minitest::Spec, :subject do
|
|
723
744
|
end
|
724
745
|
|
725
746
|
class TestMetaStatic < Minitest::Test
|
747
|
+
def assert_method_count expected, klass
|
748
|
+
assert_equal expected, klass.public_instance_methods.grep(/^test_/).count
|
749
|
+
end
|
750
|
+
|
726
751
|
def test_children
|
727
752
|
Minitest::Spec.children.clear # prevents parallel run
|
728
753
|
|
@@ -756,8 +781,8 @@ class TestMetaStatic < Minitest::Test
|
|
756
781
|
end
|
757
782
|
end
|
758
783
|
|
759
|
-
|
760
|
-
|
784
|
+
assert_method_count 1, outer
|
785
|
+
assert_method_count 1, inner
|
761
786
|
end
|
762
787
|
|
763
788
|
def test_it_wont_add_test_methods_to_children
|
@@ -771,14 +796,18 @@ class TestMetaStatic < Minitest::Test
|
|
771
796
|
end
|
772
797
|
end
|
773
798
|
|
774
|
-
|
775
|
-
|
799
|
+
assert_method_count 1, outer
|
800
|
+
assert_method_count 0, inner
|
776
801
|
end
|
777
802
|
end
|
778
803
|
|
779
804
|
class TestMeta < MetaMetaMetaTestCase
|
780
805
|
# do not call parallelize_me! here because specs use register_spec_type globally
|
781
806
|
|
807
|
+
def assert_defined_methods expected, klass
|
808
|
+
assert_equal expected, klass.instance_methods(false).sort.map(&:to_s)
|
809
|
+
end
|
810
|
+
|
782
811
|
def util_structure
|
783
812
|
y = z = nil
|
784
813
|
before_list = []
|
@@ -851,7 +880,7 @@ class TestMeta < MetaMetaMetaTestCase
|
|
851
880
|
end
|
852
881
|
end
|
853
882
|
|
854
|
-
test_name = spec_class.instance_methods.sort.grep(/
|
883
|
+
test_name = spec_class.instance_methods.sort.grep(/test_/).first
|
855
884
|
|
856
885
|
spec = spec_class.new test_name
|
857
886
|
|
@@ -900,9 +929,9 @@ class TestMeta < MetaMetaMetaTestCase
|
|
900
929
|
inner_methods2 = inner_methods1 +
|
901
930
|
%w[test_0002_anonymous test_0003_anonymous]
|
902
931
|
|
903
|
-
|
904
|
-
|
905
|
-
|
932
|
+
assert_defined_methods top_methods, x
|
933
|
+
assert_defined_methods inner_methods1, y
|
934
|
+
assert_defined_methods inner_methods2, z
|
906
935
|
end
|
907
936
|
|
908
937
|
def test_structure_postfix_it
|
@@ -919,8 +948,8 @@ class TestMeta < MetaMetaMetaTestCase
|
|
919
948
|
it "inner-it" do end
|
920
949
|
end
|
921
950
|
|
922
|
-
|
923
|
-
|
951
|
+
assert_defined_methods %w[test_0001_inner-it], y
|
952
|
+
assert_defined_methods %w[test_0001_inner-it], z
|
924
953
|
end
|
925
954
|
|
926
955
|
def test_setup_teardown_behavior
|
@@ -951,9 +980,9 @@ class TestMeta < MetaMetaMetaTestCase
|
|
951
980
|
].sort
|
952
981
|
|
953
982
|
assert_equal test_methods, [x1, x2]
|
954
|
-
|
955
|
-
|
956
|
-
|
983
|
+
assert_defined_methods test_methods, x
|
984
|
+
assert_defined_methods [], y
|
985
|
+
assert_defined_methods [], z
|
957
986
|
end
|
958
987
|
|
959
988
|
def test_structure_subclasses
|
@@ -1039,3 +1068,38 @@ class ValueMonadTest < Minitest::Test
|
|
1039
1068
|
assert_equal "c", struct.expect
|
1040
1069
|
end
|
1041
1070
|
end
|
1071
|
+
|
1072
|
+
describe Minitest::Spec, :infect_an_assertion do
|
1073
|
+
class << self
|
1074
|
+
attr_accessor :infect_mock
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
def assert_infects exp, act, msg = nil, foo: nil, bar: nil
|
1078
|
+
self.class.infect_mock.assert_infects exp, act, msg, foo: foo, bar: bar
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
infect_an_assertion :assert_infects, :must_infect
|
1082
|
+
infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
|
1083
|
+
|
1084
|
+
it "infects assertions with kwargs" do
|
1085
|
+
mock = Minitest::Mock.new
|
1086
|
+
mock.expect :assert_infects, true, [:exp, :act, nil], foo: :foo, bar: :bar
|
1087
|
+
|
1088
|
+
self.class.infect_mock = mock
|
1089
|
+
|
1090
|
+
_(:act).must_infect :exp, foo: :foo, bar: :bar
|
1091
|
+
|
1092
|
+
assert_mock mock
|
1093
|
+
end
|
1094
|
+
|
1095
|
+
it "infects assertions with kwargs (dont_flip)" do
|
1096
|
+
mock = Minitest::Mock.new
|
1097
|
+
mock.expect :assert_infects, true, [:act, :exp, nil], foo: :foo, bar: :bar
|
1098
|
+
|
1099
|
+
self.class.infect_mock = mock
|
1100
|
+
|
1101
|
+
_(:act).must_infect_without_flipping :exp, foo: :foo, bar: :bar
|
1102
|
+
|
1103
|
+
assert_mock mock
|
1104
|
+
end
|
1105
|
+
end
|