minitest 5.8.5 → 5.9.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.rdoc +14 -4
- data/Manifest.txt +1 -1
- data/README.rdoc +29 -26
- data/lib/hoe/minitest.rb +4 -10
- data/lib/minitest.rb +23 -2
- data/lib/minitest/assertions.rb +17 -4
- data/lib/minitest/autorun.rb +1 -0
- data/lib/minitest/benchmark.rb +1 -2
- data/lib/minitest/hell.rb +6 -0
- data/lib/minitest/mock.rb +9 -0
- data/lib/minitest/test.rb +2 -3
- data/lib/minitest/unit.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +14 -14
- data/test/minitest/{test_minitest_unit.rb → test_minitest_test.rb} +150 -65
- metadata +16 -17
- metadata.gz.sig +2 -5
@@ -26,7 +26,7 @@ class TestMinitestMock < Minitest::Test
|
|
26
26
|
@mock.foo
|
27
27
|
@mock.meaning_of_life
|
28
28
|
|
29
|
-
|
29
|
+
assert_mock @mock
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_allow_expectations_to_be_added_after_creation
|
@@ -60,7 +60,7 @@ class TestMinitestMock < Minitest::Test
|
|
60
60
|
mock.expect(:foo, retval)
|
61
61
|
mock.foo
|
62
62
|
|
63
|
-
|
63
|
+
assert_mock mock
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_mock_args_does_not_raise
|
@@ -71,7 +71,7 @@ class TestMinitestMock < Minitest::Test
|
|
71
71
|
mock.expect(:foo, nil, [arg])
|
72
72
|
mock.foo(arg)
|
73
73
|
|
74
|
-
|
74
|
+
assert_mock mock
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_set_expectation_on_special_methods
|
@@ -98,14 +98,14 @@ class TestMinitestMock < Minitest::Test
|
|
98
98
|
mock.expect :send, "received send"
|
99
99
|
assert_equal "received send", mock.send
|
100
100
|
|
101
|
-
|
101
|
+
assert_mock mock
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_expectations_can_be_satisfied_via_send
|
105
105
|
@mock.send :foo
|
106
106
|
@mock.send :meaning_of_life
|
107
107
|
|
108
|
-
|
108
|
+
assert_mock @mock
|
109
109
|
end
|
110
110
|
|
111
111
|
def test_expectations_can_be_satisfied_via_public_send
|
@@ -114,7 +114,7 @@ class TestMinitestMock < Minitest::Test
|
|
114
114
|
@mock.public_send :foo
|
115
115
|
@mock.public_send :meaning_of_life
|
116
116
|
|
117
|
-
|
117
|
+
assert_mock @mock
|
118
118
|
end
|
119
119
|
|
120
120
|
def test_blow_up_on_wrong_arguments
|
@@ -186,7 +186,7 @@ class TestMinitestMock < Minitest::Test
|
|
186
186
|
mock.expect :loose_expectation, true, [Integer]
|
187
187
|
mock.loose_expectation 1
|
188
188
|
|
189
|
-
|
189
|
+
assert_mock mock
|
190
190
|
end
|
191
191
|
|
192
192
|
def test_verify_raises_with_strict_args
|
@@ -223,7 +223,7 @@ class TestMinitestMock < Minitest::Test
|
|
223
223
|
mock.foo :bar
|
224
224
|
mock.foo :baz
|
225
225
|
|
226
|
-
|
226
|
+
assert_mock mock
|
227
227
|
end
|
228
228
|
|
229
229
|
def test_same_method_expects_blow_up_when_not_all_called
|
@@ -262,7 +262,7 @@ class TestMinitestMock < Minitest::Test
|
|
262
262
|
|
263
263
|
mock.foo
|
264
264
|
|
265
|
-
|
265
|
+
assert_mock mock
|
266
266
|
end
|
267
267
|
|
268
268
|
def test_mock_block_is_passed_function_params
|
@@ -274,7 +274,7 @@ class TestMinitestMock < Minitest::Test
|
|
274
274
|
|
275
275
|
mock.foo arg1, arg2, arg3
|
276
276
|
|
277
|
-
|
277
|
+
assert_mock mock
|
278
278
|
end
|
279
279
|
|
280
280
|
def test_mock_block_is_passed_function_block
|
@@ -285,7 +285,7 @@ class TestMinitestMock < Minitest::Test
|
|
285
285
|
blk == block
|
286
286
|
end
|
287
287
|
mock.foo "foo", &block
|
288
|
-
|
288
|
+
assert_mock mock
|
289
289
|
end
|
290
290
|
|
291
291
|
def test_verify_fails_when_mock_block_returns_false
|
@@ -338,7 +338,7 @@ class TestMinitestMock < Minitest::Test
|
|
338
338
|
mock.expect(:foo, true)
|
339
339
|
|
340
340
|
mock.send :foo
|
341
|
-
mock
|
341
|
+
assert_mock mock
|
342
342
|
end
|
343
343
|
|
344
344
|
def test_mock_called_via___send__
|
@@ -346,7 +346,7 @@ class TestMinitestMock < Minitest::Test
|
|
346
346
|
mock.expect(:foo, true)
|
347
347
|
|
348
348
|
mock.__send__ :foo
|
349
|
-
mock
|
349
|
+
assert_mock mock
|
350
350
|
end
|
351
351
|
|
352
352
|
def test_mock_called_via_send_with_args
|
@@ -354,7 +354,7 @@ class TestMinitestMock < Minitest::Test
|
|
354
354
|
mock.expect(:foo, true, [1, 2, 3])
|
355
355
|
|
356
356
|
mock.send(:foo, 1, 2, 3)
|
357
|
-
mock
|
357
|
+
assert_mock mock
|
358
358
|
end
|
359
359
|
|
360
360
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require "pathname"
|
2
4
|
require "minitest/metametameta"
|
3
5
|
|
@@ -249,7 +251,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
249
251
|
|
250
252
|
1) Failure:
|
251
253
|
#<Class:0xXXX>#test_failure [FILE:LINE]:
|
252
|
-
|
254
|
+
Expected false to be truthy.
|
253
255
|
|
254
256
|
2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
|
255
257
|
EOM
|
@@ -284,8 +286,8 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
284
286
|
assert_report expected, %w[--name /some|thing/ --seed 42]
|
285
287
|
end
|
286
288
|
|
287
|
-
def assert_filtering name, expected, a = false
|
288
|
-
args = %W[
|
289
|
+
def assert_filtering filter, name, expected, a = false
|
290
|
+
args = %W[--#{filter} #{name} --seed 42]
|
289
291
|
|
290
292
|
alpha = Class.new Minitest::Test do
|
291
293
|
define_method :test_something do
|
@@ -318,7 +320,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
318
320
|
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
|
319
321
|
EOM
|
320
322
|
|
321
|
-
assert_filtering "/Beta#test_something/", expected
|
323
|
+
assert_filtering 'name', "/Beta#test_something/", expected
|
322
324
|
end
|
323
325
|
|
324
326
|
def test_run_filtered_including_suite_name_string
|
@@ -330,7 +332,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
330
332
|
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
|
331
333
|
EOM
|
332
334
|
|
333
|
-
assert_filtering "Beta#test_something", expected
|
335
|
+
assert_filtering 'name', "Beta#test_something", expected
|
334
336
|
end
|
335
337
|
|
336
338
|
def test_run_filtered_string_method_only
|
@@ -342,7 +344,57 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
342
344
|
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
|
343
345
|
EOM
|
344
346
|
|
345
|
-
assert_filtering "test_something", expected, :pass
|
347
|
+
assert_filtering 'name', "test_something", expected, :pass
|
348
|
+
end
|
349
|
+
|
350
|
+
def test_run_failing_excluded
|
351
|
+
setup_basic_tu
|
352
|
+
|
353
|
+
expected = clean <<-EOM
|
354
|
+
.
|
355
|
+
|
356
|
+
Finished in 0.00
|
357
|
+
|
358
|
+
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
|
359
|
+
EOM
|
360
|
+
|
361
|
+
assert_report expected, %w[--exclude /failure/ --seed 42]
|
362
|
+
end
|
363
|
+
|
364
|
+
def test_run_filtered_excluding_suite_name
|
365
|
+
expected = clean <<-EOM
|
366
|
+
.
|
367
|
+
|
368
|
+
Finished in 0.00
|
369
|
+
|
370
|
+
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
|
371
|
+
EOM
|
372
|
+
|
373
|
+
assert_filtering 'exclude', "/Alpha#test_something/", expected
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_run_filtered_excluding_suite_name_string
|
377
|
+
expected = clean <<-EOM
|
378
|
+
.
|
379
|
+
|
380
|
+
Finished in 0.00
|
381
|
+
|
382
|
+
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
|
383
|
+
EOM
|
384
|
+
|
385
|
+
assert_filtering 'exclude', "Alpha#test_something", expected
|
386
|
+
end
|
387
|
+
|
388
|
+
def test_run_filtered_excluding_string_method_only
|
389
|
+
expected = clean <<-EOM
|
390
|
+
|
391
|
+
|
392
|
+
Finished in 0.00
|
393
|
+
|
394
|
+
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
|
395
|
+
EOM
|
396
|
+
|
397
|
+
assert_filtering 'exclude', "test_something", expected, :pass
|
346
398
|
end
|
347
399
|
|
348
400
|
def test_run_passing
|
@@ -431,7 +483,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
431
483
|
def self.name; "wacky!" end
|
432
484
|
|
433
485
|
def self.before_my_suite
|
434
|
-
@reporter.
|
486
|
+
@reporter.io.puts "Running #{self.name} tests"
|
435
487
|
@@foo = 1
|
436
488
|
end
|
437
489
|
|
@@ -730,13 +782,13 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
730
782
|
end
|
731
783
|
|
732
784
|
def test_assert__triggered
|
733
|
-
|
785
|
+
assert_triggered "Expected false to be truthy." do
|
734
786
|
@tc.assert false
|
735
787
|
end
|
736
788
|
end
|
737
789
|
|
738
790
|
def test_assert__triggered_message
|
739
|
-
|
791
|
+
assert_triggered @zomg do
|
740
792
|
@tc.assert false, @zomg
|
741
793
|
end
|
742
794
|
end
|
@@ -750,7 +802,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
750
802
|
def test_assert_empty_triggered
|
751
803
|
@assertion_count = 2
|
752
804
|
|
753
|
-
|
805
|
+
assert_triggered "Expected [1] to be empty." do
|
754
806
|
@tc.assert_empty [1]
|
755
807
|
end
|
756
808
|
end
|
@@ -765,7 +817,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
765
817
|
msg = "No visible difference in the Array#inspect output.
|
766
818
|
You should look at the implementation of #== on Array or its members.
|
767
819
|
[#<Object:0xXXXXXX>]".gsub(/^ +/, "")
|
768
|
-
|
820
|
+
assert_triggered msg do
|
769
821
|
@tc.assert_equal [object1], [object2]
|
770
822
|
end
|
771
823
|
end
|
@@ -778,16 +830,49 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
778
830
|
You should look at the implementation of #== on Hash or its members.
|
779
831
|
{1=>#<Object:0xXXXXXX>}".gsub(/^ +/, "")
|
780
832
|
|
781
|
-
|
833
|
+
assert_triggered msg do
|
782
834
|
@tc.assert_equal h1, h2
|
783
835
|
end
|
784
836
|
end
|
785
837
|
|
838
|
+
def test_assert_equal_string_encodings
|
839
|
+
msg = <<-EOM.gsub(/^ {10}/, "")
|
840
|
+
--- expected
|
841
|
+
+++ actual
|
842
|
+
@@ -1 +1,2 @@
|
843
|
+
+# encoding: ASCII-8BIT
|
844
|
+
"bad-utf8-\\xF1.txt"
|
845
|
+
EOM
|
846
|
+
|
847
|
+
assert_triggered msg do
|
848
|
+
x = "bad-utf8-\xF1.txt"
|
849
|
+
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
|
850
|
+
@tc.assert_equal x, y
|
851
|
+
end
|
852
|
+
end unless RUBY18
|
853
|
+
|
854
|
+
def test_assert_equal_string_encodings_both_different
|
855
|
+
msg = <<-EOM.gsub(/^ {10}/, "")
|
856
|
+
--- expected
|
857
|
+
+++ actual
|
858
|
+
@@ -1,2 +1,2 @@
|
859
|
+
-# encoding: US-ASCII
|
860
|
+
+# encoding: ASCII-8BIT
|
861
|
+
"bad-utf8-\\xF1.txt"
|
862
|
+
EOM
|
863
|
+
|
864
|
+
assert_triggered msg do
|
865
|
+
x = "bad-utf8-\xF1.txt".force_encoding "ASCII"
|
866
|
+
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
|
867
|
+
@tc.assert_equal x, y
|
868
|
+
end
|
869
|
+
end unless RUBY18
|
870
|
+
|
786
871
|
def test_assert_equal_different_diff_deactivated
|
787
872
|
skip "https://github.com/MagLev/maglev/issues/209" if maglev?
|
788
873
|
|
789
874
|
without_diff do
|
790
|
-
|
875
|
+
assert_triggered util_msg("haha" * 10, "blah" * 10) do
|
791
876
|
o1 = "haha" * 10
|
792
877
|
o2 = "blah" * 10
|
793
878
|
|
@@ -810,7 +895,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
810
895
|
+#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"b\">
|
811
896
|
".gsub(/^ +/, "")
|
812
897
|
|
813
|
-
|
898
|
+
assert_triggered msg do
|
814
899
|
@tc.assert_equal o1, o2
|
815
900
|
end
|
816
901
|
end
|
@@ -823,7 +908,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
823
908
|
You should look at the implementation of #== on Object or its members.
|
824
909
|
#<Object:0xXXXXXX>".gsub(/^ +/, "")
|
825
910
|
|
826
|
-
|
911
|
+
assert_triggered msg do
|
827
912
|
@tc.assert_equal o1, o2
|
828
913
|
end
|
829
914
|
end
|
@@ -836,7 +921,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
836
921
|
+\"blahblahblahblahblahblahblahblahblahblah\"
|
837
922
|
".gsub(/^ +/, "")
|
838
923
|
|
839
|
-
|
924
|
+
assert_triggered msg do
|
840
925
|
o1 = "haha" * 10
|
841
926
|
o2 = "blah" * 10
|
842
927
|
|
@@ -849,7 +934,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
849
934
|
You should look at the implementation of #== on String or its members.
|
850
935
|
\"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "")
|
851
936
|
|
852
|
-
|
937
|
+
assert_triggered msg do
|
853
938
|
o1 = "blah" * 10
|
854
939
|
o2 = "blah" * 10
|
855
940
|
def o1.== _
|
@@ -868,7 +953,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
868
953
|
+\"blahblahblahblahblahblahblahblahblahblah\"
|
869
954
|
".gsub(/^ +/, "")
|
870
955
|
|
871
|
-
|
956
|
+
assert_triggered msg do
|
872
957
|
o1 = "haha" * 10
|
873
958
|
o2 = "blah" * 10
|
874
959
|
@tc.assert_equal o1, o2, "message"
|
@@ -876,20 +961,20 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
876
961
|
end
|
877
962
|
|
878
963
|
def test_assert_equal_different_short
|
879
|
-
|
964
|
+
assert_triggered util_msg(1, 2) do
|
880
965
|
@tc.assert_equal 1, 2
|
881
966
|
end
|
882
967
|
end
|
883
968
|
|
884
969
|
def test_assert_equal_different_short_msg
|
885
|
-
|
970
|
+
assert_triggered util_msg(1, 2, "message") do
|
886
971
|
@tc.assert_equal 1, 2, "message"
|
887
972
|
end
|
888
973
|
end
|
889
974
|
|
890
975
|
def test_assert_equal_different_short_multiline
|
891
976
|
msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n"
|
892
|
-
|
977
|
+
assert_triggered msg do
|
893
978
|
@tc.assert_equal "a\nb", "a\nc"
|
894
979
|
end
|
895
980
|
end
|
@@ -903,14 +988,14 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
903
988
|
|
904
989
|
@tc.assert_in_delta 0, 1, 1
|
905
990
|
|
906
|
-
|
991
|
+
assert_triggered "Expected |0 - 1| (1) to not be <= 1." do
|
907
992
|
@tc.refute_in_delta 0, 1, 1
|
908
993
|
end
|
909
994
|
end
|
910
995
|
|
911
996
|
def test_assert_in_delta_triggered
|
912
997
|
x = maglev? ? "9.999999xxxe-07" : "1.0e-06"
|
913
|
-
|
998
|
+
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
|
914
999
|
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
|
915
1000
|
end
|
916
1001
|
end
|
@@ -938,13 +1023,13 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
938
1023
|
@tc.assert_in_epsilon 1.0, 1.001
|
939
1024
|
|
940
1025
|
msg = "Expected |1.0 - 1.001| (0.000999xxx) to not be <= 0.001."
|
941
|
-
|
1026
|
+
assert_triggered msg do
|
942
1027
|
@tc.refute_in_epsilon 1.0, 1.001
|
943
1028
|
end
|
944
1029
|
end
|
945
1030
|
|
946
1031
|
def test_assert_in_epsilon_triggered
|
947
|
-
|
1032
|
+
assert_triggered "Expected |10000 - 9990| (10) to be <= 9.99." do
|
948
1033
|
@tc.assert_in_epsilon 10_000, 9990
|
949
1034
|
end
|
950
1035
|
end
|
@@ -952,7 +1037,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
952
1037
|
def test_assert_in_epsilon_triggered_negative_case
|
953
1038
|
x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
|
954
1039
|
y = maglev? ? "0.100000xxx" : "0.1"
|
955
|
-
|
1040
|
+
assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
|
956
1041
|
@tc.assert_in_epsilon(-1.1, -1, 0.1)
|
957
1042
|
end
|
958
1043
|
end
|
@@ -979,7 +1064,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
979
1064
|
end
|
980
1065
|
|
981
1066
|
def test_assert_instance_of_triggered
|
982
|
-
|
1067
|
+
assert_triggered 'Expected "blah" to be an instance of Array, not String.' do
|
983
1068
|
@tc.assert_instance_of Array, "blah"
|
984
1069
|
end
|
985
1070
|
end
|
@@ -989,7 +1074,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
989
1074
|
end
|
990
1075
|
|
991
1076
|
def test_assert_kind_of_triggered
|
992
|
-
|
1077
|
+
assert_triggered 'Expected "blah" to be a kind of Array, not String.' do
|
993
1078
|
@tc.assert_kind_of Array, "blah"
|
994
1079
|
end
|
995
1080
|
end
|
@@ -1024,14 +1109,14 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1024
1109
|
def pattern.=~(_) false end
|
1025
1110
|
def pattern.inspect; "[Object]" end
|
1026
1111
|
|
1027
|
-
|
1112
|
+
assert_triggered "Expected [Object] to match 5." do
|
1028
1113
|
@tc.assert_match pattern, 5
|
1029
1114
|
end
|
1030
1115
|
end
|
1031
1116
|
|
1032
1117
|
def test_assert_match_triggered
|
1033
1118
|
@assertion_count = 2
|
1034
|
-
|
1119
|
+
assert_triggered 'Expected /\d+/ to match "blah blah blah".' do
|
1035
1120
|
@tc.assert_match(/\d+/, "blah blah blah")
|
1036
1121
|
end
|
1037
1122
|
end
|
@@ -1041,7 +1126,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1041
1126
|
end
|
1042
1127
|
|
1043
1128
|
def test_assert_nil_triggered
|
1044
|
-
|
1129
|
+
assert_triggered "Expected 42 to be nil." do
|
1045
1130
|
@tc.assert_nil 42
|
1046
1131
|
end
|
1047
1132
|
end
|
@@ -1058,7 +1143,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1058
1143
|
end
|
1059
1144
|
|
1060
1145
|
def test_assert_operator_triggered
|
1061
|
-
|
1146
|
+
assert_triggered "Expected 2 to be < 1." do
|
1062
1147
|
@tc.assert_operator 2, :<, 1
|
1063
1148
|
end
|
1064
1149
|
end
|
@@ -1102,7 +1187,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1102
1187
|
end
|
1103
1188
|
|
1104
1189
|
def test_assert_output_triggered_both
|
1105
|
-
|
1190
|
+
assert_triggered util_msg("blah", "blah blah", "In stderr") do
|
1106
1191
|
@tc.assert_output "yay", "blah" do
|
1107
1192
|
print "boo"
|
1108
1193
|
$stderr.print "blah blah"
|
@@ -1111,7 +1196,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1111
1196
|
end
|
1112
1197
|
|
1113
1198
|
def test_assert_output_triggered_err
|
1114
|
-
|
1199
|
+
assert_triggered util_msg("blah", "blah blah", "In stderr") do
|
1115
1200
|
@tc.assert_output nil, "blah" do
|
1116
1201
|
$stderr.print "blah blah"
|
1117
1202
|
end
|
@@ -1119,7 +1204,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1119
1204
|
end
|
1120
1205
|
|
1121
1206
|
def test_assert_output_triggered_out
|
1122
|
-
|
1207
|
+
assert_triggered util_msg("blah", "blah blah", "In stdout") do
|
1123
1208
|
@tc.assert_output "blah" do
|
1124
1209
|
print "blah blah"
|
1125
1210
|
end
|
@@ -1131,7 +1216,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1131
1216
|
end
|
1132
1217
|
|
1133
1218
|
def test_assert_predicate_triggered
|
1134
|
-
|
1219
|
+
assert_triggered 'Expected "blah" to be empty?.' do
|
1135
1220
|
@tc.assert_predicate "blah", :empty?
|
1136
1221
|
end
|
1137
1222
|
end
|
@@ -1185,7 +1270,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1185
1270
|
def test_assert_raises_skip
|
1186
1271
|
@assertion_count = 0
|
1187
1272
|
|
1188
|
-
|
1273
|
+
assert_triggered "skipped", Minitest::Skip do
|
1189
1274
|
@tc.assert_raises ArgumentError do
|
1190
1275
|
begin
|
1191
1276
|
raise "blah"
|
@@ -1310,7 +1395,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1310
1395
|
end
|
1311
1396
|
|
1312
1397
|
def test_assert_respond_to_triggered
|
1313
|
-
|
1398
|
+
assert_triggered 'Expected "blah" (String) to respond to #rawr!.' do
|
1314
1399
|
@tc.assert_respond_to "blah", :rawr!
|
1315
1400
|
end
|
1316
1401
|
end
|
@@ -1327,14 +1412,14 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1327
1412
|
def test_assert_same_triggered
|
1328
1413
|
@assertion_count = 2
|
1329
1414
|
|
1330
|
-
|
1415
|
+
assert_triggered "Expected 2 (oid=N) to be the same as 1 (oid=N)." do
|
1331
1416
|
@tc.assert_same 1, 2
|
1332
1417
|
end
|
1333
1418
|
|
1334
1419
|
s1 = "blah"
|
1335
1420
|
s2 = "blah"
|
1336
1421
|
|
1337
|
-
|
1422
|
+
assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
|
1338
1423
|
@tc.assert_same s1, s2
|
1339
1424
|
end
|
1340
1425
|
end
|
@@ -1344,7 +1429,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1344
1429
|
end
|
1345
1430
|
|
1346
1431
|
def test_assert_send_bad
|
1347
|
-
|
1432
|
+
assert_triggered "Expected 1.>(*[2]) to return true." do
|
1348
1433
|
@tc.assert_send [1, :>, 2]
|
1349
1434
|
end
|
1350
1435
|
end
|
@@ -1358,7 +1443,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1358
1443
|
end
|
1359
1444
|
|
1360
1445
|
def test_assert_silent_triggered_err
|
1361
|
-
|
1446
|
+
assert_triggered util_msg("", "blah blah", "In stderr") do
|
1362
1447
|
@tc.assert_silent do
|
1363
1448
|
$stderr.print "blah blah"
|
1364
1449
|
end
|
@@ -1368,7 +1453,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1368
1453
|
def test_assert_silent_triggered_out
|
1369
1454
|
@assertion_count = 2
|
1370
1455
|
|
1371
|
-
|
1456
|
+
assert_triggered util_msg("", "blah blah", "In stdout") do
|
1372
1457
|
@tc.assert_silent do
|
1373
1458
|
print "blah blah"
|
1374
1459
|
end
|
@@ -1382,7 +1467,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1382
1467
|
end
|
1383
1468
|
|
1384
1469
|
def test_assert_throws_different
|
1385
|
-
|
1470
|
+
assert_triggered "Expected :blah to have been thrown, not :not_blah." do
|
1386
1471
|
@tc.assert_throws :blah do
|
1387
1472
|
throw :not_blah
|
1388
1473
|
end
|
@@ -1390,7 +1475,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1390
1475
|
end
|
1391
1476
|
|
1392
1477
|
def test_assert_throws_unthrown
|
1393
|
-
|
1478
|
+
assert_triggered "Expected :blah to have been thrown." do
|
1394
1479
|
@tc.assert_throws :blah do
|
1395
1480
|
# do nothing
|
1396
1481
|
end
|
@@ -1434,7 +1519,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1434
1519
|
# These don't have corresponding refutes _on purpose_. They're
|
1435
1520
|
# useless and will never be added, so don't bother.
|
1436
1521
|
ignores = %w[assert_output assert_raises assert_send
|
1437
|
-
assert_silent assert_throws]
|
1522
|
+
assert_silent assert_throws assert_mock]
|
1438
1523
|
|
1439
1524
|
# These are test/unit methods. I'm not actually sure why they're still here
|
1440
1525
|
ignores += %w[assert_no_match assert_not_equal assert_not_nil
|
@@ -1449,13 +1534,13 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1449
1534
|
end
|
1450
1535
|
|
1451
1536
|
def test_flunk
|
1452
|
-
|
1537
|
+
assert_triggered "Epic Fail!" do
|
1453
1538
|
@tc.flunk
|
1454
1539
|
end
|
1455
1540
|
end
|
1456
1541
|
|
1457
1542
|
def test_flunk_message
|
1458
|
-
|
1543
|
+
assert_triggered @zomg do
|
1459
1544
|
@tc.flunk @zomg
|
1460
1545
|
end
|
1461
1546
|
end
|
@@ -1476,13 +1561,13 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1476
1561
|
end
|
1477
1562
|
|
1478
1563
|
def test_message_message
|
1479
|
-
|
1564
|
+
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1480
1565
|
@tc.assert_equal 1, 2, message { "whoops" }
|
1481
1566
|
end
|
1482
1567
|
end
|
1483
1568
|
|
1484
1569
|
def test_message_lambda
|
1485
|
-
|
1570
|
+
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1486
1571
|
@tc.assert_equal 1, 2, lambda { "whoops" }
|
1487
1572
|
end
|
1488
1573
|
end
|
@@ -1523,7 +1608,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1523
1608
|
def test_refute_empty_triggered
|
1524
1609
|
@assertion_count = 2
|
1525
1610
|
|
1526
|
-
|
1611
|
+
assert_triggered "Expected [] to not be empty." do
|
1527
1612
|
@tc.refute_empty []
|
1528
1613
|
end
|
1529
1614
|
end
|
@@ -1533,7 +1618,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1533
1618
|
end
|
1534
1619
|
|
1535
1620
|
def test_refute_equal_triggered
|
1536
|
-
|
1621
|
+
assert_triggered 'Expected "blah" to not be equal to "blah".' do
|
1537
1622
|
@tc.refute_equal "blah", "blah"
|
1538
1623
|
end
|
1539
1624
|
end
|
@@ -1544,7 +1629,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1544
1629
|
|
1545
1630
|
def test_refute_in_delta_triggered
|
1546
1631
|
x = maglev? ? "0.100000xxx" : "0.1"
|
1547
|
-
|
1632
|
+
assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
|
1548
1633
|
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
|
1549
1634
|
end
|
1550
1635
|
end
|
@@ -1554,7 +1639,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1554
1639
|
end
|
1555
1640
|
|
1556
1641
|
def test_refute_in_epsilon_triggered
|
1557
|
-
|
1642
|
+
assert_triggered "Expected |10000 - 9990| (10) to not be <= 10.0." do
|
1558
1643
|
@tc.refute_in_epsilon 10_000, 9990
|
1559
1644
|
flunk
|
1560
1645
|
end
|
@@ -1582,7 +1667,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1582
1667
|
end
|
1583
1668
|
|
1584
1669
|
def test_refute_instance_of_triggered
|
1585
|
-
|
1670
|
+
assert_triggered 'Expected "blah" to not be an instance of String.' do
|
1586
1671
|
@tc.refute_instance_of String, "blah"
|
1587
1672
|
end
|
1588
1673
|
end
|
@@ -1592,7 +1677,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1592
1677
|
end
|
1593
1678
|
|
1594
1679
|
def test_refute_kind_of_triggered
|
1595
|
-
|
1680
|
+
assert_triggered 'Expected "blah" to not be a kind of String.' do
|
1596
1681
|
@tc.refute_kind_of String, "blah"
|
1597
1682
|
end
|
1598
1683
|
end
|
@@ -1614,14 +1699,14 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1614
1699
|
def pattern.=~(_) true end
|
1615
1700
|
def pattern.inspect; "[Object]" end
|
1616
1701
|
|
1617
|
-
|
1702
|
+
assert_triggered "Expected [Object] to not match 5." do
|
1618
1703
|
@tc.refute_match pattern, 5
|
1619
1704
|
end
|
1620
1705
|
end
|
1621
1706
|
|
1622
1707
|
def test_refute_match_triggered
|
1623
1708
|
@assertion_count = 2
|
1624
|
-
|
1709
|
+
assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do
|
1625
1710
|
@tc.refute_match(/\w+/, "blah blah blah")
|
1626
1711
|
end
|
1627
1712
|
end
|
@@ -1631,7 +1716,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1631
1716
|
end
|
1632
1717
|
|
1633
1718
|
def test_refute_nil_triggered
|
1634
|
-
|
1719
|
+
assert_triggered "Expected nil to not be nil." do
|
1635
1720
|
@tc.refute_nil nil
|
1636
1721
|
end
|
1637
1722
|
end
|
@@ -1641,7 +1726,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1641
1726
|
end
|
1642
1727
|
|
1643
1728
|
def test_refute_predicate_triggered
|
1644
|
-
|
1729
|
+
assert_triggered 'Expected "" to not be empty?.' do
|
1645
1730
|
@tc.refute_predicate "", :empty?
|
1646
1731
|
end
|
1647
1732
|
end
|
@@ -1658,7 +1743,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1658
1743
|
end
|
1659
1744
|
|
1660
1745
|
def test_refute_operator_triggered
|
1661
|
-
|
1746
|
+
assert_triggered "Expected 2 to not be > 1." do
|
1662
1747
|
@tc.refute_operator 2, :>, 1
|
1663
1748
|
end
|
1664
1749
|
end
|
@@ -1668,7 +1753,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1668
1753
|
end
|
1669
1754
|
|
1670
1755
|
def test_refute_respond_to_triggered
|
1671
|
-
|
1756
|
+
assert_triggered 'Expected "blah" to not respond to empty?.' do
|
1672
1757
|
@tc.refute_respond_to "blah", :empty?
|
1673
1758
|
end
|
1674
1759
|
end
|
@@ -1678,7 +1763,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1678
1763
|
end
|
1679
1764
|
|
1680
1765
|
def test_refute_same_triggered
|
1681
|
-
|
1766
|
+
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
1682
1767
|
@tc.refute_same 1, 1
|
1683
1768
|
end
|
1684
1769
|
end
|
@@ -1686,7 +1771,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1686
1771
|
def test_skip
|
1687
1772
|
@assertion_count = 0
|
1688
1773
|
|
1689
|
-
|
1774
|
+
assert_triggered "haha!", Minitest::Skip do
|
1690
1775
|
@tc.skip "haha!"
|
1691
1776
|
end
|
1692
1777
|
end
|
@@ -1747,7 +1832,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1747
1832
|
end
|
1748
1833
|
end
|
1749
1834
|
|
1750
|
-
def
|
1835
|
+
def assert_triggered expected, klass = Minitest::Assertion
|
1751
1836
|
e = assert_raises klass do
|
1752
1837
|
yield
|
1753
1838
|
end
|