minitest 5.11.3 → 5.12.0
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.tar.gz.sig +0 -0
- data/History.rdoc +19 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +17 -3
- data/lib/minitest.rb +6 -3
- data/lib/minitest/assertions.rb +48 -15
- data/lib/minitest/spec.rb +4 -0
- data/test/minitest/metametameta.rb +3 -0
- data/test/minitest/test_minitest_assertions.rb +1389 -0
- data/test/minitest/test_minitest_mock.rb +2 -2
- data/test/minitest/test_minitest_spec.rb +164 -130
- data/test/minitest/test_minitest_test.rb +0 -1087
- metadata +23 -17
- metadata.gz.sig +0 -0
@@ -15,11 +15,6 @@ if defined? Encoding then
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
module MyModule; end
|
19
|
-
class AnError < StandardError; include MyModule; end
|
20
|
-
class ImmutableString < String; def inspect; super.freeze; end; end
|
21
|
-
SomeError = Class.new Exception
|
22
|
-
|
23
18
|
class Minitest::Runnable
|
24
19
|
def whatever # faked for testing
|
25
20
|
assert true
|
@@ -851,1060 +846,6 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
851
846
|
$VERBOSE = orig_verbose
|
852
847
|
end
|
853
848
|
|
854
|
-
def test_assert
|
855
|
-
@assertion_count = 2
|
856
|
-
|
857
|
-
@tc.assert_equal true, @tc.assert(true), "returns true on success"
|
858
|
-
end
|
859
|
-
|
860
|
-
def test_assert__triggered
|
861
|
-
assert_triggered "Expected false to be truthy." do
|
862
|
-
@tc.assert false
|
863
|
-
end
|
864
|
-
end
|
865
|
-
|
866
|
-
def test_assert__triggered_message
|
867
|
-
assert_triggered @zomg do
|
868
|
-
@tc.assert false, @zomg
|
869
|
-
end
|
870
|
-
end
|
871
|
-
|
872
|
-
def test_assert_empty
|
873
|
-
@assertion_count = 2
|
874
|
-
|
875
|
-
@tc.assert_empty []
|
876
|
-
end
|
877
|
-
|
878
|
-
def test_assert_empty_triggered
|
879
|
-
@assertion_count = 2
|
880
|
-
|
881
|
-
assert_triggered "Expected [1] to be empty." do
|
882
|
-
@tc.assert_empty [1]
|
883
|
-
end
|
884
|
-
end
|
885
|
-
|
886
|
-
def test_assert_equal
|
887
|
-
@tc.assert_equal 1, 1
|
888
|
-
end
|
889
|
-
|
890
|
-
def test_assert_equal_different_collection_array_hex_invisible
|
891
|
-
object1 = Object.new
|
892
|
-
object2 = Object.new
|
893
|
-
msg = "No visible difference in the Array#inspect output.
|
894
|
-
You should look at the implementation of #== on Array or its members.
|
895
|
-
[#<Object:0xXXXXXX>]".gsub(/^ +/, "")
|
896
|
-
assert_triggered msg do
|
897
|
-
@tc.assert_equal [object1], [object2]
|
898
|
-
end
|
899
|
-
end
|
900
|
-
|
901
|
-
def test_assert_equal_different_collection_hash_hex_invisible
|
902
|
-
h1, h2 = {}, {}
|
903
|
-
h1[1] = Object.new
|
904
|
-
h2[1] = Object.new
|
905
|
-
msg = "No visible difference in the Hash#inspect output.
|
906
|
-
You should look at the implementation of #== on Hash or its members.
|
907
|
-
{1=>#<Object:0xXXXXXX>}".gsub(/^ +/, "")
|
908
|
-
|
909
|
-
assert_triggered msg do
|
910
|
-
@tc.assert_equal h1, h2
|
911
|
-
end
|
912
|
-
end
|
913
|
-
|
914
|
-
def test_assert_equal_string_encodings
|
915
|
-
msg = <<-EOM.gsub(/^ {10}/, "")
|
916
|
-
--- expected
|
917
|
-
+++ actual
|
918
|
-
@@ -1 +1,2 @@
|
919
|
-
+# encoding: ASCII-8BIT
|
920
|
-
"bad-utf8-\\xF1.txt"
|
921
|
-
EOM
|
922
|
-
|
923
|
-
assert_triggered msg do
|
924
|
-
x = "bad-utf8-\xF1.txt"
|
925
|
-
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
|
926
|
-
@tc.assert_equal x, y
|
927
|
-
end
|
928
|
-
end unless RUBY18
|
929
|
-
|
930
|
-
def test_assert_equal_string_encodings_both_different
|
931
|
-
msg = <<-EOM.gsub(/^ {10}/, "")
|
932
|
-
--- expected
|
933
|
-
+++ actual
|
934
|
-
@@ -1,2 +1,2 @@
|
935
|
-
-# encoding: US-ASCII
|
936
|
-
+# encoding: ASCII-8BIT
|
937
|
-
"bad-utf8-\\xF1.txt"
|
938
|
-
EOM
|
939
|
-
|
940
|
-
assert_triggered msg do
|
941
|
-
x = "bad-utf8-\xF1.txt".force_encoding "ASCII"
|
942
|
-
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
|
943
|
-
@tc.assert_equal x, y
|
944
|
-
end
|
945
|
-
end unless RUBY18
|
946
|
-
|
947
|
-
def test_assert_equal_different_diff_deactivated
|
948
|
-
skip "https://github.com/MagLev/maglev/issues/209" if maglev?
|
949
|
-
|
950
|
-
without_diff do
|
951
|
-
assert_triggered util_msg("haha" * 10, "blah" * 10) do
|
952
|
-
o1 = "haha" * 10
|
953
|
-
o2 = "blah" * 10
|
954
|
-
|
955
|
-
@tc.assert_equal o1, o2
|
956
|
-
end
|
957
|
-
end
|
958
|
-
end
|
959
|
-
|
960
|
-
def test_assert_equal_different_hex
|
961
|
-
c = Class.new do
|
962
|
-
def initialize s; @name = s; end
|
963
|
-
end
|
964
|
-
|
965
|
-
o1 = c.new "a"
|
966
|
-
o2 = c.new "b"
|
967
|
-
msg = "--- expected
|
968
|
-
+++ actual
|
969
|
-
@@ -1 +1 @@
|
970
|
-
-#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"a\">
|
971
|
-
+#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"b\">
|
972
|
-
".gsub(/^ +/, "")
|
973
|
-
|
974
|
-
assert_triggered msg do
|
975
|
-
@tc.assert_equal o1, o2
|
976
|
-
end
|
977
|
-
end
|
978
|
-
|
979
|
-
def test_assert_equal_different_hex_invisible
|
980
|
-
o1 = Object.new
|
981
|
-
o2 = Object.new
|
982
|
-
|
983
|
-
msg = "No visible difference in the Object#inspect output.
|
984
|
-
You should look at the implementation of #== on Object or its members.
|
985
|
-
#<Object:0xXXXXXX>".gsub(/^ +/, "")
|
986
|
-
|
987
|
-
assert_triggered msg do
|
988
|
-
@tc.assert_equal o1, o2
|
989
|
-
end
|
990
|
-
end
|
991
|
-
|
992
|
-
def test_assert_equal_different_long
|
993
|
-
msg = "--- expected
|
994
|
-
+++ actual
|
995
|
-
@@ -1 +1 @@
|
996
|
-
-\"hahahahahahahahahahahahahahahahahahahaha\"
|
997
|
-
+\"blahblahblahblahblahblahblahblahblahblah\"
|
998
|
-
".gsub(/^ +/, "")
|
999
|
-
|
1000
|
-
assert_triggered msg do
|
1001
|
-
o1 = "haha" * 10
|
1002
|
-
o2 = "blah" * 10
|
1003
|
-
|
1004
|
-
@tc.assert_equal o1, o2
|
1005
|
-
end
|
1006
|
-
end
|
1007
|
-
|
1008
|
-
def test_assert_equal_different_long_invisible
|
1009
|
-
msg = "No visible difference in the String#inspect output.
|
1010
|
-
You should look at the implementation of #== on String or its members.
|
1011
|
-
\"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "")
|
1012
|
-
|
1013
|
-
assert_triggered msg do
|
1014
|
-
o1 = "blah" * 10
|
1015
|
-
o2 = "blah" * 10
|
1016
|
-
def o1.== _
|
1017
|
-
false
|
1018
|
-
end
|
1019
|
-
@tc.assert_equal o1, o2
|
1020
|
-
end
|
1021
|
-
end
|
1022
|
-
|
1023
|
-
def test_assert_equal_different_long_msg
|
1024
|
-
msg = "message.
|
1025
|
-
--- expected
|
1026
|
-
+++ actual
|
1027
|
-
@@ -1 +1 @@
|
1028
|
-
-\"hahahahahahahahahahahahahahahahahahahaha\"
|
1029
|
-
+\"blahblahblahblahblahblahblahblahblahblah\"
|
1030
|
-
".gsub(/^ +/, "")
|
1031
|
-
|
1032
|
-
assert_triggered msg do
|
1033
|
-
o1 = "haha" * 10
|
1034
|
-
o2 = "blah" * 10
|
1035
|
-
@tc.assert_equal o1, o2, "message"
|
1036
|
-
end
|
1037
|
-
end
|
1038
|
-
|
1039
|
-
def test_assert_equal_different_short
|
1040
|
-
assert_triggered util_msg(1, 2) do
|
1041
|
-
@tc.assert_equal 1, 2
|
1042
|
-
end
|
1043
|
-
end
|
1044
|
-
|
1045
|
-
def test_assert_equal_different_short_msg
|
1046
|
-
assert_triggered util_msg(1, 2, "message") do
|
1047
|
-
@tc.assert_equal 1, 2, "message"
|
1048
|
-
end
|
1049
|
-
end
|
1050
|
-
|
1051
|
-
def test_assert_equal_different_short_multiline
|
1052
|
-
msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n"
|
1053
|
-
assert_triggered msg do
|
1054
|
-
@tc.assert_equal "a\nb", "a\nc"
|
1055
|
-
end
|
1056
|
-
end
|
1057
|
-
|
1058
|
-
def test_assert_equal_does_not_allow_lhs_nil
|
1059
|
-
if Minitest::VERSION =~ /^6/ then
|
1060
|
-
warn "Time to strip the MT5 test"
|
1061
|
-
|
1062
|
-
@assertion_count += 1
|
1063
|
-
assert_triggered(/Use assert_nil if expecting nil/) do
|
1064
|
-
@tc.assert_equal nil, nil
|
1065
|
-
end
|
1066
|
-
else
|
1067
|
-
err_re = /Use assert_nil if expecting nil from .*test_minitest_test.rb/
|
1068
|
-
err_re = "" if $-w.nil?
|
1069
|
-
|
1070
|
-
assert_output "", err_re do
|
1071
|
-
@tc.assert_equal nil, nil
|
1072
|
-
end
|
1073
|
-
end
|
1074
|
-
end
|
1075
|
-
|
1076
|
-
def test_assert_equal_does_not_allow_lhs_nil_triggered
|
1077
|
-
assert_triggered "Expected: nil\n Actual: false" do
|
1078
|
-
@tc.assert_equal nil, false
|
1079
|
-
end
|
1080
|
-
end
|
1081
|
-
|
1082
|
-
def test_assert_in_delta
|
1083
|
-
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
|
1084
|
-
end
|
1085
|
-
|
1086
|
-
def test_delta_consistency
|
1087
|
-
@assertion_count = 2
|
1088
|
-
|
1089
|
-
@tc.assert_in_delta 0, 1, 1
|
1090
|
-
|
1091
|
-
assert_triggered "Expected |0 - 1| (1) to not be <= 1." do
|
1092
|
-
@tc.refute_in_delta 0, 1, 1
|
1093
|
-
end
|
1094
|
-
end
|
1095
|
-
|
1096
|
-
def test_assert_in_delta_triggered
|
1097
|
-
x = maglev? ? "9.999999xxxe-07" : "1.0e-06"
|
1098
|
-
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
|
1099
|
-
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
|
1100
|
-
end
|
1101
|
-
end
|
1102
|
-
|
1103
|
-
def test_assert_in_epsilon
|
1104
|
-
@assertion_count = 10
|
1105
|
-
|
1106
|
-
@tc.assert_in_epsilon 10_000, 9991
|
1107
|
-
@tc.assert_in_epsilon 9991, 10_000
|
1108
|
-
@tc.assert_in_epsilon 1.0, 1.001
|
1109
|
-
@tc.assert_in_epsilon 1.001, 1.0
|
1110
|
-
|
1111
|
-
@tc.assert_in_epsilon 10_000, 9999.1, 0.0001
|
1112
|
-
@tc.assert_in_epsilon 9999.1, 10_000, 0.0001
|
1113
|
-
@tc.assert_in_epsilon 1.0, 1.0001, 0.0001
|
1114
|
-
@tc.assert_in_epsilon 1.0001, 1.0, 0.0001
|
1115
|
-
|
1116
|
-
@tc.assert_in_epsilon(-1, -1)
|
1117
|
-
@tc.assert_in_epsilon(-10_000, -9991)
|
1118
|
-
end
|
1119
|
-
|
1120
|
-
def test_epsilon_consistency
|
1121
|
-
@assertion_count = 2
|
1122
|
-
|
1123
|
-
@tc.assert_in_epsilon 1.0, 1.001
|
1124
|
-
|
1125
|
-
msg = "Expected |1.0 - 1.001| (0.000999xxx) to not be <= 0.001."
|
1126
|
-
assert_triggered msg do
|
1127
|
-
@tc.refute_in_epsilon 1.0, 1.001
|
1128
|
-
end
|
1129
|
-
end
|
1130
|
-
|
1131
|
-
def test_assert_in_epsilon_triggered
|
1132
|
-
assert_triggered "Expected |10000 - 9990| (10) to be <= 9.99." do
|
1133
|
-
@tc.assert_in_epsilon 10_000, 9990
|
1134
|
-
end
|
1135
|
-
end
|
1136
|
-
|
1137
|
-
def test_assert_in_epsilon_triggered_negative_case
|
1138
|
-
x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
|
1139
|
-
y = maglev? ? "0.100000xxx" : "0.1"
|
1140
|
-
assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
|
1141
|
-
@tc.assert_in_epsilon(-1.1, -1, 0.1)
|
1142
|
-
end
|
1143
|
-
end
|
1144
|
-
|
1145
|
-
def test_assert_includes
|
1146
|
-
@assertion_count = 2
|
1147
|
-
|
1148
|
-
@tc.assert_includes [true], true
|
1149
|
-
end
|
1150
|
-
|
1151
|
-
def test_assert_includes_triggered
|
1152
|
-
@assertion_count = 3
|
1153
|
-
|
1154
|
-
e = @tc.assert_raises Minitest::Assertion do
|
1155
|
-
@tc.assert_includes [true], false
|
1156
|
-
end
|
1157
|
-
|
1158
|
-
expected = "Expected [true] to include false."
|
1159
|
-
assert_equal expected, e.message
|
1160
|
-
end
|
1161
|
-
|
1162
|
-
def test_assert_instance_of
|
1163
|
-
@tc.assert_instance_of String, "blah"
|
1164
|
-
end
|
1165
|
-
|
1166
|
-
def test_assert_instance_of_triggered
|
1167
|
-
assert_triggered 'Expected "blah" to be an instance of Array, not String.' do
|
1168
|
-
@tc.assert_instance_of Array, "blah"
|
1169
|
-
end
|
1170
|
-
end
|
1171
|
-
|
1172
|
-
def test_assert_kind_of
|
1173
|
-
@tc.assert_kind_of String, "blah"
|
1174
|
-
end
|
1175
|
-
|
1176
|
-
def test_assert_kind_of_triggered
|
1177
|
-
assert_triggered 'Expected "blah" to be a kind of Array, not String.' do
|
1178
|
-
@tc.assert_kind_of Array, "blah"
|
1179
|
-
end
|
1180
|
-
end
|
1181
|
-
|
1182
|
-
def test_assert_match
|
1183
|
-
@assertion_count = 2
|
1184
|
-
@tc.assert_match(/\w+/, "blah blah blah")
|
1185
|
-
end
|
1186
|
-
|
1187
|
-
def test_assert_match_matcher_object
|
1188
|
-
@assertion_count = 2
|
1189
|
-
|
1190
|
-
pattern = Object.new
|
1191
|
-
def pattern.=~ _; true end
|
1192
|
-
|
1193
|
-
@tc.assert_match pattern, 5
|
1194
|
-
end
|
1195
|
-
|
1196
|
-
def test_assert_match_matchee_to_str
|
1197
|
-
@assertion_count = 2
|
1198
|
-
|
1199
|
-
obj = Object.new
|
1200
|
-
def obj.to_str; "blah" end
|
1201
|
-
|
1202
|
-
@tc.assert_match "blah", obj
|
1203
|
-
end
|
1204
|
-
|
1205
|
-
def test_assert_match_object_triggered
|
1206
|
-
@assertion_count = 2
|
1207
|
-
|
1208
|
-
pattern = Object.new
|
1209
|
-
def pattern.=~ _; false end
|
1210
|
-
def pattern.inspect; "[Object]" end
|
1211
|
-
|
1212
|
-
assert_triggered "Expected [Object] to match 5." do
|
1213
|
-
@tc.assert_match pattern, 5
|
1214
|
-
end
|
1215
|
-
end
|
1216
|
-
|
1217
|
-
def test_assert_match_triggered
|
1218
|
-
@assertion_count = 2
|
1219
|
-
assert_triggered 'Expected /\d+/ to match "blah blah blah".' do
|
1220
|
-
@tc.assert_match(/\d+/, "blah blah blah")
|
1221
|
-
end
|
1222
|
-
end
|
1223
|
-
|
1224
|
-
def test_assert_nil
|
1225
|
-
@tc.assert_nil nil
|
1226
|
-
end
|
1227
|
-
|
1228
|
-
def test_assert_nil_triggered
|
1229
|
-
assert_triggered "Expected 42 to be nil." do
|
1230
|
-
@tc.assert_nil 42
|
1231
|
-
end
|
1232
|
-
end
|
1233
|
-
|
1234
|
-
def test_assert_operator
|
1235
|
-
@tc.assert_operator 2, :>, 1
|
1236
|
-
end
|
1237
|
-
|
1238
|
-
def test_assert_operator_bad_object
|
1239
|
-
bad = Object.new
|
1240
|
-
def bad.== _; true end
|
1241
|
-
|
1242
|
-
@tc.assert_operator bad, :equal?, bad
|
1243
|
-
end
|
1244
|
-
|
1245
|
-
def test_assert_operator_triggered
|
1246
|
-
assert_triggered "Expected 2 to be < 1." do
|
1247
|
-
@tc.assert_operator 2, :<, 1
|
1248
|
-
end
|
1249
|
-
end
|
1250
|
-
|
1251
|
-
def test_assert_output_both
|
1252
|
-
@assertion_count = 2
|
1253
|
-
|
1254
|
-
@tc.assert_output "yay", "blah" do
|
1255
|
-
print "yay"
|
1256
|
-
$stderr.print "blah"
|
1257
|
-
end
|
1258
|
-
end
|
1259
|
-
|
1260
|
-
def test_assert_output_both_regexps
|
1261
|
-
@assertion_count = 4
|
1262
|
-
|
1263
|
-
@tc.assert_output(/y.y/, /bl.h/) do
|
1264
|
-
print "yay"
|
1265
|
-
$stderr.print "blah"
|
1266
|
-
end
|
1267
|
-
end
|
1268
|
-
|
1269
|
-
def test_assert_output_err
|
1270
|
-
@tc.assert_output nil, "blah" do
|
1271
|
-
$stderr.print "blah"
|
1272
|
-
end
|
1273
|
-
end
|
1274
|
-
|
1275
|
-
def test_assert_output_neither
|
1276
|
-
@assertion_count = 0
|
1277
|
-
|
1278
|
-
@tc.assert_output do
|
1279
|
-
# do nothing
|
1280
|
-
end
|
1281
|
-
end
|
1282
|
-
|
1283
|
-
def test_assert_output_out
|
1284
|
-
@tc.assert_output "blah" do
|
1285
|
-
print "blah"
|
1286
|
-
end
|
1287
|
-
end
|
1288
|
-
|
1289
|
-
def test_assert_output_triggered_both
|
1290
|
-
assert_triggered util_msg("blah", "blah blah", "In stderr") do
|
1291
|
-
@tc.assert_output "yay", "blah" do
|
1292
|
-
print "boo"
|
1293
|
-
$stderr.print "blah blah"
|
1294
|
-
end
|
1295
|
-
end
|
1296
|
-
end
|
1297
|
-
|
1298
|
-
def test_assert_output_triggered_err
|
1299
|
-
assert_triggered util_msg("blah", "blah blah", "In stderr") do
|
1300
|
-
@tc.assert_output nil, "blah" do
|
1301
|
-
$stderr.print "blah blah"
|
1302
|
-
end
|
1303
|
-
end
|
1304
|
-
end
|
1305
|
-
|
1306
|
-
def test_assert_output_triggered_out
|
1307
|
-
assert_triggered util_msg("blah", "blah blah", "In stdout") do
|
1308
|
-
@tc.assert_output "blah" do
|
1309
|
-
print "blah blah"
|
1310
|
-
end
|
1311
|
-
end
|
1312
|
-
end
|
1313
|
-
|
1314
|
-
def test_assert_predicate
|
1315
|
-
@tc.assert_predicate "", :empty?
|
1316
|
-
end
|
1317
|
-
|
1318
|
-
def test_assert_predicate_triggered
|
1319
|
-
assert_triggered 'Expected "blah" to be empty?.' do
|
1320
|
-
@tc.assert_predicate "blah", :empty?
|
1321
|
-
end
|
1322
|
-
end
|
1323
|
-
|
1324
|
-
def test_assert_raises
|
1325
|
-
@tc.assert_raises RuntimeError do
|
1326
|
-
raise "blah"
|
1327
|
-
end
|
1328
|
-
end
|
1329
|
-
|
1330
|
-
def test_assert_raises_default
|
1331
|
-
@tc.assert_raises do
|
1332
|
-
raise StandardError, "blah"
|
1333
|
-
end
|
1334
|
-
end
|
1335
|
-
|
1336
|
-
def test_assert_raises_default_triggered
|
1337
|
-
e = assert_raises Minitest::Assertion do
|
1338
|
-
@tc.assert_raises do
|
1339
|
-
raise SomeError, "blah"
|
1340
|
-
end
|
1341
|
-
end
|
1342
|
-
|
1343
|
-
expected = clean <<-EOM.chomp
|
1344
|
-
[StandardError] exception expected, not
|
1345
|
-
Class: <SomeError>
|
1346
|
-
Message: <\"blah\">
|
1347
|
-
---Backtrace---
|
1348
|
-
FILE:LINE:in \`test_assert_raises_default_triggered\'
|
1349
|
-
---------------
|
1350
|
-
EOM
|
1351
|
-
|
1352
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1353
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1354
|
-
|
1355
|
-
assert_equal expected, actual
|
1356
|
-
end
|
1357
|
-
|
1358
|
-
def test_assert_raises_module
|
1359
|
-
@tc.assert_raises MyModule do
|
1360
|
-
raise AnError
|
1361
|
-
end
|
1362
|
-
end
|
1363
|
-
|
1364
|
-
##
|
1365
|
-
# *sigh* This is quite an odd scenario, but it is from real (albeit
|
1366
|
-
# ugly) test code in ruby-core:
|
1367
|
-
#
|
1368
|
-
# http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29259
|
1369
|
-
|
1370
|
-
def test_assert_raises_skip
|
1371
|
-
@assertion_count = 0
|
1372
|
-
|
1373
|
-
assert_triggered "skipped", Minitest::Skip do
|
1374
|
-
@tc.assert_raises ArgumentError do
|
1375
|
-
begin
|
1376
|
-
raise "blah"
|
1377
|
-
rescue
|
1378
|
-
skip "skipped"
|
1379
|
-
end
|
1380
|
-
end
|
1381
|
-
end
|
1382
|
-
end
|
1383
|
-
|
1384
|
-
def test_assert_raises_triggered_different
|
1385
|
-
e = assert_raises Minitest::Assertion do
|
1386
|
-
@tc.assert_raises RuntimeError do
|
1387
|
-
raise SyntaxError, "icky"
|
1388
|
-
end
|
1389
|
-
end
|
1390
|
-
|
1391
|
-
expected = clean <<-EOM.chomp
|
1392
|
-
[RuntimeError] exception expected, not
|
1393
|
-
Class: <SyntaxError>
|
1394
|
-
Message: <\"icky\">
|
1395
|
-
---Backtrace---
|
1396
|
-
FILE:LINE:in \`test_assert_raises_triggered_different\'
|
1397
|
-
---------------
|
1398
|
-
EOM
|
1399
|
-
|
1400
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1401
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1402
|
-
|
1403
|
-
assert_equal expected, actual
|
1404
|
-
end
|
1405
|
-
|
1406
|
-
def test_assert_raises_triggered_different_msg
|
1407
|
-
e = assert_raises Minitest::Assertion do
|
1408
|
-
@tc.assert_raises RuntimeError, "XXX" do
|
1409
|
-
raise SyntaxError, "icky"
|
1410
|
-
end
|
1411
|
-
end
|
1412
|
-
|
1413
|
-
expected = clean <<-EOM
|
1414
|
-
XXX.
|
1415
|
-
[RuntimeError] exception expected, not
|
1416
|
-
Class: <SyntaxError>
|
1417
|
-
Message: <\"icky\">
|
1418
|
-
---Backtrace---
|
1419
|
-
FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
|
1420
|
-
---------------
|
1421
|
-
EOM
|
1422
|
-
|
1423
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1424
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1425
|
-
|
1426
|
-
assert_equal expected.chomp, actual
|
1427
|
-
end
|
1428
|
-
|
1429
|
-
def test_assert_raises_triggered_none
|
1430
|
-
e = assert_raises Minitest::Assertion do
|
1431
|
-
@tc.assert_raises Minitest::Assertion do
|
1432
|
-
# do nothing
|
1433
|
-
end
|
1434
|
-
end
|
1435
|
-
|
1436
|
-
expected = "Minitest::Assertion expected but nothing was raised."
|
1437
|
-
|
1438
|
-
assert_equal expected, e.message
|
1439
|
-
end
|
1440
|
-
|
1441
|
-
def test_assert_raises_triggered_none_msg
|
1442
|
-
e = assert_raises Minitest::Assertion do
|
1443
|
-
@tc.assert_raises Minitest::Assertion, "XXX" do
|
1444
|
-
# do nothing
|
1445
|
-
end
|
1446
|
-
end
|
1447
|
-
|
1448
|
-
expected = "XXX.\nMinitest::Assertion expected but nothing was raised."
|
1449
|
-
|
1450
|
-
assert_equal expected, e.message
|
1451
|
-
end
|
1452
|
-
|
1453
|
-
def test_assert_raises_subclass
|
1454
|
-
@tc.assert_raises StandardError do
|
1455
|
-
raise AnError
|
1456
|
-
end
|
1457
|
-
end
|
1458
|
-
|
1459
|
-
def test_assert_raises_subclass_triggered
|
1460
|
-
e = assert_raises Minitest::Assertion do
|
1461
|
-
@tc.assert_raises SomeError do
|
1462
|
-
raise AnError, "some message"
|
1463
|
-
end
|
1464
|
-
end
|
1465
|
-
|
1466
|
-
expected = clean <<-EOM
|
1467
|
-
[SomeError] exception expected, not
|
1468
|
-
Class: <AnError>
|
1469
|
-
Message: <\"some message\">
|
1470
|
-
---Backtrace---
|
1471
|
-
FILE:LINE:in \`test_assert_raises_subclass_triggered\'
|
1472
|
-
---------------
|
1473
|
-
EOM
|
1474
|
-
|
1475
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1476
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1477
|
-
|
1478
|
-
assert_equal expected.chomp, actual
|
1479
|
-
end
|
1480
|
-
|
1481
|
-
def test_assert_raises_exit
|
1482
|
-
@tc.assert_raises SystemExit do
|
1483
|
-
exit 1
|
1484
|
-
end
|
1485
|
-
end
|
1486
|
-
|
1487
|
-
def test_assert_raises_signals
|
1488
|
-
@tc.assert_raises SignalException do
|
1489
|
-
raise SignalException, :INT
|
1490
|
-
end
|
1491
|
-
end
|
1492
|
-
|
1493
|
-
def test_assert_respond_to
|
1494
|
-
@tc.assert_respond_to "blah", :empty?
|
1495
|
-
end
|
1496
|
-
|
1497
|
-
def test_assert_respond_to_triggered
|
1498
|
-
assert_triggered 'Expected "blah" (String) to respond to #rawr!.' do
|
1499
|
-
@tc.assert_respond_to "blah", :rawr!
|
1500
|
-
end
|
1501
|
-
end
|
1502
|
-
|
1503
|
-
def test_assert_same
|
1504
|
-
@assertion_count = 3
|
1505
|
-
|
1506
|
-
o = "blah"
|
1507
|
-
@tc.assert_same 1, 1
|
1508
|
-
@tc.assert_same :blah, :blah
|
1509
|
-
@tc.assert_same o, o
|
1510
|
-
end
|
1511
|
-
|
1512
|
-
def test_assert_same_triggered
|
1513
|
-
@assertion_count = 2
|
1514
|
-
|
1515
|
-
assert_triggered "Expected 2 (oid=N) to be the same as 1 (oid=N)." do
|
1516
|
-
@tc.assert_same 1, 2
|
1517
|
-
end
|
1518
|
-
|
1519
|
-
s1 = "blah"
|
1520
|
-
s2 = "blah"
|
1521
|
-
|
1522
|
-
assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
|
1523
|
-
@tc.assert_same s1, s2
|
1524
|
-
end
|
1525
|
-
end
|
1526
|
-
|
1527
|
-
def assert_deprecated name
|
1528
|
-
dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+(?::.*)?/
|
1529
|
-
dep = "" if $-w.nil?
|
1530
|
-
|
1531
|
-
assert_output nil, dep do
|
1532
|
-
yield
|
1533
|
-
end
|
1534
|
-
end
|
1535
|
-
|
1536
|
-
def test_assert_send
|
1537
|
-
assert_deprecated :assert_send do
|
1538
|
-
@tc.assert_send [1, :<, 2]
|
1539
|
-
end
|
1540
|
-
end
|
1541
|
-
|
1542
|
-
def test_assert_send_bad
|
1543
|
-
assert_deprecated :assert_send do
|
1544
|
-
assert_triggered "Expected 1.>(*[2]) to return true." do
|
1545
|
-
@tc.assert_send [1, :>, 2]
|
1546
|
-
end
|
1547
|
-
end
|
1548
|
-
end
|
1549
|
-
|
1550
|
-
def test_assert_silent
|
1551
|
-
@assertion_count = 2
|
1552
|
-
|
1553
|
-
@tc.assert_silent do
|
1554
|
-
# do nothing
|
1555
|
-
end
|
1556
|
-
end
|
1557
|
-
|
1558
|
-
def test_assert_silent_triggered_err
|
1559
|
-
assert_triggered util_msg("", "blah blah", "In stderr") do
|
1560
|
-
@tc.assert_silent do
|
1561
|
-
$stderr.print "blah blah"
|
1562
|
-
end
|
1563
|
-
end
|
1564
|
-
end
|
1565
|
-
|
1566
|
-
def test_assert_silent_triggered_out
|
1567
|
-
@assertion_count = 2
|
1568
|
-
|
1569
|
-
assert_triggered util_msg("", "blah blah", "In stdout") do
|
1570
|
-
@tc.assert_silent do
|
1571
|
-
print "blah blah"
|
1572
|
-
end
|
1573
|
-
end
|
1574
|
-
end
|
1575
|
-
|
1576
|
-
def test_assert_throws
|
1577
|
-
@tc.assert_throws :blah do
|
1578
|
-
throw :blah
|
1579
|
-
end
|
1580
|
-
end
|
1581
|
-
|
1582
|
-
def test_assert_throws_name_error
|
1583
|
-
@tc.assert_raises NameError do
|
1584
|
-
@tc.assert_throws :blah do
|
1585
|
-
raise NameError
|
1586
|
-
end
|
1587
|
-
end
|
1588
|
-
end
|
1589
|
-
|
1590
|
-
def test_assert_throws_argument_exception
|
1591
|
-
@tc.assert_raises ArgumentError do
|
1592
|
-
@tc.assert_throws :blah do
|
1593
|
-
raise ArgumentError
|
1594
|
-
end
|
1595
|
-
end
|
1596
|
-
end
|
1597
|
-
|
1598
|
-
def test_assert_throws_different
|
1599
|
-
assert_triggered "Expected :blah to have been thrown, not :not_blah." do
|
1600
|
-
@tc.assert_throws :blah do
|
1601
|
-
throw :not_blah
|
1602
|
-
end
|
1603
|
-
end
|
1604
|
-
end
|
1605
|
-
|
1606
|
-
def test_assert_throws_unthrown
|
1607
|
-
assert_triggered "Expected :blah to have been thrown." do
|
1608
|
-
@tc.assert_throws :blah do
|
1609
|
-
# do nothing
|
1610
|
-
end
|
1611
|
-
end
|
1612
|
-
end
|
1613
|
-
|
1614
|
-
def test_capture_io
|
1615
|
-
@assertion_count = 0
|
1616
|
-
|
1617
|
-
non_verbose do
|
1618
|
-
out, err = capture_io do
|
1619
|
-
puts "hi"
|
1620
|
-
$stderr.puts "bye!"
|
1621
|
-
end
|
1622
|
-
|
1623
|
-
assert_equal "hi\n", out
|
1624
|
-
assert_equal "bye!\n", err
|
1625
|
-
end
|
1626
|
-
end
|
1627
|
-
|
1628
|
-
def test_capture_subprocess_io
|
1629
|
-
@assertion_count = 0
|
1630
|
-
|
1631
|
-
non_verbose do
|
1632
|
-
out, err = capture_subprocess_io do
|
1633
|
-
system("echo hi")
|
1634
|
-
system("echo bye! 1>&2")
|
1635
|
-
end
|
1636
|
-
|
1637
|
-
assert_equal "hi\n", out
|
1638
|
-
assert_equal "bye!", err.strip
|
1639
|
-
end
|
1640
|
-
end
|
1641
|
-
|
1642
|
-
def test_class_asserts_match_refutes
|
1643
|
-
@assertion_count = 0
|
1644
|
-
|
1645
|
-
methods = Minitest::Assertions.public_instance_methods
|
1646
|
-
methods.map!(&:to_s) if Symbol === methods.first
|
1647
|
-
|
1648
|
-
# These don't have corresponding refutes _on purpose_. They're
|
1649
|
-
# useless and will never be added, so don't bother.
|
1650
|
-
ignores = %w[assert_output assert_raises assert_send
|
1651
|
-
assert_silent assert_throws assert_mock]
|
1652
|
-
|
1653
|
-
# These are test/unit methods. I'm not actually sure why they're still here
|
1654
|
-
ignores += %w[assert_no_match assert_not_equal assert_not_nil
|
1655
|
-
assert_not_same assert_nothing_raised
|
1656
|
-
assert_nothing_thrown assert_raise]
|
1657
|
-
|
1658
|
-
asserts = methods.grep(/^assert/).sort - ignores
|
1659
|
-
refutes = methods.grep(/^refute/).sort - ignores
|
1660
|
-
|
1661
|
-
assert_empty refutes.map { |n| n.sub(/^refute/, "assert") } - asserts
|
1662
|
-
assert_empty asserts.map { |n| n.sub(/^assert/, "refute") } - refutes
|
1663
|
-
end
|
1664
|
-
|
1665
|
-
def test_flunk
|
1666
|
-
assert_triggered "Epic Fail!" do
|
1667
|
-
@tc.flunk
|
1668
|
-
end
|
1669
|
-
end
|
1670
|
-
|
1671
|
-
def test_flunk_message
|
1672
|
-
assert_triggered @zomg do
|
1673
|
-
@tc.flunk @zomg
|
1674
|
-
end
|
1675
|
-
end
|
1676
|
-
|
1677
|
-
def test_message
|
1678
|
-
@assertion_count = 0
|
1679
|
-
|
1680
|
-
assert_equal "blah2.", @tc.message { "blah2" }.call
|
1681
|
-
assert_equal "blah2.", @tc.message("") { "blah2" }.call
|
1682
|
-
assert_equal "blah1.\nblah2.", @tc.message(:blah1) { "blah2" }.call
|
1683
|
-
assert_equal "blah1.\nblah2.", @tc.message("blah1") { "blah2" }.call
|
1684
|
-
|
1685
|
-
message = proc { "blah1" }
|
1686
|
-
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
|
1687
|
-
|
1688
|
-
message = @tc.message { "blah1" }
|
1689
|
-
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
|
1690
|
-
end
|
1691
|
-
|
1692
|
-
def test_message_message
|
1693
|
-
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1694
|
-
@tc.assert_equal 1, 2, message { "whoops" }
|
1695
|
-
end
|
1696
|
-
end
|
1697
|
-
|
1698
|
-
def test_message_lambda
|
1699
|
-
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1700
|
-
@tc.assert_equal 1, 2, lambda { "whoops" }
|
1701
|
-
end
|
1702
|
-
end
|
1703
|
-
|
1704
|
-
def test_message_deferred
|
1705
|
-
@assertion_count, var = 0, nil
|
1706
|
-
|
1707
|
-
msg = message { var = "blah" }
|
1708
|
-
|
1709
|
-
assert_nil var
|
1710
|
-
|
1711
|
-
msg.call
|
1712
|
-
|
1713
|
-
assert_equal "blah", var
|
1714
|
-
end
|
1715
|
-
|
1716
|
-
def test_pass
|
1717
|
-
@tc.pass
|
1718
|
-
end
|
1719
|
-
|
1720
|
-
def test_prints
|
1721
|
-
printer = Class.new { extend Minitest::Assertions }
|
1722
|
-
@tc.assert_equal '"test"', printer.mu_pp(ImmutableString.new "test")
|
1723
|
-
end
|
1724
|
-
|
1725
|
-
def test_refute
|
1726
|
-
@assertion_count = 2
|
1727
|
-
|
1728
|
-
@tc.assert_equal false, @tc.refute(false), "returns false on success"
|
1729
|
-
end
|
1730
|
-
|
1731
|
-
def test_refute_empty
|
1732
|
-
@assertion_count = 2
|
1733
|
-
|
1734
|
-
@tc.refute_empty [1]
|
1735
|
-
end
|
1736
|
-
|
1737
|
-
def test_refute_empty_triggered
|
1738
|
-
@assertion_count = 2
|
1739
|
-
|
1740
|
-
assert_triggered "Expected [] to not be empty." do
|
1741
|
-
@tc.refute_empty []
|
1742
|
-
end
|
1743
|
-
end
|
1744
|
-
|
1745
|
-
def test_refute_equal
|
1746
|
-
@tc.refute_equal "blah", "yay"
|
1747
|
-
end
|
1748
|
-
|
1749
|
-
def test_refute_equal_triggered
|
1750
|
-
assert_triggered 'Expected "blah" to not be equal to "blah".' do
|
1751
|
-
@tc.refute_equal "blah", "blah"
|
1752
|
-
end
|
1753
|
-
end
|
1754
|
-
|
1755
|
-
def test_refute_in_delta
|
1756
|
-
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.000001
|
1757
|
-
end
|
1758
|
-
|
1759
|
-
def test_refute_in_delta_triggered
|
1760
|
-
x = maglev? ? "0.100000xxx" : "0.1"
|
1761
|
-
assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
|
1762
|
-
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
|
1763
|
-
end
|
1764
|
-
end
|
1765
|
-
|
1766
|
-
def test_refute_in_epsilon
|
1767
|
-
@tc.refute_in_epsilon 10_000, 9990-1
|
1768
|
-
end
|
1769
|
-
|
1770
|
-
def test_refute_in_epsilon_triggered
|
1771
|
-
assert_triggered "Expected |10000 - 9990| (10) to not be <= 10.0." do
|
1772
|
-
@tc.refute_in_epsilon 10_000, 9990
|
1773
|
-
flunk
|
1774
|
-
end
|
1775
|
-
end
|
1776
|
-
|
1777
|
-
def test_refute_includes
|
1778
|
-
@assertion_count = 2
|
1779
|
-
|
1780
|
-
@tc.refute_includes [true], false
|
1781
|
-
end
|
1782
|
-
|
1783
|
-
def test_refute_includes_triggered
|
1784
|
-
@assertion_count = 3
|
1785
|
-
|
1786
|
-
e = @tc.assert_raises Minitest::Assertion do
|
1787
|
-
@tc.refute_includes [true], true
|
1788
|
-
end
|
1789
|
-
|
1790
|
-
expected = "Expected [true] to not include true."
|
1791
|
-
assert_equal expected, e.message
|
1792
|
-
end
|
1793
|
-
|
1794
|
-
def test_refute_instance_of
|
1795
|
-
@tc.refute_instance_of Array, "blah"
|
1796
|
-
end
|
1797
|
-
|
1798
|
-
def test_refute_instance_of_triggered
|
1799
|
-
assert_triggered 'Expected "blah" to not be an instance of String.' do
|
1800
|
-
@tc.refute_instance_of String, "blah"
|
1801
|
-
end
|
1802
|
-
end
|
1803
|
-
|
1804
|
-
def test_refute_kind_of
|
1805
|
-
@tc.refute_kind_of Array, "blah"
|
1806
|
-
end
|
1807
|
-
|
1808
|
-
def test_refute_kind_of_triggered
|
1809
|
-
assert_triggered 'Expected "blah" to not be a kind of String.' do
|
1810
|
-
@tc.refute_kind_of String, "blah"
|
1811
|
-
end
|
1812
|
-
end
|
1813
|
-
|
1814
|
-
def test_refute_match
|
1815
|
-
@assertion_count = 2
|
1816
|
-
@tc.refute_match(/\d+/, "blah blah blah")
|
1817
|
-
end
|
1818
|
-
|
1819
|
-
def test_refute_match_matcher_object
|
1820
|
-
@assertion_count = 2
|
1821
|
-
@tc.refute_match Object.new, 5 # default #=~ returns false
|
1822
|
-
end
|
1823
|
-
|
1824
|
-
def test_refute_match_object_triggered
|
1825
|
-
@assertion_count = 2
|
1826
|
-
|
1827
|
-
pattern = Object.new
|
1828
|
-
def pattern.=~ _; true end
|
1829
|
-
def pattern.inspect; "[Object]" end
|
1830
|
-
|
1831
|
-
assert_triggered "Expected [Object] to not match 5." do
|
1832
|
-
@tc.refute_match pattern, 5
|
1833
|
-
end
|
1834
|
-
end
|
1835
|
-
|
1836
|
-
def test_refute_match_triggered
|
1837
|
-
@assertion_count = 2
|
1838
|
-
assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do
|
1839
|
-
@tc.refute_match(/\w+/, "blah blah blah")
|
1840
|
-
end
|
1841
|
-
end
|
1842
|
-
|
1843
|
-
def test_refute_nil
|
1844
|
-
@tc.refute_nil 42
|
1845
|
-
end
|
1846
|
-
|
1847
|
-
def test_refute_nil_triggered
|
1848
|
-
assert_triggered "Expected nil to not be nil." do
|
1849
|
-
@tc.refute_nil nil
|
1850
|
-
end
|
1851
|
-
end
|
1852
|
-
|
1853
|
-
def test_refute_predicate
|
1854
|
-
@tc.refute_predicate "42", :empty?
|
1855
|
-
end
|
1856
|
-
|
1857
|
-
def test_refute_predicate_triggered
|
1858
|
-
assert_triggered 'Expected "" to not be empty?.' do
|
1859
|
-
@tc.refute_predicate "", :empty?
|
1860
|
-
end
|
1861
|
-
end
|
1862
|
-
|
1863
|
-
def test_refute_operator
|
1864
|
-
@tc.refute_operator 2, :<, 1
|
1865
|
-
end
|
1866
|
-
|
1867
|
-
def test_refute_operator_bad_object
|
1868
|
-
bad = Object.new
|
1869
|
-
def bad.== _; true end
|
1870
|
-
|
1871
|
-
@tc.refute_operator true, :equal?, bad
|
1872
|
-
end
|
1873
|
-
|
1874
|
-
def test_refute_operator_triggered
|
1875
|
-
assert_triggered "Expected 2 to not be > 1." do
|
1876
|
-
@tc.refute_operator 2, :>, 1
|
1877
|
-
end
|
1878
|
-
end
|
1879
|
-
|
1880
|
-
def test_refute_respond_to
|
1881
|
-
@tc.refute_respond_to "blah", :rawr!
|
1882
|
-
end
|
1883
|
-
|
1884
|
-
def test_refute_respond_to_triggered
|
1885
|
-
assert_triggered 'Expected "blah" to not respond to empty?.' do
|
1886
|
-
@tc.refute_respond_to "blah", :empty?
|
1887
|
-
end
|
1888
|
-
end
|
1889
|
-
|
1890
|
-
def test_refute_same
|
1891
|
-
@tc.refute_same 1, 2
|
1892
|
-
end
|
1893
|
-
|
1894
|
-
def test_refute_same_triggered
|
1895
|
-
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
1896
|
-
@tc.refute_same 1, 1
|
1897
|
-
end
|
1898
|
-
end
|
1899
|
-
|
1900
|
-
def test_skip
|
1901
|
-
@assertion_count = 0
|
1902
|
-
|
1903
|
-
assert_triggered "haha!", Minitest::Skip do
|
1904
|
-
@tc.skip "haha!"
|
1905
|
-
end
|
1906
|
-
end
|
1907
|
-
|
1908
849
|
def test_runnable_methods_random
|
1909
850
|
@assertion_count = 0
|
1910
851
|
|
@@ -1960,34 +901,6 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1960
901
|
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
1961
902
|
end
|
1962
903
|
end
|
1963
|
-
|
1964
|
-
def assert_triggered expected, klass = Minitest::Assertion
|
1965
|
-
e = assert_raises klass do
|
1966
|
-
yield
|
1967
|
-
end
|
1968
|
-
|
1969
|
-
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
1970
|
-
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
|
1971
|
-
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
1972
|
-
|
1973
|
-
assert_msg = Regexp === expected ? :assert_match : :assert_equal
|
1974
|
-
self.send assert_msg, expected, msg
|
1975
|
-
end
|
1976
|
-
|
1977
|
-
def util_msg exp, act, msg = nil
|
1978
|
-
s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}"
|
1979
|
-
s = "#{msg}.\n#{s}" if msg
|
1980
|
-
s
|
1981
|
-
end
|
1982
|
-
|
1983
|
-
def without_diff
|
1984
|
-
old_diff = Minitest::Assertions.diff
|
1985
|
-
Minitest::Assertions.diff = nil
|
1986
|
-
|
1987
|
-
yield
|
1988
|
-
ensure
|
1989
|
-
Minitest::Assertions.diff = old_diff
|
1990
|
-
end
|
1991
904
|
end
|
1992
905
|
|
1993
906
|
class TestMinitestGuard < Minitest::Test
|