minitest 3.2.0 → 3.3.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.
- data.tar.gz.sig +0 -0
- data/History.txt +18 -0
- data/lib/minitest/mock.rb +1 -1
- data/lib/minitest/spec.rb +15 -22
- data/lib/minitest/unit.rb +153 -127
- data/test/minitest/metametameta.rb +13 -9
- data/test/minitest/test_minitest_spec.rb +16 -11
- data/test/minitest/test_minitest_unit.rb +133 -250
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
=== 3.3.0 / 2012-07-26
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
|
5
|
+
* Deprecated add_(setup|teardown)_hook in favor of (before|after)_(setup|teardown) [2013-01-01]
|
6
|
+
|
7
|
+
* 4 minor enhancements:
|
8
|
+
|
9
|
+
* Refactored deprecated hook system into a module.
|
10
|
+
* Refactored lifecycle hooks into a module.
|
11
|
+
* Removed after_setup/before_teardown + run_X_hooks from Spec.
|
12
|
+
* Spec#before/after now do a simple define_method and call super. DUR.
|
13
|
+
|
14
|
+
* 2 bug fixes:
|
15
|
+
|
16
|
+
* Fixed #passed? when used against a test that called flunk. (floehopper)
|
17
|
+
* Fixed rdoc bug preventing doco for some expectations. (stomar).
|
18
|
+
|
1
19
|
=== 3.2.0 / 2012-06-26
|
2
20
|
|
3
21
|
* 1 minor enhancement:
|
data/lib/minitest/mock.rb
CHANGED
data/lib/minitest/spec.rb
CHANGED
@@ -155,10 +155,11 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
155
155
|
#
|
156
156
|
# Equivalent to MiniTest::Unit::TestCase#setup.
|
157
157
|
|
158
|
-
def self.before type =
|
159
|
-
|
160
|
-
|
161
|
-
|
158
|
+
def self.before type = nil, &block
|
159
|
+
define_method :setup do
|
160
|
+
super()
|
161
|
+
self.instance_eval(&block)
|
162
|
+
end
|
162
163
|
end
|
163
164
|
|
164
165
|
##
|
@@ -168,10 +169,11 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
168
169
|
#
|
169
170
|
# Equivalent to MiniTest::Unit::TestCase#teardown.
|
170
171
|
|
171
|
-
def self.after type =
|
172
|
-
|
173
|
-
|
174
|
-
|
172
|
+
def self.after type = nil, &block
|
173
|
+
define_method :teardown do
|
174
|
+
self.instance_eval(&block)
|
175
|
+
super()
|
176
|
+
end
|
175
177
|
end
|
176
178
|
|
177
179
|
##
|
@@ -240,14 +242,6 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
240
242
|
end
|
241
243
|
|
242
244
|
# :stopdoc:
|
243
|
-
def after_setup
|
244
|
-
run_setup_hooks
|
245
|
-
end
|
246
|
-
|
247
|
-
def before_teardown
|
248
|
-
run_teardown_hooks
|
249
|
-
end
|
250
|
-
|
251
245
|
class << self
|
252
246
|
attr_reader :desc
|
253
247
|
alias :specify :it
|
@@ -283,11 +277,11 @@ module MiniTest::Expectations
|
|
283
277
|
#
|
284
278
|
# n.must_be_close_to m [, delta]
|
285
279
|
#
|
286
|
-
# :method:
|
280
|
+
# :method: must_be_close_to
|
287
281
|
|
288
282
|
infect_an_assertion :assert_in_delta, :must_be_close_to
|
289
283
|
|
290
|
-
alias :must_be_within_delta :must_be_close_to
|
284
|
+
alias :must_be_within_delta :must_be_close_to # :nodoc:
|
291
285
|
|
292
286
|
##
|
293
287
|
# See MiniTest::Assertions#assert_in_epsilon
|
@@ -443,12 +437,11 @@ module MiniTest::Expectations
|
|
443
437
|
#
|
444
438
|
# n.wont_be_close_to m [, delta]
|
445
439
|
#
|
446
|
-
# :method:
|
440
|
+
# :method: wont_be_close_to
|
447
441
|
|
448
|
-
infect_an_assertion :refute_in_delta, :
|
442
|
+
infect_an_assertion :refute_in_delta, :wont_be_close_to
|
449
443
|
|
450
|
-
alias :wont_be_close_to :
|
451
|
-
# FIX: reverse aliases
|
444
|
+
alias :wont_be_within_delta :wont_be_close_to # :nodoc:
|
452
445
|
|
453
446
|
##
|
454
447
|
# See MiniTest::Assertions#refute_in_epsilon
|
data/lib/minitest/unit.rb
CHANGED
@@ -184,9 +184,12 @@ module MiniTest
|
|
184
184
|
|
185
185
|
##
|
186
186
|
# Fails unless the block returns a true value.
|
187
|
+
#
|
188
|
+
# NOTE: This method is deprecated, use assert. It will be removed
|
189
|
+
# on 2013-01-01."
|
187
190
|
|
188
191
|
def assert_block msg = nil
|
189
|
-
warn "NOTE: MiniTest::Unit::TestCase#assert_block is deprecated, use assert. It will be removed on
|
192
|
+
warn "NOTE: MiniTest::Unit::TestCase#assert_block is deprecated, use assert. It will be removed on 2013-01-01. Called from #{caller.first}"
|
190
193
|
msg = message(msg) { "Expected block to return true value" }
|
191
194
|
assert yield, msg
|
192
195
|
end
|
@@ -645,7 +648,7 @@ module MiniTest
|
|
645
648
|
end
|
646
649
|
|
647
650
|
class Unit # :nodoc:
|
648
|
-
VERSION = "3.
|
651
|
+
VERSION = "3.3.0" # :nodoc:
|
649
652
|
|
650
653
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
651
654
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
@@ -667,8 +670,8 @@ module MiniTest
|
|
667
670
|
@@after_tests = []
|
668
671
|
|
669
672
|
##
|
670
|
-
# A simple hook allowing you to run a block of code after
|
671
|
-
# tests are done. Eg:
|
673
|
+
# A simple hook allowing you to run a block of code after _all_ of
|
674
|
+
# the tests are done. Eg:
|
672
675
|
#
|
673
676
|
# MiniTest::Unit.after_tests { p $debugging_info }
|
674
677
|
|
@@ -1018,6 +1021,143 @@ module MiniTest
|
|
1018
1021
|
end
|
1019
1022
|
end
|
1020
1023
|
|
1024
|
+
##
|
1025
|
+
# Provides before/after hooks for setup and teardown. These are
|
1026
|
+
# meant for library writers, NOT for regular test authors. See
|
1027
|
+
# #before_setup for an example.
|
1028
|
+
|
1029
|
+
module LifecycleHooks
|
1030
|
+
##
|
1031
|
+
# Runs before every test, after setup. This hook is meant for
|
1032
|
+
# libraries to extend minitest. It is not meant to be used by
|
1033
|
+
# test developers.
|
1034
|
+
#
|
1035
|
+
# See #before_setup for an example.
|
1036
|
+
|
1037
|
+
def after_setup; end
|
1038
|
+
|
1039
|
+
##
|
1040
|
+
# Runs before every test, before setup. This hook is meant for
|
1041
|
+
# libraries to extend minitest. It is not meant to be used by
|
1042
|
+
# test developers.
|
1043
|
+
#
|
1044
|
+
# As a simplistic example:
|
1045
|
+
#
|
1046
|
+
# module MyMinitestPlugin
|
1047
|
+
# def before_setup
|
1048
|
+
# super
|
1049
|
+
# # ... stuff to do before setup is run
|
1050
|
+
# end
|
1051
|
+
#
|
1052
|
+
# def after_setup
|
1053
|
+
# # ... stuff to do after setup is run
|
1054
|
+
# super
|
1055
|
+
# end
|
1056
|
+
#
|
1057
|
+
# def before_teardown
|
1058
|
+
# super
|
1059
|
+
# # ... stuff to do before teardown is run
|
1060
|
+
# end
|
1061
|
+
#
|
1062
|
+
# def after_teardown
|
1063
|
+
# # ... stuff to do after teardown is run
|
1064
|
+
# super
|
1065
|
+
# end
|
1066
|
+
# end
|
1067
|
+
#
|
1068
|
+
# class MiniTest::Unit::TestCase
|
1069
|
+
# include MyMinitestPlugin
|
1070
|
+
# end
|
1071
|
+
|
1072
|
+
def before_setup; end
|
1073
|
+
|
1074
|
+
##
|
1075
|
+
# Runs after every test, before teardown. This hook is meant for
|
1076
|
+
# libraries to extend minitest. It is not meant to be used by
|
1077
|
+
# test developers.
|
1078
|
+
#
|
1079
|
+
# See #before_setup for an example.
|
1080
|
+
|
1081
|
+
def before_teardown; end
|
1082
|
+
|
1083
|
+
##
|
1084
|
+
# Runs after every test, after teardown. This hook is meant for
|
1085
|
+
# libraries to extend minitest. It is not meant to be used by
|
1086
|
+
# test developers.
|
1087
|
+
#
|
1088
|
+
# See #before_setup for an example.
|
1089
|
+
|
1090
|
+
def after_teardown; end
|
1091
|
+
end
|
1092
|
+
|
1093
|
+
module Deprecated # :nodoc:
|
1094
|
+
|
1095
|
+
##
|
1096
|
+
# This entire module is deprecated and slated for removal on 2013-01-01.
|
1097
|
+
|
1098
|
+
module Hooks
|
1099
|
+
##
|
1100
|
+
# Adds a block of code that will be executed before every
|
1101
|
+
# TestCase is run.
|
1102
|
+
#
|
1103
|
+
# NOTE: This method is deprecated, use before/after_setup. It
|
1104
|
+
# will be removed on 2013-01-01.
|
1105
|
+
|
1106
|
+
def self.add_setup_hook arg=nil, &block
|
1107
|
+
warn "NOTE: MiniTest::Unit::TestCase.add_setup_hook is deprecated, use before/after_setup via a module (and call super!). It will be removed on 2013-01-01. Called from #{caller.first}"
|
1108
|
+
hook = arg || block
|
1109
|
+
@setup_hooks << hook
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
def self.setup_hooks # :nodoc:
|
1113
|
+
if superclass.respond_to? :setup_hooks then
|
1114
|
+
superclass.setup_hooks
|
1115
|
+
else
|
1116
|
+
[]
|
1117
|
+
end + @setup_hooks
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
def run_setup_hooks # :nodoc:
|
1121
|
+
_run_hooks self.class.setup_hooks
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
def _run_hooks hooks # :nodoc:
|
1125
|
+
hooks.each do |hook|
|
1126
|
+
if hook.respond_to?(:arity) && hook.arity == 1
|
1127
|
+
hook.call(self)
|
1128
|
+
else
|
1129
|
+
hook.call
|
1130
|
+
end
|
1131
|
+
end
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
##
|
1135
|
+
# Adds a block of code that will be executed after every
|
1136
|
+
# TestCase is run.
|
1137
|
+
#
|
1138
|
+
# NOTE: This method is deprecated, use before/after_teardown. It
|
1139
|
+
# will be removed on 2013-01-01.
|
1140
|
+
|
1141
|
+
def self.add_teardown_hook arg=nil, &block
|
1142
|
+
warn "NOTE: MiniTest::Unit::TestCase#add_teardown_hook is deprecated, use before/after_teardown. It will be removed on 2013-01-01. Called from #{caller.first}"
|
1143
|
+
hook = arg || block
|
1144
|
+
@teardown_hooks << hook
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
def self.teardown_hooks # :nodoc:
|
1148
|
+
if superclass.respond_to? :teardown_hooks then
|
1149
|
+
superclass.teardown_hooks
|
1150
|
+
else
|
1151
|
+
[]
|
1152
|
+
end + @teardown_hooks
|
1153
|
+
end
|
1154
|
+
|
1155
|
+
def run_teardown_hooks # :nodoc:
|
1156
|
+
_run_hooks self.class.teardown_hooks.reverse
|
1157
|
+
end
|
1158
|
+
end
|
1159
|
+
end
|
1160
|
+
|
1021
1161
|
##
|
1022
1162
|
# Subclass TestCase to create your own tests. Typically you'll want a
|
1023
1163
|
# TestCase subclass per implementation class.
|
@@ -1025,6 +1165,8 @@ module MiniTest
|
|
1025
1165
|
# See MiniTest::Assertions
|
1026
1166
|
|
1027
1167
|
class TestCase
|
1168
|
+
include LifecycleHooks
|
1169
|
+
include Deprecated::Hooks
|
1028
1170
|
include Guard
|
1029
1171
|
extend Guard
|
1030
1172
|
|
@@ -1070,6 +1212,7 @@ module MiniTest
|
|
1070
1212
|
rescue *PASSTHROUGH_EXCEPTIONS
|
1071
1213
|
raise
|
1072
1214
|
rescue Exception => e
|
1215
|
+
@passed = false
|
1073
1216
|
result = runner.puke self.class, self.__name__, e
|
1074
1217
|
end
|
1075
1218
|
end
|
@@ -1160,148 +1303,31 @@ module MiniTest
|
|
1160
1303
|
end
|
1161
1304
|
|
1162
1305
|
##
|
1163
|
-
# Runs before every test. Use this to
|
1306
|
+
# Runs before every test. Use this to set up before each test
|
1307
|
+
# run.
|
1164
1308
|
|
1165
1309
|
def setup; end
|
1166
1310
|
|
1167
1311
|
##
|
1168
|
-
# Runs
|
1169
|
-
#
|
1170
|
-
|
1171
|
-
def after_setup; end
|
1172
|
-
|
1173
|
-
##
|
1174
|
-
# Runs before every setup. Use this to refactor test initialization.
|
1175
|
-
|
1176
|
-
def before_setup; end
|
1177
|
-
|
1178
|
-
##
|
1179
|
-
# Runs after every test. Use this to refactor test cleanup.
|
1312
|
+
# Runs after every test. Use this to clean up after each test
|
1313
|
+
# run.
|
1180
1314
|
|
1181
1315
|
def teardown; end
|
1182
1316
|
|
1183
|
-
##
|
1184
|
-
# Runs after every test before teardown. Use this to refactor test
|
1185
|
-
# initialization.
|
1186
|
-
|
1187
|
-
def before_teardown; end
|
1188
|
-
|
1189
|
-
##
|
1190
|
-
# Runs after every teardown. Use this to refactor test cleanup.
|
1191
|
-
|
1192
|
-
def after_teardown; end
|
1193
|
-
|
1194
1317
|
def self.reset_setup_teardown_hooks # :nodoc:
|
1318
|
+
# also deprecated... believe it.
|
1195
1319
|
@setup_hooks = []
|
1196
1320
|
@teardown_hooks = []
|
1197
1321
|
end
|
1198
1322
|
|
1199
1323
|
reset_setup_teardown_hooks
|
1200
1324
|
|
1201
|
-
##
|
1202
|
-
# Adds a block of code that will be executed before every TestCase is
|
1203
|
-
# run. Equivalent to +setup+, but usable multiple times and without
|
1204
|
-
# re-opening any classes.
|
1205
|
-
#
|
1206
|
-
# All of the setup hooks will run in order after the +setup+ method, if
|
1207
|
-
# one is defined.
|
1208
|
-
#
|
1209
|
-
# The argument can be any object that responds to #call or a block.
|
1210
|
-
# That means that this call,
|
1211
|
-
#
|
1212
|
-
# MiniTest::Unit::TestCase.add_setup_hook { puts "foo" }
|
1213
|
-
#
|
1214
|
-
# ... is equivalent to:
|
1215
|
-
#
|
1216
|
-
# module MyTestSetup
|
1217
|
-
# def self.call
|
1218
|
-
# puts "foo"
|
1219
|
-
# end
|
1220
|
-
# end
|
1221
|
-
#
|
1222
|
-
# MiniTest::Unit::TestCase.add_setup_hook MyTestSetup
|
1223
|
-
#
|
1224
|
-
# The blocks passed to +add_setup_hook+ take an optional parameter that
|
1225
|
-
# will be the TestCase instance that is executing the block.
|
1226
|
-
|
1227
|
-
def self.add_setup_hook arg=nil, &block
|
1228
|
-
hook = arg || block
|
1229
|
-
@setup_hooks << hook
|
1230
|
-
end
|
1231
|
-
|
1232
|
-
def self.setup_hooks # :nodoc:
|
1233
|
-
if superclass.respond_to? :setup_hooks then
|
1234
|
-
superclass.setup_hooks
|
1235
|
-
else
|
1236
|
-
[]
|
1237
|
-
end + @setup_hooks
|
1238
|
-
end
|
1239
|
-
|
1240
|
-
def run_setup_hooks # :nodoc:
|
1241
|
-
self.class.setup_hooks.each do |hook|
|
1242
|
-
if hook.respond_to?(:arity) && hook.arity == 1
|
1243
|
-
hook.call(self)
|
1244
|
-
else
|
1245
|
-
hook.call
|
1246
|
-
end
|
1247
|
-
end
|
1248
|
-
end
|
1249
|
-
|
1250
|
-
##
|
1251
|
-
# Adds a block of code that will be executed after every TestCase is
|
1252
|
-
# run. Equivalent to +teardown+, but usable multiple times and without
|
1253
|
-
# re-opening any classes.
|
1254
|
-
#
|
1255
|
-
# All of the teardown hooks will run in reverse order after the
|
1256
|
-
# +teardown+ method, if one is defined.
|
1257
|
-
#
|
1258
|
-
# The argument can be any object that responds to #call or a block.
|
1259
|
-
# That means that this call,
|
1260
|
-
#
|
1261
|
-
# MiniTest::Unit::TestCase.add_teardown_hook { puts "foo" }
|
1262
|
-
#
|
1263
|
-
# ... is equivalent to:
|
1264
|
-
#
|
1265
|
-
# module MyTestTeardown
|
1266
|
-
# def self.call
|
1267
|
-
# puts "foo"
|
1268
|
-
# end
|
1269
|
-
# end
|
1270
|
-
#
|
1271
|
-
# MiniTest::Unit::TestCase.add_teardown_hook MyTestTeardown
|
1272
|
-
#
|
1273
|
-
# The blocks passed to +add_teardown_hook+ take an optional parameter
|
1274
|
-
# that will be the TestCase instance that is executing the block.
|
1275
|
-
|
1276
|
-
def self.add_teardown_hook arg=nil, &block
|
1277
|
-
hook = arg || block
|
1278
|
-
@teardown_hooks << hook
|
1279
|
-
end
|
1280
|
-
|
1281
|
-
def self.teardown_hooks # :nodoc:
|
1282
|
-
if superclass.respond_to? :teardown_hooks then
|
1283
|
-
superclass.teardown_hooks
|
1284
|
-
else
|
1285
|
-
[]
|
1286
|
-
end + @teardown_hooks
|
1287
|
-
end
|
1288
|
-
|
1289
|
-
def run_teardown_hooks # :nodoc:
|
1290
|
-
self.class.teardown_hooks.reverse.each do |hook|
|
1291
|
-
if hook.respond_to?(:arity) && hook.arity == 1
|
1292
|
-
hook.call(self)
|
1293
|
-
else
|
1294
|
-
hook.call
|
1295
|
-
end
|
1296
|
-
end
|
1297
|
-
end
|
1298
|
-
|
1299
1325
|
include MiniTest::Assertions
|
1300
1326
|
end # class TestCase
|
1301
1327
|
end # class Unit
|
1302
1328
|
end # module MiniTest
|
1303
1329
|
|
1304
|
-
Minitest = MiniTest # because ugh... I typo this all the time
|
1330
|
+
Minitest = MiniTest # :nodoc: because ugh... I typo this all the time
|
1305
1331
|
|
1306
1332
|
if $DEBUG then
|
1307
1333
|
module Test # :nodoc:
|
@@ -2,25 +2,29 @@ require 'tempfile'
|
|
2
2
|
require 'stringio'
|
3
3
|
require 'minitest/autorun'
|
4
4
|
|
5
|
+
class MiniTest::Unit::TestCase
|
6
|
+
def clean s
|
7
|
+
s.gsub(/^ {6}/, '')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
|
6
|
-
def assert_report expected =
|
7
|
-
|
8
|
-
Run options:
|
12
|
+
def assert_report expected, flags = %w[--seed 42]
|
13
|
+
header = clean <<-EOM
|
14
|
+
Run options: #{flags.map { |s| s =~ /\|/ ? s.inspect : s }.join " "}
|
9
15
|
|
10
16
|
# Running tests:
|
11
17
|
|
12
|
-
.
|
13
|
-
|
14
|
-
Finished tests in 0.00
|
15
|
-
|
16
|
-
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
|
17
18
|
EOM
|
18
19
|
|
20
|
+
@tu.run flags
|
21
|
+
|
19
22
|
output = @output.string.dup
|
20
23
|
output.sub!(/Finished tests in .*/, "Finished tests in 0.00")
|
21
24
|
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
|
22
25
|
|
23
26
|
output.gsub!(/ = \d+.\d\d s = /, ' = 0.00 s = ')
|
27
|
+
output.gsub!(/0x[A-Fa-f0-9]+/, '0xXXX')
|
24
28
|
|
25
29
|
if windows? then
|
26
30
|
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]')
|
@@ -30,7 +34,7 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
|
|
30
34
|
output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
|
31
35
|
end
|
32
36
|
|
33
|
-
assert_equal
|
37
|
+
assert_equal header + expected, output
|
34
38
|
end
|
35
39
|
|
36
40
|
def setup
|
@@ -630,20 +630,20 @@ class TestMeta < MiniTest::Unit::TestCase
|
|
630
630
|
def test_structure
|
631
631
|
x, y, z, * = util_structure
|
632
632
|
|
633
|
-
assert_equal "top-level thingy",
|
634
|
-
assert_equal "top-level thingy::inner thingy",
|
633
|
+
assert_equal "top-level thingy", x.to_s
|
634
|
+
assert_equal "top-level thingy::inner thingy", y.to_s
|
635
635
|
assert_equal "top-level thingy::inner thingy::very inner thingy", z.to_s
|
636
636
|
|
637
|
-
assert_equal "top-level thingy",
|
638
|
-
assert_equal "inner thingy",
|
637
|
+
assert_equal "top-level thingy", x.desc
|
638
|
+
assert_equal "inner thingy", y.desc
|
639
639
|
assert_equal "very inner thingy", z.desc
|
640
640
|
|
641
|
-
top_methods = %w(test_0001_top-level-it)
|
642
|
-
inner_methods1 = %w(test_0001_inner-it)
|
641
|
+
top_methods = %w(setup teardown test_0001_top-level-it)
|
642
|
+
inner_methods1 = %w(setup teardown test_0001_inner-it)
|
643
643
|
inner_methods2 = inner_methods1 +
|
644
644
|
%w(test_0002_anonymous test_0003_anonymous)
|
645
645
|
|
646
|
-
assert_equal top_methods,
|
646
|
+
assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
|
647
647
|
assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
|
648
648
|
assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s)
|
649
649
|
end
|
@@ -651,13 +651,18 @@ class TestMeta < MiniTest::Unit::TestCase
|
|
651
651
|
def test_setup_teardown_behavior
|
652
652
|
_, _, z, before_list, after_list = util_structure
|
653
653
|
|
654
|
-
|
654
|
+
@tu = MiniTest::Unit.new
|
655
|
+
@output = StringIO.new("")
|
656
|
+
MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
|
657
|
+
MiniTest::Unit.output = @output
|
655
658
|
|
656
|
-
tc.
|
657
|
-
tc.
|
659
|
+
tc = z.new :test_0002_anonymous
|
660
|
+
tc.run @tu
|
658
661
|
|
659
662
|
assert_equal [1, 2, 3], before_list
|
660
663
|
assert_equal [3, 2, 1], after_list
|
664
|
+
ensure
|
665
|
+
MiniTest::Unit.output = $stdout
|
661
666
|
end
|
662
667
|
|
663
668
|
def test_children
|
@@ -689,7 +694,7 @@ class TestMeta < MiniTest::Unit::TestCase
|
|
689
694
|
z = describe "second thingy" do end
|
690
695
|
end
|
691
696
|
|
692
|
-
test_methods = ['test_0001_top level it', 'test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world'].sort
|
697
|
+
test_methods = ['test_0001_top level it', 'test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world'].sort
|
693
698
|
|
694
699
|
assert_equal test_methods, [x1, x2]
|
695
700
|
assert_equal test_methods,
|
@@ -6,8 +6,8 @@ class AnError < StandardError; include MyModule; end
|
|
6
6
|
class ImmutableString < String; def inspect; super.freeze; end; end
|
7
7
|
|
8
8
|
class TestMiniTestUnit < MetaMetaMetaTestCase
|
9
|
-
pwd = Pathname.new
|
10
|
-
basedir = Pathname.new(File.expand_path
|
9
|
+
pwd = Pathname.new File.expand_path Dir.pwd
|
10
|
+
basedir = Pathname.new(File.expand_path "lib/minitest") + 'mini'
|
11
11
|
basedir = basedir.relative_path_from(pwd).to_s
|
12
12
|
MINITEST_BASE_DIR = basedir[/\A\./] ? basedir : "./#{basedir}"
|
13
13
|
BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in `each'",
|
@@ -145,12 +145,12 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
|
|
145
145
|
bt = util_expand_bt bt
|
146
146
|
|
147
147
|
ex = ["-e:1"]
|
148
|
-
fu = MiniTest::filter_backtrace
|
148
|
+
fu = MiniTest::filter_backtrace bt
|
149
149
|
assert_equal ex, fu
|
150
150
|
end
|
151
151
|
|
152
152
|
def test_run_test
|
153
|
-
|
153
|
+
Class.new MiniTest::Unit::TestCase do
|
154
154
|
attr_reader :foo
|
155
155
|
|
156
156
|
def run_test name
|
@@ -164,25 +164,19 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
-
|
168
|
-
|
169
|
-
@tu.run %w[--seed 42]
|
170
|
-
|
171
|
-
expected = "Run options: --seed 42
|
172
|
-
|
173
|
-
# Running tests:
|
167
|
+
expected = clean <<-EOM
|
168
|
+
.
|
174
169
|
|
175
|
-
.
|
170
|
+
Finished tests in 0.00
|
176
171
|
|
177
|
-
|
172
|
+
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
|
173
|
+
EOM
|
178
174
|
|
179
|
-
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
|
180
|
-
"
|
181
175
|
assert_report expected
|
182
176
|
end
|
183
177
|
|
184
178
|
def test_run_error
|
185
|
-
|
179
|
+
Class.new MiniTest::Unit::TestCase do
|
186
180
|
def test_something
|
187
181
|
assert true
|
188
182
|
end
|
@@ -192,21 +186,13 @@ Finished tests in 0.00
|
|
192
186
|
end
|
193
187
|
end
|
194
188
|
|
195
|
-
|
196
|
-
|
197
|
-
@tu.run %w[--seed 42]
|
198
|
-
|
199
|
-
expected = <<-EOM.gsub(/^ {6}/, '')
|
200
|
-
Run options: --seed 42
|
201
|
-
|
202
|
-
# Running tests:
|
203
|
-
|
189
|
+
expected = clean <<-EOM
|
204
190
|
E.
|
205
191
|
|
206
192
|
Finished tests in 0.00
|
207
193
|
|
208
194
|
1) Error:
|
209
|
-
test_error(
|
195
|
+
test_error(#<Class:0xXXX>):
|
210
196
|
RuntimeError: unhandled exception
|
211
197
|
FILE:LINE:in `test_error'
|
212
198
|
|
@@ -217,7 +203,7 @@ Finished tests in 0.00
|
|
217
203
|
end
|
218
204
|
|
219
205
|
def test_run_error_teardown
|
220
|
-
|
206
|
+
Class.new MiniTest::Unit::TestCase do
|
221
207
|
def test_something
|
222
208
|
assert true
|
223
209
|
end
|
@@ -227,30 +213,24 @@ Finished tests in 0.00
|
|
227
213
|
end
|
228
214
|
end
|
229
215
|
|
230
|
-
|
231
|
-
|
232
|
-
@tu.run %w[--seed 42]
|
233
|
-
|
234
|
-
expected = "Run options: --seed 42
|
216
|
+
expected = clean <<-EOM
|
217
|
+
E
|
235
218
|
|
236
|
-
|
237
|
-
|
238
|
-
E
|
219
|
+
Finished tests in 0.00
|
239
220
|
|
240
|
-
|
221
|
+
1) Error:
|
222
|
+
test_something(#<Class:0xXXX>):
|
223
|
+
RuntimeError: unhandled exception
|
224
|
+
FILE:LINE:in `teardown'
|
241
225
|
|
242
|
-
|
243
|
-
|
244
|
-
RuntimeError: unhandled exception
|
245
|
-
FILE:LINE:in `teardown'
|
226
|
+
1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
|
227
|
+
EOM
|
246
228
|
|
247
|
-
1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
|
248
|
-
"
|
249
229
|
assert_report expected
|
250
230
|
end
|
251
231
|
|
252
232
|
def test_run_failing
|
253
|
-
|
233
|
+
Class.new MiniTest::Unit::TestCase do
|
254
234
|
def test_something
|
255
235
|
assert true
|
256
236
|
end
|
@@ -260,29 +240,23 @@ RuntimeError: unhandled exception
|
|
260
240
|
end
|
261
241
|
end
|
262
242
|
|
263
|
-
|
264
|
-
|
265
|
-
@tu.run %w[--seed 42]
|
243
|
+
expected = clean <<-EOM
|
244
|
+
F.
|
266
245
|
|
267
|
-
|
268
|
-
|
269
|
-
# Running tests:
|
270
|
-
|
271
|
-
F.
|
246
|
+
Finished tests in 0.00
|
272
247
|
|
273
|
-
|
248
|
+
1) Failure:
|
249
|
+
test_failure(#<Class:0xXXX>) [FILE:LINE]:
|
250
|
+
Failed assertion, no message given.
|
274
251
|
|
275
|
-
|
276
|
-
|
277
|
-
Failed assertion, no message given.
|
252
|
+
2 tests, 2 assertions, 1 failures, 0 errors, 0 skips
|
253
|
+
EOM
|
278
254
|
|
279
|
-
2 tests, 2 assertions, 1 failures, 0 errors, 0 skips
|
280
|
-
"
|
281
255
|
assert_report expected
|
282
256
|
end
|
283
257
|
|
284
258
|
def test_run_failing_filtered
|
285
|
-
|
259
|
+
Class.new MiniTest::Unit::TestCase do
|
286
260
|
def test_something
|
287
261
|
assert true
|
288
262
|
end
|
@@ -292,39 +266,37 @@ Failed assertion, no message given.
|
|
292
266
|
end
|
293
267
|
end
|
294
268
|
|
295
|
-
|
269
|
+
expected = clean <<-EOM
|
270
|
+
.
|
296
271
|
|
297
|
-
|
298
|
-
|
299
|
-
expected = "Run options: --name \"/some|thing/\" --seed 42
|
300
|
-
|
301
|
-
# Running tests:
|
302
|
-
|
303
|
-
.
|
272
|
+
Finished tests in 0.00
|
304
273
|
|
305
|
-
|
274
|
+
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
|
275
|
+
EOM
|
306
276
|
|
307
|
-
|
308
|
-
"
|
309
|
-
assert_report expected
|
277
|
+
assert_report expected, %w[--name /some|thing/ --seed 42]
|
310
278
|
end
|
311
279
|
|
312
280
|
def test_run_passing
|
313
|
-
|
281
|
+
Class.new MiniTest::Unit::TestCase do
|
314
282
|
def test_something
|
315
283
|
assert true
|
316
284
|
end
|
317
285
|
end
|
318
286
|
|
319
|
-
|
287
|
+
expected = clean <<-EOM
|
288
|
+
.
|
320
289
|
|
321
|
-
|
290
|
+
Finished tests in 0.00
|
322
291
|
|
323
|
-
|
292
|
+
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
|
293
|
+
EOM
|
294
|
+
|
295
|
+
assert_report expected
|
324
296
|
end
|
325
297
|
|
326
298
|
def test_run_skip
|
327
|
-
|
299
|
+
Class.new MiniTest::Unit::TestCase do
|
328
300
|
def test_something
|
329
301
|
assert true
|
330
302
|
end
|
@@ -334,25 +306,19 @@ Finished tests in 0.00
|
|
334
306
|
end
|
335
307
|
end
|
336
308
|
|
337
|
-
|
338
|
-
|
339
|
-
@tu.run %w[--seed 42]
|
309
|
+
expected = clean <<-EOM
|
310
|
+
S.
|
340
311
|
|
341
|
-
|
342
|
-
|
343
|
-
# Running tests:
|
344
|
-
|
345
|
-
S.
|
312
|
+
Finished tests in 0.00
|
346
313
|
|
347
|
-
|
314
|
+
2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
|
315
|
+
EOM
|
348
316
|
|
349
|
-
2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
|
350
|
-
"
|
351
317
|
assert_report expected
|
352
318
|
end
|
353
319
|
|
354
320
|
def test_run_skip_verbose
|
355
|
-
|
321
|
+
Class.new MiniTest::Unit::TestCase do
|
356
322
|
def test_something
|
357
323
|
assert true
|
358
324
|
end
|
@@ -362,27 +328,21 @@ Finished tests in 0.00
|
|
362
328
|
end
|
363
329
|
end
|
364
330
|
|
365
|
-
|
331
|
+
expected = clean <<-EOM
|
332
|
+
#<Class:0xXXX>#test_skip = 0.00 s = S
|
333
|
+
#<Class:0xXXX>#test_something = 0.00 s = .
|
366
334
|
|
367
|
-
@tu.run %w[--seed 42 --verbose]
|
368
|
-
|
369
|
-
expected = "Run options: --seed 42 --verbose
|
370
|
-
|
371
|
-
# Running tests:
|
372
|
-
|
373
|
-
ATestCase#test_skip = 0.00 s = S
|
374
|
-
ATestCase#test_something = 0.00 s = .
|
375
335
|
|
336
|
+
Finished tests in 0.00
|
376
337
|
|
377
|
-
|
338
|
+
1) Skipped:
|
339
|
+
test_skip(#<Class:0xXXX>) [FILE:LINE]:
|
340
|
+
not yet
|
378
341
|
|
379
|
-
|
380
|
-
|
381
|
-
not yet
|
342
|
+
2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
|
343
|
+
EOM
|
382
344
|
|
383
|
-
|
384
|
-
"
|
385
|
-
assert_report expected
|
345
|
+
assert_report expected, %w[--seed 42 --verbose]
|
386
346
|
end
|
387
347
|
|
388
348
|
def test_default_runner_is_minitest_unit
|
@@ -390,18 +350,15 @@ not yet
|
|
390
350
|
end
|
391
351
|
|
392
352
|
def test_run_with_other_runner
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
begin
|
398
|
-
suite.before_suite
|
399
|
-
super(suite, type)
|
400
|
-
end
|
353
|
+
MiniTest::Unit.runner = Class.new MiniTest::Unit do
|
354
|
+
def _run_suite suite, type
|
355
|
+
suite.before_suite # Run once before each suite
|
356
|
+
super suite, type
|
401
357
|
end
|
402
|
-
end
|
358
|
+
end.new
|
403
359
|
|
404
|
-
|
360
|
+
Class.new MiniTest::Unit::TestCase do
|
361
|
+
def self.name; "wacky!" end
|
405
362
|
|
406
363
|
def self.before_suite
|
407
364
|
MiniTest::Unit.output.puts "Running #{self.name} tests"
|
@@ -417,22 +374,15 @@ not yet
|
|
417
374
|
end
|
418
375
|
end
|
419
376
|
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
# We should only see 'running ATestCase tests' once
|
425
|
-
expected = "Run options: --seed 42
|
377
|
+
expected = clean <<-EOM
|
378
|
+
Running wacky! tests
|
379
|
+
..
|
426
380
|
|
427
|
-
|
428
|
-
|
429
|
-
Running ATestCase tests
|
430
|
-
..
|
381
|
+
Finished tests in 0.00
|
431
382
|
|
432
|
-
|
383
|
+
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
|
384
|
+
EOM
|
433
385
|
|
434
|
-
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
|
435
|
-
"
|
436
386
|
assert_report expected
|
437
387
|
end
|
438
388
|
|
@@ -448,7 +398,6 @@ Finished tests in 0.00
|
|
448
398
|
end
|
449
399
|
|
450
400
|
yield
|
451
|
-
|
452
401
|
ensure
|
453
402
|
Class.class_eval do
|
454
403
|
alias inherited inherited_without_hacks
|
@@ -471,7 +420,7 @@ Finished tests in 0.00
|
|
471
420
|
|
472
421
|
def test_before_setup
|
473
422
|
call_order = []
|
474
|
-
Class.new
|
423
|
+
Class.new MiniTest::Unit::TestCase do
|
475
424
|
define_method :setup do
|
476
425
|
super()
|
477
426
|
call_order << :setup
|
@@ -490,9 +439,31 @@ Finished tests in 0.00
|
|
490
439
|
assert_equal expected, call_order
|
491
440
|
end
|
492
441
|
|
442
|
+
def test_passed_eh_teardown_good
|
443
|
+
test_class = Class.new MiniTest::Unit::TestCase do
|
444
|
+
def teardown; assert true; end
|
445
|
+
def test_omg; assert true; end
|
446
|
+
end
|
447
|
+
|
448
|
+
test = test_class.new :test_omg
|
449
|
+
test.run @tu
|
450
|
+
assert test.passed?
|
451
|
+
end
|
452
|
+
|
453
|
+
def test_passed_eh_teardown_flunked
|
454
|
+
test_class = Class.new MiniTest::Unit::TestCase do
|
455
|
+
def teardown; flunk; end
|
456
|
+
def test_omg; assert true; end
|
457
|
+
end
|
458
|
+
|
459
|
+
test = test_class.new :test_omg
|
460
|
+
test.run @tu
|
461
|
+
refute test.passed?
|
462
|
+
end
|
463
|
+
|
493
464
|
def test_after_teardown
|
494
465
|
call_order = []
|
495
|
-
Class.new
|
466
|
+
Class.new MiniTest::Unit::TestCase do
|
496
467
|
define_method :teardown do
|
497
468
|
super()
|
498
469
|
call_order << :teardown
|
@@ -513,7 +484,7 @@ Finished tests in 0.00
|
|
513
484
|
|
514
485
|
def test_all_teardowns_are_guaranteed_to_run
|
515
486
|
call_order = []
|
516
|
-
Class.new
|
487
|
+
Class.new MiniTest::Unit::TestCase do
|
517
488
|
define_method :after_teardown do
|
518
489
|
super()
|
519
490
|
call_order << :after_teardown
|
@@ -541,91 +512,15 @@ Finished tests in 0.00
|
|
541
512
|
assert_equal expected, call_order
|
542
513
|
end
|
543
514
|
|
544
|
-
def
|
545
|
-
call_order = []
|
546
|
-
|
547
|
-
tc = Class.new(MiniTest::Spec) do
|
548
|
-
define_method :setup do
|
549
|
-
super()
|
550
|
-
call_order << :method
|
551
|
-
end
|
552
|
-
|
553
|
-
define_method :test2 do
|
554
|
-
call_order << :test2
|
555
|
-
end
|
556
|
-
|
557
|
-
define_method :test1 do
|
558
|
-
call_order << :test1
|
559
|
-
end
|
560
|
-
end
|
561
|
-
|
562
|
-
tc.add_setup_hook lambda { call_order << :proc }
|
563
|
-
|
564
|
-
argument = nil
|
565
|
-
|
566
|
-
tc.add_setup_hook do |arg|
|
567
|
-
argument = arg
|
568
|
-
call_order << :block
|
569
|
-
end
|
570
|
-
|
571
|
-
@tu.run %w[--seed 42]
|
572
|
-
|
573
|
-
assert_kind_of tc, argument
|
574
|
-
|
575
|
-
expected = [:method, :proc, :block, :test1,
|
576
|
-
:method, :proc, :block, :test2]
|
577
|
-
|
578
|
-
assert_equal expected, call_order
|
579
|
-
end
|
580
|
-
|
581
|
-
def test_teardown_hooks
|
515
|
+
def test_setup_and_teardown_survive_inheritance
|
582
516
|
call_order = []
|
583
517
|
|
584
|
-
|
585
|
-
|
586
|
-
super()
|
587
|
-
call_order << :method
|
588
|
-
end
|
589
|
-
|
590
|
-
define_method :test2 do
|
591
|
-
call_order << :test2
|
592
|
-
end
|
593
|
-
|
594
|
-
define_method :test1 do
|
595
|
-
call_order << :test1
|
596
|
-
end
|
597
|
-
end
|
598
|
-
|
599
|
-
tc.add_teardown_hook lambda { call_order << :proc }
|
600
|
-
|
601
|
-
argument = nil
|
602
|
-
|
603
|
-
tc.add_teardown_hook do |arg|
|
604
|
-
argument = arg
|
605
|
-
call_order << :block
|
606
|
-
end
|
607
|
-
|
608
|
-
@tu.run %w[--seed 42]
|
609
|
-
|
610
|
-
assert_kind_of tc, argument
|
611
|
-
|
612
|
-
expected = [:test1, :block, :proc, :method,
|
613
|
-
:test2, :block, :proc, :method]
|
614
|
-
|
615
|
-
assert_equal expected, call_order
|
616
|
-
end
|
617
|
-
|
618
|
-
def test_setup_and_teardown_hooks_survive_inheritance
|
619
|
-
call_order = []
|
620
|
-
|
621
|
-
parent = Class.new(MiniTest::Spec) do
|
622
|
-
define_method :setup do
|
623
|
-
super()
|
518
|
+
parent = Class.new MiniTest::Spec do
|
519
|
+
before do
|
624
520
|
call_order << :setup_method
|
625
521
|
end
|
626
522
|
|
627
|
-
|
628
|
-
super()
|
523
|
+
after do
|
629
524
|
call_order << :teardown_method
|
630
525
|
end
|
631
526
|
|
@@ -634,19 +529,12 @@ Finished tests in 0.00
|
|
634
529
|
end
|
635
530
|
end
|
636
531
|
|
637
|
-
parent.add_setup_hook { call_order << :setup_hook }
|
638
|
-
parent.add_teardown_hook { call_order << :teardown_hook }
|
639
|
-
|
640
532
|
_ = Class.new parent
|
641
533
|
|
642
|
-
parent.add_setup_hook { call_order << :setup_after }
|
643
|
-
parent.add_teardown_hook { call_order << :teardown_after }
|
644
|
-
|
645
534
|
@tu.run %w[--seed 42]
|
646
535
|
|
647
536
|
# Once for the parent class, once for the child
|
648
|
-
expected = [:setup_method, :
|
649
|
-
:teardown_after, :teardown_hook, :teardown_method] * 2
|
537
|
+
expected = [:setup_method, :test, :teardown_method] * 2
|
650
538
|
|
651
539
|
assert_equal expected, call_order
|
652
540
|
end
|
@@ -676,7 +564,6 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
676
564
|
def teardown
|
677
565
|
assert_equal(@assertion_count, @tc._assertions,
|
678
566
|
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc._assertions
|
679
|
-
Object.send :remove_const, :ATestCase if defined? ATestCase
|
680
567
|
end
|
681
568
|
|
682
569
|
def test_assert
|
@@ -699,7 +586,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
699
586
|
|
700
587
|
def test_assert_block
|
701
588
|
exp = ["NOTE: MiniTest::Unit::TestCase#assert_block is deprecated,",
|
702
|
-
"use assert. It will be removed on
|
589
|
+
"use assert. It will be removed on 2013-01-01."].join " "
|
703
590
|
|
704
591
|
out, err = capture_io do
|
705
592
|
@tc.assert_block do
|
@@ -1097,12 +984,14 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
1097
984
|
end
|
1098
985
|
end
|
1099
986
|
|
1100
|
-
expected =
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
987
|
+
expected = clean <<-EOM.chomp
|
988
|
+
[RuntimeError] exception expected, not
|
989
|
+
Class: <SyntaxError>
|
990
|
+
Message: <\"icky\">
|
991
|
+
---Backtrace---
|
992
|
+
FILE:LINE:in `test_assert_raises_triggered_different'
|
993
|
+
---------------
|
994
|
+
EOM
|
1106
995
|
|
1107
996
|
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
|
1108
997
|
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
|
@@ -1117,7 +1006,7 @@ FILE:LINE:in `test_assert_raises_triggered_different'
|
|
1117
1006
|
end
|
1118
1007
|
end
|
1119
1008
|
|
1120
|
-
expected = <<-EOM
|
1009
|
+
expected = clean <<-EOM
|
1121
1010
|
XXX.
|
1122
1011
|
[RuntimeError] exception expected, not
|
1123
1012
|
Class: <SyntaxError>
|
@@ -1130,7 +1019,7 @@ FILE:LINE:in `test_assert_raises_triggered_different'
|
|
1130
1019
|
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
|
1131
1020
|
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
|
1132
1021
|
|
1133
|
-
assert_equal expected, actual
|
1022
|
+
assert_equal expected.chomp, actual
|
1134
1023
|
end
|
1135
1024
|
|
1136
1025
|
def test_assert_raises_triggered_none
|
@@ -1164,12 +1053,14 @@ FILE:LINE:in `test_assert_raises_triggered_different'
|
|
1164
1053
|
end
|
1165
1054
|
end
|
1166
1055
|
|
1167
|
-
expected =
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1056
|
+
expected = clean <<-EOM.chomp
|
1057
|
+
[StandardError] exception expected, not
|
1058
|
+
Class: <AnError>
|
1059
|
+
Message: <\"AnError\">
|
1060
|
+
---Backtrace---
|
1061
|
+
FILE:LINE:in `test_assert_raises_triggered_subclass'
|
1062
|
+
---------------
|
1063
|
+
EOM
|
1173
1064
|
|
1174
1065
|
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
|
1175
1066
|
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
|
@@ -1248,14 +1139,14 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1248
1139
|
end
|
1249
1140
|
|
1250
1141
|
def test_assert_throws
|
1251
|
-
@tc.assert_throws
|
1142
|
+
@tc.assert_throws :blah do
|
1252
1143
|
throw :blah
|
1253
1144
|
end
|
1254
1145
|
end
|
1255
1146
|
|
1256
1147
|
def test_assert_throws_different
|
1257
1148
|
util_assert_triggered 'Expected :blah to have been thrown, not :not_blah.' do
|
1258
|
-
@tc.assert_throws
|
1149
|
+
@tc.assert_throws :blah do
|
1259
1150
|
throw :not_blah
|
1260
1151
|
end
|
1261
1152
|
end
|
@@ -1263,7 +1154,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1263
1154
|
|
1264
1155
|
def test_assert_throws_unthrown
|
1265
1156
|
util_assert_triggered 'Expected :blah to have been thrown.' do
|
1266
|
-
@tc.assert_throws
|
1157
|
+
@tc.assert_throws :blah do
|
1267
1158
|
# do nothing
|
1268
1159
|
end
|
1269
1160
|
end
|
@@ -1308,21 +1199,13 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1308
1199
|
assert_empty asserts.map { |n| n.sub(/^assert/, 'refute') } - refutes
|
1309
1200
|
end
|
1310
1201
|
|
1311
|
-
def test_class_inherited
|
1312
|
-
@assertion_count = 0
|
1313
|
-
|
1314
|
-
Object.const_set(:ATestCase, Class.new(MiniTest::Unit::TestCase))
|
1315
|
-
|
1316
|
-
assert_equal [ATestCase], MiniTest::Unit::TestCase.test_suites
|
1317
|
-
end
|
1318
|
-
|
1319
1202
|
def test_class_test_suites
|
1320
1203
|
@assertion_count = 0
|
1321
1204
|
|
1322
|
-
|
1205
|
+
tc = Class.new(MiniTest::Unit::TestCase)
|
1323
1206
|
|
1324
1207
|
assert_equal 1, MiniTest::Unit::TestCase.test_suites.size
|
1325
|
-
assert_equal [
|
1208
|
+
assert_equal [tc], MiniTest::Unit::TestCase.test_suites
|
1326
1209
|
end
|
1327
1210
|
|
1328
1211
|
def test_expectation
|
@@ -1558,7 +1441,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1558
1441
|
def test_test_methods_random
|
1559
1442
|
@assertion_count = 0
|
1560
1443
|
|
1561
|
-
sample_test_case = Class.new
|
1444
|
+
sample_test_case = Class.new MiniTest::Unit::TestCase do
|
1562
1445
|
def test_test1; assert "does not matter" end
|
1563
1446
|
def test_test2; assert "does not matter" end
|
1564
1447
|
def test_test3; assert "does not matter" end
|
@@ -1572,7 +1455,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1572
1455
|
def test_test_methods_sorted
|
1573
1456
|
@assertion_count = 0
|
1574
1457
|
|
1575
|
-
sample_test_case = Class.new
|
1458
|
+
sample_test_case = Class.new MiniTest::Unit::TestCase do
|
1576
1459
|
def self.test_order; :sorted end
|
1577
1460
|
def test_test3; assert "does not matter" end
|
1578
1461
|
def test_test2; assert "does not matter" end
|
@@ -1606,7 +1489,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1606
1489
|
end
|
1607
1490
|
|
1608
1491
|
def util_assert_triggered expected, klass = MiniTest::Assertion
|
1609
|
-
e = assert_raises
|
1492
|
+
e = assert_raises klass do
|
1610
1493
|
yield
|
1611
1494
|
end
|
1612
1495
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 3.
|
10
|
+
version: 3.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2012-
|
39
|
+
date: 2012-07-27 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
metadata.gz.sig
CHANGED
Binary file
|