minitest 5.5.1 → 5.6.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.tar.gz.sig +0 -0
- data/{History.txt → History.rdoc} +25 -3
- data/Manifest.txt +2 -2
- data/{README.txt → README.rdoc} +49 -18
- data/Rakefile +10 -9
- data/lib/minitest.rb +15 -10
- data/lib/minitest/assertions.rb +22 -23
- data/lib/minitest/benchmark.rb +14 -15
- data/lib/minitest/expectations.rb +31 -4
- data/lib/minitest/mock.rb +24 -20
- data/lib/minitest/parallel.rb +14 -4
- data/lib/minitest/pride_plugin.rb +2 -2
- data/lib/minitest/spec.rb +25 -20
- data/lib/minitest/test.rb +8 -10
- data/test/minitest/metametameta.rb +10 -10
- data/test/minitest/test_minitest_benchmark.rb +3 -3
- data/test/minitest/test_minitest_mock.rb +11 -13
- data/test/minitest/test_minitest_spec.rb +48 -26
- data/test/minitest/test_minitest_unit.rb +59 -59
- metadata +9 -14
- metadata.gz.sig +0 -0
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "tempfile"
|
2
|
+
require "stringio"
|
3
|
+
require "minitest/autorun"
|
4
4
|
|
5
5
|
class Minitest::Test
|
6
6
|
def clean s
|
7
|
-
s.gsub(/^ {6}/,
|
7
|
+
s.gsub(/^ {6}/, "")
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -55,17 +55,17 @@ class MetaMetaMetaTestCase < Minitest::Test
|
|
55
55
|
|
56
56
|
def normalize_output output
|
57
57
|
output.sub!(/Finished in .*/, "Finished in 0.00")
|
58
|
-
output.sub!(/Loaded suite .*/,
|
58
|
+
output.sub!(/Loaded suite .*/, "Loaded suite blah")
|
59
59
|
|
60
|
-
output.gsub!(/ = \d+.\d\d s = /,
|
61
|
-
output.gsub!(/0x[A-Fa-f0-9]+/,
|
62
|
-
output.gsub!(/ +$/,
|
60
|
+
output.gsub!(/ = \d+.\d\d s = /, " = 0.00 s = ")
|
61
|
+
output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
|
62
|
+
output.gsub!(/ +$/, "")
|
63
63
|
|
64
64
|
if windows? then
|
65
|
-
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/,
|
65
|
+
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, "[FILE:LINE]")
|
66
66
|
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
|
67
67
|
else
|
68
|
-
output.gsub!(/\[[^\]:]+:\d+\]/,
|
68
|
+
output.gsub!(/\[[^\]:]+:\d+\]/, "[FILE:LINE]")
|
69
69
|
output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
|
70
70
|
end
|
71
71
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/benchmark"
|
3
3
|
|
4
4
|
##
|
5
5
|
# Used to verify data:
|
@@ -111,7 +111,7 @@ class TestMinitestBenchmark < Minitest::Test
|
|
111
111
|
|
112
112
|
# income to % of households below income amount
|
113
113
|
# http://library.wolfram.com/infocenter/Conferences/6461/PowerLaws.nb
|
114
|
-
x = [
|
114
|
+
x = [15_000, 25_000, 35_000, 50_000, 75_000, 100_000]
|
115
115
|
y = [0.154, 0.283, 0.402, 0.55, 0.733, 0.843]
|
116
116
|
|
117
117
|
# verified in numbers
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "minitest/autorun"
|
2
2
|
|
3
3
|
class TestMinitestMock < Minitest::Test
|
4
4
|
parallelize_me!
|
@@ -141,7 +141,7 @@ class TestMinitestMock < Minitest::Test
|
|
141
141
|
def test_respond_appropriately
|
142
142
|
assert @mock.respond_to?(:foo)
|
143
143
|
assert @mock.respond_to?(:foo, true)
|
144
|
-
assert @mock.respond_to?(
|
144
|
+
assert @mock.respond_to?("foo")
|
145
145
|
assert !@mock.respond_to?(:bar)
|
146
146
|
end
|
147
147
|
|
@@ -252,12 +252,10 @@ class TestMinitestMock < Minitest::Test
|
|
252
252
|
end
|
253
253
|
|
254
254
|
def test_mock_block_is_passed_function_params
|
255
|
-
arg1, arg2, arg3 = :bar, [1,2,3], {:a =>
|
255
|
+
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
256
256
|
mock = Minitest::Mock.new
|
257
257
|
mock.expect :foo, nil do |a1, a2, a3|
|
258
|
-
a1 == arg1 &&
|
259
|
-
a2 == arg2 &&
|
260
|
-
a3 == arg3
|
258
|
+
a1 == arg1 && a2 == arg2 && a3 == arg3
|
261
259
|
end
|
262
260
|
|
263
261
|
mock.foo arg1, arg2, arg3
|
@@ -267,12 +265,12 @@ class TestMinitestMock < Minitest::Test
|
|
267
265
|
|
268
266
|
def test_mock_block_is_passed_function_block
|
269
267
|
mock = Minitest::Mock.new
|
270
|
-
block = proc {
|
268
|
+
block = proc { "bar" }
|
271
269
|
mock.expect :foo, nil do |arg, &blk|
|
272
|
-
arg ==
|
270
|
+
arg == "foo" &&
|
273
271
|
blk == block
|
274
272
|
end
|
275
|
-
mock.foo
|
273
|
+
mock.foo "foo", &block
|
276
274
|
assert mock.verify
|
277
275
|
end
|
278
276
|
|
@@ -339,7 +337,7 @@ class TestMinitestMock < Minitest::Test
|
|
339
337
|
|
340
338
|
def test_mock_called_via_send_with_args
|
341
339
|
mock = Minitest::Mock.new
|
342
|
-
mock.expect(:foo, true, [1,2,3])
|
340
|
+
mock.expect(:foo, true, [1, 2, 3])
|
343
341
|
|
344
342
|
mock.send(:foo, 1, 2, 3)
|
345
343
|
mock.verify
|
@@ -356,7 +354,7 @@ class TestMinitestStub < Minitest::Test
|
|
356
354
|
super
|
357
355
|
Minitest::Test.reset
|
358
356
|
|
359
|
-
@tc = Minitest::Test.new
|
357
|
+
@tc = Minitest::Test.new "fake tc"
|
360
358
|
@assertion_count = 1
|
361
359
|
end
|
362
360
|
|
@@ -400,12 +398,12 @@ class TestMinitestStub < Minitest::Test
|
|
400
398
|
|
401
399
|
fail_clapper = Class.new do
|
402
400
|
def fail_clap
|
403
|
-
|
401
|
+
raise
|
404
402
|
:clap
|
405
403
|
end
|
406
404
|
end.new
|
407
405
|
|
408
|
-
fail_clapper.stub :
|
406
|
+
fail_clapper.stub :raise, nil do |safe_clapper|
|
409
407
|
@tc.assert_equal :clap, safe_clapper.fail_clap # either form works
|
410
408
|
@tc.assert_equal :clap, fail_clapper.fail_clap # yay closures
|
411
409
|
end
|
@@ -32,7 +32,7 @@ describe Minitest::Spec do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
after do
|
35
|
-
self.assertions.must_equal @assertion_count if passed? and not skipped?
|
35
|
+
_(self.assertions).must_equal @assertion_count if passed? and not skipped?
|
36
36
|
end
|
37
37
|
|
38
38
|
it "needs to be able to catch a Minitest::Assertion exception" do
|
@@ -112,11 +112,11 @@ describe Minitest::Spec do
|
|
112
112
|
@assertion_count = 2
|
113
113
|
|
114
114
|
methods = Object.public_instance_methods.find_all { |n| n =~ /^must|^wont/ }
|
115
|
-
methods.map!
|
115
|
+
methods.map!(&:to_s) if Symbol === methods.first
|
116
116
|
|
117
117
|
musts, wonts = methods.sort.partition { |m| m =~ /^must/ }
|
118
118
|
|
119
|
-
expected_musts = %w
|
119
|
+
expected_musts = %w[must_be
|
120
120
|
must_be_close_to
|
121
121
|
must_be_empty
|
122
122
|
must_be_instance_of
|
@@ -132,7 +132,7 @@ describe Minitest::Spec do
|
|
132
132
|
must_output
|
133
133
|
must_raise
|
134
134
|
must_respond_to
|
135
|
-
must_throw
|
135
|
+
must_throw]
|
136
136
|
|
137
137
|
bad = %w[not raise throw send output be_silent]
|
138
138
|
|
@@ -442,6 +442,30 @@ describe Minitest::Spec do
|
|
442
442
|
end
|
443
443
|
end
|
444
444
|
|
445
|
+
describe "expect" do
|
446
|
+
before do
|
447
|
+
@assertion_count -= 3
|
448
|
+
end
|
449
|
+
|
450
|
+
it "can use expect" do
|
451
|
+
_(1 + 1).must_equal 2
|
452
|
+
end
|
453
|
+
|
454
|
+
it "can use expect with a lambda" do
|
455
|
+
_ { raise "blah" }.must_raise RuntimeError
|
456
|
+
end
|
457
|
+
|
458
|
+
it "can use expect in a thread" do
|
459
|
+
Thread.new { _(1 + 1).must_equal 2 }.join
|
460
|
+
end
|
461
|
+
|
462
|
+
it "can NOT use must_equal in a thread. It must use expect in a thread" do
|
463
|
+
assert_raises NoMethodError do
|
464
|
+
Thread.new { (1 + 1).must_equal 2 }.join
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
445
469
|
it "needs to verify throw" do
|
446
470
|
@assertion_count += 2 # 2 extra tests
|
447
471
|
|
@@ -519,7 +543,6 @@ describe Minitest::Spec do
|
|
519
543
|
42.must_respond_to :clear, "msg"
|
520
544
|
end
|
521
545
|
end
|
522
|
-
|
523
546
|
end
|
524
547
|
|
525
548
|
describe Minitest::Spec, :let do
|
@@ -556,7 +579,7 @@ describe Minitest::Spec, :let do
|
|
556
579
|
proc { self.class.let(:test_value) { true } }.must_raise ArgumentError
|
557
580
|
end
|
558
581
|
|
559
|
-
it
|
582
|
+
it "raises an error if the name shadows a normal instance method" do
|
560
583
|
proc { self.class.let(:message) { true } }.must_raise ArgumentError
|
561
584
|
end
|
562
585
|
|
@@ -572,8 +595,8 @@ describe Minitest::Spec, :let do
|
|
572
595
|
end.call.must_equal :good
|
573
596
|
end
|
574
597
|
|
575
|
-
it
|
576
|
-
p = proc{ }
|
598
|
+
it "procs come after dont_flip" do
|
599
|
+
p = proc { }
|
577
600
|
assert_respond_to p, :call
|
578
601
|
p.must_respond_to :call
|
579
602
|
end
|
@@ -599,7 +622,7 @@ class TestMetaStatic < Minitest::Test
|
|
599
622
|
def test_children
|
600
623
|
Minitest::Spec.children.clear # prevents parallel run
|
601
624
|
|
602
|
-
|
625
|
+
y = z = nil
|
603
626
|
x = describe "top-level thingy" do
|
604
627
|
y = describe "first thingy" do end
|
605
628
|
|
@@ -617,7 +640,7 @@ class TestMetaStatic < Minitest::Test
|
|
617
640
|
def test_it_wont_remove_existing_child_test_methods
|
618
641
|
Minitest::Spec.children.clear # prevents parallel run
|
619
642
|
|
620
|
-
|
643
|
+
inner = nil
|
621
644
|
outer = describe "outer" do
|
622
645
|
inner = describe "inner" do
|
623
646
|
it do
|
@@ -636,7 +659,7 @@ class TestMetaStatic < Minitest::Test
|
|
636
659
|
def test_it_wont_add_test_methods_to_children
|
637
660
|
Minitest::Spec.children.clear # prevents parallel run
|
638
661
|
|
639
|
-
|
662
|
+
inner = nil
|
640
663
|
outer = describe "outer" do
|
641
664
|
inner = describe "inner" do end
|
642
665
|
it do
|
@@ -655,7 +678,7 @@ class TestMeta < MetaMetaMetaTestCase
|
|
655
678
|
parallelize_me!
|
656
679
|
|
657
680
|
def util_structure
|
658
|
-
|
681
|
+
y = z = nil
|
659
682
|
before_list = []
|
660
683
|
after_list = []
|
661
684
|
x = describe "top-level thingy" do
|
@@ -674,8 +697,8 @@ class TestMeta < MetaMetaMetaTestCase
|
|
674
697
|
after { after_list << 3 }
|
675
698
|
it "inner-it" do end
|
676
699
|
|
677
|
-
it {} # ignore me
|
678
|
-
specify {} # anonymous it
|
700
|
+
it { } # ignore me
|
701
|
+
specify { } # anonymous it
|
679
702
|
end
|
680
703
|
end
|
681
704
|
end
|
@@ -690,7 +713,7 @@ class TestMeta < MetaMetaMetaTestCase
|
|
690
713
|
|
691
714
|
Minitest::Spec.register_spec_type(/woot/, TestMeta)
|
692
715
|
|
693
|
-
p = lambda do |
|
716
|
+
p = lambda do |_| true end
|
694
717
|
Minitest::Spec.register_spec_type TestMeta, &p
|
695
718
|
|
696
719
|
keys = Minitest::Spec::TYPES.map(&:first)
|
@@ -708,7 +731,7 @@ class TestMeta < MetaMetaMetaTestCase
|
|
708
731
|
Minitest::Spec.register_spec_type MiniSpecB do |desc|
|
709
732
|
desc.superclass == ExampleA
|
710
733
|
end
|
711
|
-
Minitest::Spec.register_spec_type MiniSpecC do |
|
734
|
+
Minitest::Spec.register_spec_type MiniSpecC do |_desc, *addl|
|
712
735
|
addl.include? :woot
|
713
736
|
end
|
714
737
|
|
@@ -770,10 +793,10 @@ class TestMeta < MetaMetaMetaTestCase
|
|
770
793
|
assert_equal "inner thingy", y.desc
|
771
794
|
assert_equal "very inner thingy", z.desc
|
772
795
|
|
773
|
-
top_methods = %w
|
774
|
-
inner_methods1 = %w
|
796
|
+
top_methods = %w[setup teardown test_0001_top-level-it]
|
797
|
+
inner_methods1 = %w[setup teardown test_0001_inner-it]
|
775
798
|
inner_methods2 = inner_methods1 +
|
776
|
-
%w
|
799
|
+
%w[test_0002_anonymous test_0003_anonymous]
|
777
800
|
|
778
801
|
assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
|
779
802
|
assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
|
@@ -794,8 +817,8 @@ class TestMeta < MetaMetaMetaTestCase
|
|
794
817
|
it "inner-it" do end
|
795
818
|
end
|
796
819
|
|
797
|
-
assert_equal %w
|
798
|
-
assert_equal %w
|
820
|
+
assert_equal %w[test_0001_inner-it], y.instance_methods(false).map(&:to_s)
|
821
|
+
assert_equal %w[test_0001_inner-it], z.instance_methods(false).map(&:to_s)
|
799
822
|
end
|
800
823
|
|
801
824
|
def test_setup_teardown_behavior
|
@@ -811,7 +834,7 @@ class TestMeta < MetaMetaMetaTestCase
|
|
811
834
|
end
|
812
835
|
|
813
836
|
def test_describe_first_structure
|
814
|
-
|
837
|
+
x1 = x2 = y = z = nil
|
815
838
|
x = describe "top-level thingy" do
|
816
839
|
y = describe "first thingy" do end
|
817
840
|
|
@@ -822,12 +845,11 @@ class TestMeta < MetaMetaMetaTestCase
|
|
822
845
|
end
|
823
846
|
|
824
847
|
test_methods = ["test_0001_top level it",
|
825
|
-
"test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world"
|
848
|
+
"test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
|
826
849
|
].sort
|
827
850
|
|
828
851
|
assert_equal test_methods, [x1, x2]
|
829
|
-
assert_equal test_methods,
|
830
|
-
x.instance_methods.grep(/^test/).map {|o| o.to_s}.sort
|
852
|
+
assert_equal test_methods, x.instance_methods.grep(/^test/).map(&:to_s).sort
|
831
853
|
assert_equal [], y.instance_methods.grep(/^test/)
|
832
854
|
assert_equal [], z.instance_methods.grep(/^test/)
|
833
855
|
end
|
@@ -838,7 +860,7 @@ class TestMeta < MetaMetaMetaTestCase
|
|
838
860
|
def xyz; end
|
839
861
|
end
|
840
862
|
y = Class.new x do
|
841
|
-
z = describe("inner") {}
|
863
|
+
z = describe("inner") { }
|
842
864
|
end
|
843
865
|
|
844
866
|
assert_respond_to x.new(nil), "xyz"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "pathname"
|
2
|
+
require "minitest/metametameta"
|
3
3
|
|
4
4
|
module MyModule; end
|
5
5
|
class AnError < StandardError; include MyModule; end
|
@@ -9,7 +9,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
9
9
|
parallelize_me!
|
10
10
|
|
11
11
|
pwd = Pathname.new File.expand_path Dir.pwd
|
12
|
-
basedir = Pathname.new(File.expand_path "lib/minitest") +
|
12
|
+
basedir = Pathname.new(File.expand_path "lib/minitest") + "mini"
|
13
13
|
basedir = basedir.relative_path_from(pwd).to_s
|
14
14
|
MINITEST_BASE_DIR = basedir[/\A\./] ? basedir : "./#{basedir}"
|
15
15
|
BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in `each'",
|
@@ -32,7 +32,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
32
32
|
"test/test_autotest.rb:62:in `test_add_exception'"]
|
33
33
|
ex = util_expand_bt ex
|
34
34
|
|
35
|
-
fu = Minitest
|
35
|
+
fu = Minitest.filter_backtrace(bt)
|
36
36
|
|
37
37
|
assert_equal ex, fu
|
38
38
|
end
|
@@ -42,7 +42,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
42
42
|
BT_MIDDLE +
|
43
43
|
["#{MINITEST_BASE_DIR}/test.rb:29"])
|
44
44
|
ex = bt.clone
|
45
|
-
fu = Minitest
|
45
|
+
fu = Minitest.filter_backtrace(bt)
|
46
46
|
assert_equal ex, fu
|
47
47
|
end
|
48
48
|
|
@@ -55,7 +55,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
55
55
|
bt = util_expand_bt bt
|
56
56
|
|
57
57
|
ex = ["-e:1"]
|
58
|
-
fu = Minitest
|
58
|
+
fu = Minitest.filter_backtrace bt
|
59
59
|
assert_equal ex, fu
|
60
60
|
end
|
61
61
|
|
@@ -99,7 +99,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def util_expand_bt bt
|
102
|
-
if RUBY_VERSION >=
|
102
|
+
if RUBY_VERSION >= "1.9.0" then
|
103
103
|
bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
|
104
104
|
else
|
105
105
|
bt
|
@@ -110,7 +110,7 @@ end
|
|
110
110
|
class TestMinitestUnitInherited < MetaMetaMetaTestCase
|
111
111
|
def with_overridden_include
|
112
112
|
Class.class_eval do
|
113
|
-
def inherited_with_hacks
|
113
|
+
def inherited_with_hacks _klass
|
114
114
|
throw :inherited_hook
|
115
115
|
end
|
116
116
|
|
@@ -455,7 +455,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
455
455
|
assert_report expected
|
456
456
|
end
|
457
457
|
|
458
|
-
require
|
458
|
+
require "monitor"
|
459
459
|
|
460
460
|
class Latch
|
461
461
|
def initialize count = 1
|
@@ -675,7 +675,7 @@ class TestMinitestRunnable < Minitest::Test
|
|
675
675
|
def test_marshal
|
676
676
|
setup_marshal Minitest::Runnable
|
677
677
|
|
678
|
-
assert_marshal %w
|
678
|
+
assert_marshal %w[@NAME @assertions @failures]
|
679
679
|
end
|
680
680
|
end
|
681
681
|
|
@@ -685,7 +685,7 @@ class TestMinitestTest < TestMinitestRunnable
|
|
685
685
|
tc.time = 3.14
|
686
686
|
end
|
687
687
|
|
688
|
-
assert_marshal %w
|
688
|
+
assert_marshal %w[@NAME @assertions @failures @time] do |new_tc|
|
689
689
|
assert_in_epsilon 3.14, new_tc.time
|
690
690
|
end
|
691
691
|
end
|
@@ -696,14 +696,14 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
696
696
|
# which is not threadsafe. Nearly every method in here is an
|
697
697
|
# assertion test so it isn't worth splitting it out further.
|
698
698
|
|
699
|
-
RUBY18 = !
|
699
|
+
RUBY18 = !defined? Encoding
|
700
700
|
|
701
701
|
def setup
|
702
702
|
super
|
703
703
|
|
704
704
|
Minitest::Test.reset
|
705
705
|
|
706
|
-
@tc = Minitest::Test.new
|
706
|
+
@tc = Minitest::Test.new "fake tc"
|
707
707
|
@zomg = "zomg ponies!"
|
708
708
|
@assertion_count = 1
|
709
709
|
end
|
@@ -851,7 +851,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
851
851
|
util_assert_triggered msg do
|
852
852
|
o1 = "blah" * 10
|
853
853
|
o2 = "blah" * 10
|
854
|
-
def o1.==
|
854
|
+
def o1.== _
|
855
855
|
false
|
856
856
|
end
|
857
857
|
@tc.assert_equal o1, o2
|
@@ -917,18 +917,18 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
917
917
|
def test_assert_in_epsilon
|
918
918
|
@assertion_count = 10
|
919
919
|
|
920
|
-
@tc.assert_in_epsilon
|
921
|
-
@tc.assert_in_epsilon 9991,
|
920
|
+
@tc.assert_in_epsilon 10_000, 9991
|
921
|
+
@tc.assert_in_epsilon 9991, 10_000
|
922
922
|
@tc.assert_in_epsilon 1.0, 1.001
|
923
923
|
@tc.assert_in_epsilon 1.001, 1.0
|
924
924
|
|
925
|
-
@tc.assert_in_epsilon
|
926
|
-
@tc.assert_in_epsilon 9999.1,
|
925
|
+
@tc.assert_in_epsilon 10_000, 9999.1, 0.0001
|
926
|
+
@tc.assert_in_epsilon 9999.1, 10_000, 0.0001
|
927
927
|
@tc.assert_in_epsilon 1.0, 1.0001, 0.0001
|
928
928
|
@tc.assert_in_epsilon 1.0001, 1.0, 0.0001
|
929
929
|
|
930
930
|
@tc.assert_in_epsilon(-1, -1)
|
931
|
-
@tc.assert_in_epsilon(-
|
931
|
+
@tc.assert_in_epsilon(-10_000, -9991)
|
932
932
|
end
|
933
933
|
|
934
934
|
def test_epsilon_consistency
|
@@ -943,8 +943,8 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
943
943
|
end
|
944
944
|
|
945
945
|
def test_assert_in_epsilon_triggered
|
946
|
-
util_assert_triggered
|
947
|
-
@tc.assert_in_epsilon
|
946
|
+
util_assert_triggered "Expected |10000 - 9990| (10) to be <= 9.99." do
|
947
|
+
@tc.assert_in_epsilon 10_000, 9990
|
948
948
|
end
|
949
949
|
end
|
950
950
|
|
@@ -1002,7 +1002,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1002
1002
|
@assertion_count = 2
|
1003
1003
|
|
1004
1004
|
pattern = Object.new
|
1005
|
-
def pattern.=~(
|
1005
|
+
def pattern.=~(_) true end
|
1006
1006
|
|
1007
1007
|
@tc.assert_match pattern, 5
|
1008
1008
|
end
|
@@ -1020,10 +1020,10 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1020
1020
|
@assertion_count = 2
|
1021
1021
|
|
1022
1022
|
pattern = Object.new
|
1023
|
-
def pattern.=~(
|
1023
|
+
def pattern.=~(_) false end
|
1024
1024
|
def pattern.inspect; "[Object]" end
|
1025
1025
|
|
1026
|
-
util_assert_triggered
|
1026
|
+
util_assert_triggered "Expected [Object] to match 5." do
|
1027
1027
|
@tc.assert_match pattern, 5
|
1028
1028
|
end
|
1029
1029
|
end
|
@@ -1040,7 +1040,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1040
1040
|
end
|
1041
1041
|
|
1042
1042
|
def test_assert_nil_triggered
|
1043
|
-
util_assert_triggered
|
1043
|
+
util_assert_triggered "Expected 42 to be nil." do
|
1044
1044
|
@tc.assert_nil 42
|
1045
1045
|
end
|
1046
1046
|
end
|
@@ -1051,7 +1051,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1051
1051
|
|
1052
1052
|
def test_assert_operator_bad_object
|
1053
1053
|
bad = Object.new
|
1054
|
-
def bad.==(
|
1054
|
+
def bad.==(_) true end
|
1055
1055
|
|
1056
1056
|
@tc.assert_operator bad, :equal?, bad
|
1057
1057
|
end
|
@@ -1183,8 +1183,8 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1183
1183
|
---------------
|
1184
1184
|
EOM
|
1185
1185
|
|
1186
|
-
actual = e.message.gsub(/^.+:\d+/,
|
1187
|
-
actual.gsub!(/block \(\d+ levels\) in /,
|
1186
|
+
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1187
|
+
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1188
1188
|
|
1189
1189
|
assert_equal expected, actual
|
1190
1190
|
end
|
@@ -1206,8 +1206,8 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1206
1206
|
---------------
|
1207
1207
|
EOM
|
1208
1208
|
|
1209
|
-
actual = e.message.gsub(/^.+:\d+/,
|
1210
|
-
actual.gsub!(/block \(\d+ levels\) in /,
|
1209
|
+
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1210
|
+
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1211
1211
|
|
1212
1212
|
assert_equal expected.chomp, actual
|
1213
1213
|
end
|
@@ -1252,8 +1252,8 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1252
1252
|
---------------
|
1253
1253
|
EOM
|
1254
1254
|
|
1255
|
-
actual = e.message.gsub(/^.+:\d+/,
|
1256
|
-
actual.gsub!(/block \(\d+ levels\) in /,
|
1255
|
+
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1256
|
+
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1257
1257
|
|
1258
1258
|
assert_equal expected, actual
|
1259
1259
|
end
|
@@ -1280,7 +1280,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1280
1280
|
def test_assert_same_triggered
|
1281
1281
|
@assertion_count = 2
|
1282
1282
|
|
1283
|
-
util_assert_triggered
|
1283
|
+
util_assert_triggered "Expected 2 (oid=N) to be the same as 1 (oid=N)." do
|
1284
1284
|
@tc.assert_same 1, 2
|
1285
1285
|
end
|
1286
1286
|
|
@@ -1335,7 +1335,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1335
1335
|
end
|
1336
1336
|
|
1337
1337
|
def test_assert_throws_different
|
1338
|
-
util_assert_triggered
|
1338
|
+
util_assert_triggered "Expected :blah to have been thrown, not :not_blah." do
|
1339
1339
|
@tc.assert_throws :blah do
|
1340
1340
|
throw :not_blah
|
1341
1341
|
end
|
@@ -1343,7 +1343,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1343
1343
|
end
|
1344
1344
|
|
1345
1345
|
def test_assert_throws_unthrown
|
1346
|
-
util_assert_triggered
|
1346
|
+
util_assert_triggered "Expected :blah to have been thrown." do
|
1347
1347
|
@tc.assert_throws :blah do
|
1348
1348
|
# do nothing
|
1349
1349
|
end
|
@@ -1355,8 +1355,8 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1355
1355
|
|
1356
1356
|
non_verbose do
|
1357
1357
|
out, err = capture_io do
|
1358
|
-
puts
|
1359
|
-
$stderr.puts
|
1358
|
+
puts "hi"
|
1359
|
+
$stderr.puts "bye!"
|
1360
1360
|
end
|
1361
1361
|
|
1362
1362
|
assert_equal "hi\n", out
|
@@ -1369,12 +1369,12 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1369
1369
|
|
1370
1370
|
non_verbose do
|
1371
1371
|
out, err = capture_subprocess_io do
|
1372
|
-
system("echo
|
1373
|
-
system("echo
|
1372
|
+
system("echo hi")
|
1373
|
+
system("echo bye! 1>&2")
|
1374
1374
|
end
|
1375
1375
|
|
1376
1376
|
assert_equal "hi\n", out
|
1377
|
-
assert_equal "bye
|
1377
|
+
assert_equal "bye!", err.strip
|
1378
1378
|
end
|
1379
1379
|
end
|
1380
1380
|
|
@@ -1382,7 +1382,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1382
1382
|
@assertion_count = 0
|
1383
1383
|
|
1384
1384
|
methods = Minitest::Assertions.public_instance_methods
|
1385
|
-
methods.map!
|
1385
|
+
methods.map!(&:to_s) if Symbol === methods.first
|
1386
1386
|
|
1387
1387
|
# These don't have corresponding refutes _on purpose_. They're
|
1388
1388
|
# useless and will never be added, so don't bother.
|
@@ -1397,12 +1397,12 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1397
1397
|
asserts = methods.grep(/^assert/).sort - ignores
|
1398
1398
|
refutes = methods.grep(/^refute/).sort - ignores
|
1399
1399
|
|
1400
|
-
assert_empty refutes.map { |n| n.sub(/^refute/,
|
1401
|
-
assert_empty asserts.map { |n| n.sub(/^assert/,
|
1400
|
+
assert_empty refutes.map { |n| n.sub(/^refute/, "assert") } - asserts
|
1401
|
+
assert_empty asserts.map { |n| n.sub(/^assert/, "refute") } - refutes
|
1402
1402
|
end
|
1403
1403
|
|
1404
1404
|
def test_flunk
|
1405
|
-
util_assert_triggered
|
1405
|
+
util_assert_triggered "Epic Fail!" do
|
1406
1406
|
@tc.flunk
|
1407
1407
|
end
|
1408
1408
|
end
|
@@ -1458,7 +1458,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1458
1458
|
|
1459
1459
|
def test_prints
|
1460
1460
|
printer = Class.new { extend Minitest::Assertions }
|
1461
|
-
@tc.assert_equal '"test"', printer.mu_pp(ImmutableString.new
|
1461
|
+
@tc.assert_equal '"test"', printer.mu_pp(ImmutableString.new "test")
|
1462
1462
|
end
|
1463
1463
|
|
1464
1464
|
def test_refute
|
@@ -1503,13 +1503,13 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1503
1503
|
end
|
1504
1504
|
|
1505
1505
|
def test_refute_in_epsilon
|
1506
|
-
@tc.refute_in_epsilon
|
1506
|
+
@tc.refute_in_epsilon 10_000, 9990-1
|
1507
1507
|
end
|
1508
1508
|
|
1509
1509
|
def test_refute_in_epsilon_triggered
|
1510
|
-
util_assert_triggered
|
1511
|
-
@tc.refute_in_epsilon
|
1512
|
-
|
1510
|
+
util_assert_triggered "Expected |10000 - 9990| (10) to not be <= 10.0." do
|
1511
|
+
@tc.refute_in_epsilon 10_000, 9990
|
1512
|
+
flunk
|
1513
1513
|
end
|
1514
1514
|
end
|
1515
1515
|
|
@@ -1564,10 +1564,10 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1564
1564
|
@assertion_count = 2
|
1565
1565
|
|
1566
1566
|
pattern = Object.new
|
1567
|
-
def pattern.=~(
|
1567
|
+
def pattern.=~(_) true end
|
1568
1568
|
def pattern.inspect; "[Object]" end
|
1569
1569
|
|
1570
|
-
util_assert_triggered
|
1570
|
+
util_assert_triggered "Expected [Object] to not match 5." do
|
1571
1571
|
@tc.refute_match pattern, 5
|
1572
1572
|
end
|
1573
1573
|
end
|
@@ -1584,7 +1584,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1584
1584
|
end
|
1585
1585
|
|
1586
1586
|
def test_refute_nil_triggered
|
1587
|
-
util_assert_triggered
|
1587
|
+
util_assert_triggered "Expected nil to not be nil." do
|
1588
1588
|
@tc.refute_nil nil
|
1589
1589
|
end
|
1590
1590
|
end
|
@@ -1605,7 +1605,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1605
1605
|
|
1606
1606
|
def test_refute_operator_bad_object
|
1607
1607
|
bad = Object.new
|
1608
|
-
def bad.==(
|
1608
|
+
def bad.==(_) true end
|
1609
1609
|
|
1610
1610
|
@tc.refute_operator true, :equal?, bad
|
1611
1611
|
end
|
@@ -1631,7 +1631,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1631
1631
|
end
|
1632
1632
|
|
1633
1633
|
def test_refute_same_triggered
|
1634
|
-
util_assert_triggered
|
1634
|
+
util_assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
1635
1635
|
@tc.refute_same 1, 1
|
1636
1636
|
end
|
1637
1637
|
end
|
@@ -1657,9 +1657,9 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1657
1657
|
srand 42
|
1658
1658
|
expected = case
|
1659
1659
|
when maglev? then
|
1660
|
-
%w
|
1660
|
+
%w[test_test2 test_test3 test_test1]
|
1661
1661
|
else
|
1662
|
-
%w
|
1662
|
+
%w[test_test2 test_test1 test_test3]
|
1663
1663
|
end
|
1664
1664
|
assert_equal expected, sample_test_case.runnable_methods
|
1665
1665
|
end
|
@@ -1674,7 +1674,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1674
1674
|
def test_test1; assert "does not matter" end
|
1675
1675
|
end
|
1676
1676
|
|
1677
|
-
expected = %w
|
1677
|
+
expected = %w[test_test1 test_test2 test_test3]
|
1678
1678
|
assert_equal expected, sample_test_case.runnable_methods
|
1679
1679
|
end
|
1680
1680
|
|
@@ -1693,7 +1693,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1693
1693
|
|
1694
1694
|
shitty_test_case = Class.new Minitest::Test
|
1695
1695
|
|
1696
|
-
def shitty_test_case.test_order
|
1696
|
+
def shitty_test_case.test_order; :lol end
|
1697
1697
|
|
1698
1698
|
assert_silent do
|
1699
1699
|
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
@@ -1706,7 +1706,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1706
1706
|
end
|
1707
1707
|
|
1708
1708
|
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
1709
|
-
msg.gsub!(/\(oid=[-0-9]+\)/,
|
1709
|
+
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
|
1710
1710
|
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
1711
1711
|
|
1712
1712
|
assert_equal expected, msg
|