minitest 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +15 -0
- data/lib/minitest/mock.rb +33 -7
- data/lib/minitest/spec.rb +28 -31
- data/lib/minitest/unit.rb +111 -2
- data/test/test_minitest_mock.rb +32 -8
- data/test/test_minitest_spec.rb +5 -4
- data/test/test_minitest_unit.rb +143 -0
- metadata +4 -4
- metadata.gz.sig +1 -1
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
=== 2.3.0 / 2011-06-15
|
2
|
+
|
3
|
+
* 5 minor enhancements:
|
4
|
+
|
5
|
+
* Add setup and teardown hooks to MiniTest::TestCase. (phiggins)
|
6
|
+
* Added nicer error messages for MiniTest::Mock. (phiggins)
|
7
|
+
* Allow for less specific expected arguments in Mock. (bhenderson/phiggins)
|
8
|
+
* Made MiniTest::Mock a blank slate. (phiggins)
|
9
|
+
* Refactored minitest/spec to use the hooks instead of define_inheritable_method. (phiggins)
|
10
|
+
|
11
|
+
* 2 bug fixes:
|
12
|
+
|
13
|
+
* Fixed TestCase's inherited hook. (dchelimsky/phiggins/jamis, the 'good' neighbor)
|
14
|
+
* MiniTest::Assertions#refute_empty should use mu_pp in the default message. (whatthejeff)
|
15
|
+
|
1
16
|
=== 2.2.2 / 2011-06-01
|
2
17
|
|
3
18
|
* 2 bug fixes:
|
data/lib/minitest/mock.rb
CHANGED
@@ -9,20 +9,37 @@ module MiniTest
|
|
9
9
|
# All mock objects are an instance of Mock
|
10
10
|
|
11
11
|
class Mock
|
12
|
+
alias :__respond_to? :respond_to?
|
13
|
+
|
14
|
+
instance_methods.each do |m|
|
15
|
+
undef_method m unless m =~ /^__|object_id|respond_to_missing?/
|
16
|
+
end
|
17
|
+
|
12
18
|
def initialize # :nodoc:
|
13
19
|
@expected_calls = {}
|
14
20
|
@actual_calls = Hash.new {|h,k| h[k] = [] }
|
15
21
|
end
|
16
22
|
|
17
23
|
##
|
18
|
-
# Expect that method +name+ is called, optionally with +args+, and
|
19
|
-
#
|
24
|
+
# Expect that method +name+ is called, optionally with +args+, and returns
|
25
|
+
# +retval+.
|
20
26
|
#
|
21
27
|
# @mock.expect(:meaning_of_life, 42)
|
22
28
|
# @mock.meaning_of_life # => 42
|
23
29
|
#
|
24
30
|
# @mock.expect(:do_something_with, true, [some_obj, true])
|
25
31
|
# @mock.do_something_with(some_obj, true) # => true
|
32
|
+
#
|
33
|
+
# +args+ is compared to the expected args using case equality (ie, the
|
34
|
+
# '===' operator), allowing for less specific expectations.
|
35
|
+
#
|
36
|
+
# @mock.expect(:uses_any_string, true, [String])
|
37
|
+
# @mock.uses_any_string("foo") # => true
|
38
|
+
# @mock.verify # => true
|
39
|
+
#
|
40
|
+
# @mock.expect(:uses_one_string, true, ["foo"]
|
41
|
+
# @mock.uses_one_string("bar") # => true
|
42
|
+
# @mock.verify # => raises MockExpectationError
|
26
43
|
|
27
44
|
def expect(name, retval, args=[])
|
28
45
|
@expected_calls[name] = { :retval => retval, :args => args }
|
@@ -45,17 +62,26 @@ module MiniTest
|
|
45
62
|
end
|
46
63
|
|
47
64
|
def method_missing(sym, *args) # :nodoc:
|
48
|
-
|
49
|
-
|
65
|
+
unless @expected_calls.has_key?(sym)
|
66
|
+
raise NoMethodError, "unmocked method '%s', expected one of %s" %
|
67
|
+
[sym, @expected_calls.keys.map{|s| "'#{s}'" }.sort.join(", ")]
|
68
|
+
end
|
69
|
+
|
70
|
+
unless @expected_calls[sym][:args].size == args.size
|
71
|
+
raise ArgumentError, "mocked method '%s' expects %d arguments, got %d" %
|
72
|
+
[sym, @expected_calls[sym][:args].size, args.size]
|
73
|
+
end
|
74
|
+
|
50
75
|
retval = @expected_calls[sym][:retval]
|
51
|
-
@
|
76
|
+
args_case = @expected_calls[sym][:args].
|
77
|
+
each_with_index.map{|a, i| a if a === args[i]}
|
78
|
+
@actual_calls[sym] << { :retval => retval, :args => args_case }
|
52
79
|
retval
|
53
80
|
end
|
54
81
|
|
55
|
-
alias :original_respond_to? :respond_to?
|
56
82
|
def respond_to?(sym) # :nodoc:
|
57
83
|
return true if @expected_calls.has_key?(sym)
|
58
|
-
return
|
84
|
+
return __respond_to?(sym)
|
59
85
|
end
|
60
86
|
end
|
61
87
|
end
|
data/lib/minitest/spec.rb
CHANGED
@@ -82,17 +82,8 @@ module Kernel
|
|
82
82
|
else
|
83
83
|
MiniTest::Spec.spec_type desc
|
84
84
|
end
|
85
|
-
cls = Class.new sclas
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
# :stopdoc:
|
90
|
-
# omg this sucks
|
91
|
-
(class << cls; self; end).send(:define_method, :to_s) { name }
|
92
|
-
(class << cls; self; end).send(:define_method, :desc) { desc }
|
93
|
-
# :startdoc:
|
94
|
-
|
95
|
-
cls.nuke_test_methods!
|
86
|
+
cls = sclas.create(name, desc)
|
96
87
|
|
97
88
|
stack.push cls
|
98
89
|
cls.class_eval(&block)
|
@@ -160,25 +151,6 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
160
151
|
end
|
161
152
|
end
|
162
153
|
|
163
|
-
##
|
164
|
-
# Spec users want setup/teardown to be inherited and NOTHING ELSE.
|
165
|
-
# It is almost like method reuse is lost on them.
|
166
|
-
|
167
|
-
def self.define_inheritable_method name, &block # :nodoc:
|
168
|
-
# regular super() warns
|
169
|
-
super_method = self.superclass.instance_method name
|
170
|
-
|
171
|
-
teardown = name.to_s == "teardown"
|
172
|
-
super_before = super_method && ! teardown
|
173
|
-
super_after = super_method && teardown
|
174
|
-
|
175
|
-
define_method name do
|
176
|
-
super_method.bind(self).call if super_before
|
177
|
-
instance_eval(&block)
|
178
|
-
super_method.bind(self).call if super_after
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
154
|
##
|
183
155
|
# Define a 'before' action. Inherits the way normal methods should.
|
184
156
|
#
|
@@ -188,7 +160,8 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
188
160
|
|
189
161
|
def self.before type = :each, &block
|
190
162
|
raise "unsupported before type: #{type}" unless type == :each
|
191
|
-
|
163
|
+
|
164
|
+
add_setup_hook {|tc| tc.instance_eval(&block) }
|
192
165
|
end
|
193
166
|
|
194
167
|
##
|
@@ -200,7 +173,8 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
200
173
|
|
201
174
|
def self.after type = :each, &block
|
202
175
|
raise "unsupported after type: #{type}" unless type == :each
|
203
|
-
|
176
|
+
|
177
|
+
add_teardown_hook {|tc| tc.instance_eval(&block) }
|
204
178
|
end
|
205
179
|
|
206
180
|
##
|
@@ -226,6 +200,29 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
226
200
|
mod.send :undef_method, name if mod.public_method_defined? name
|
227
201
|
end
|
228
202
|
end
|
203
|
+
|
204
|
+
def self.create(name, desc) # :nodoc:
|
205
|
+
cls = Class.new(self) do
|
206
|
+
@name = name
|
207
|
+
@desc = desc
|
208
|
+
|
209
|
+
nuke_test_methods!
|
210
|
+
end
|
211
|
+
|
212
|
+
children << cls
|
213
|
+
|
214
|
+
cls
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.to_s # :nodoc:
|
218
|
+
defined?(@name) ? @name : super
|
219
|
+
end
|
220
|
+
|
221
|
+
# :stopdoc:
|
222
|
+
class << self
|
223
|
+
attr_reader :name, :desc
|
224
|
+
end
|
225
|
+
# :startdoc:
|
229
226
|
end
|
230
227
|
|
231
228
|
Object.infect_with_assertions(:must, :wont,
|
data/lib/minitest/unit.rb
CHANGED
@@ -485,7 +485,7 @@ module MiniTest
|
|
485
485
|
# Fails if +obj+ is empty.
|
486
486
|
|
487
487
|
def refute_empty obj, msg = nil
|
488
|
-
msg = message(msg) { "Expected #{obj
|
488
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to not be empty" }
|
489
489
|
assert_respond_to obj, :empty?
|
490
490
|
refute obj.empty?, msg
|
491
491
|
end
|
@@ -614,7 +614,7 @@ module MiniTest
|
|
614
614
|
end
|
615
615
|
|
616
616
|
class Unit
|
617
|
-
VERSION = "2.
|
617
|
+
VERSION = "2.3.0" # :nodoc:
|
618
618
|
|
619
619
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
620
620
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
@@ -939,6 +939,7 @@ module MiniTest
|
|
939
939
|
begin
|
940
940
|
@passed = nil
|
941
941
|
self.setup
|
942
|
+
self.run_setup_hooks
|
942
943
|
self.__send__ self.__name__
|
943
944
|
result = "." unless io?
|
944
945
|
@passed = true
|
@@ -949,6 +950,7 @@ module MiniTest
|
|
949
950
|
result = runner.puke self.class, self.__name__, e
|
950
951
|
ensure
|
951
952
|
begin
|
953
|
+
self.run_teardown_hooks
|
952
954
|
self.teardown
|
953
955
|
rescue *PASSTHROUGH_EXCEPTIONS
|
954
956
|
raise
|
@@ -983,6 +985,8 @@ module MiniTest
|
|
983
985
|
|
984
986
|
def self.inherited klass # :nodoc:
|
985
987
|
@@test_suites[klass] = true
|
988
|
+
klass.reset_setup_teardown_hooks
|
989
|
+
super
|
986
990
|
end
|
987
991
|
|
988
992
|
##
|
@@ -1029,6 +1033,111 @@ module MiniTest
|
|
1029
1033
|
|
1030
1034
|
def teardown; end
|
1031
1035
|
|
1036
|
+
def self.reset_setup_teardown_hooks # :nodoc:
|
1037
|
+
@setup_hooks = []
|
1038
|
+
@teardown_hooks = []
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
reset_setup_teardown_hooks
|
1042
|
+
|
1043
|
+
##
|
1044
|
+
# Adds a block of code that will be executed before every TestCase is
|
1045
|
+
# run. Equivalent to +setup+, but usable multiple times and without
|
1046
|
+
# re-opening any classes.
|
1047
|
+
#
|
1048
|
+
# All of the setup hooks will run in order after the +setup+ method, if
|
1049
|
+
# one is defined.
|
1050
|
+
#
|
1051
|
+
# The argument can be any object that responds to #call or a block.
|
1052
|
+
# That means that this call,
|
1053
|
+
#
|
1054
|
+
# MiniTest::TestCase.add_setup_hook { puts "foo" }
|
1055
|
+
#
|
1056
|
+
# ... is equivalent to:
|
1057
|
+
#
|
1058
|
+
# module MyTestSetup
|
1059
|
+
# def call
|
1060
|
+
# puts "foo"
|
1061
|
+
# end
|
1062
|
+
# end
|
1063
|
+
#
|
1064
|
+
# MiniTest::TestCase.add_setup_hook MyTestSetup
|
1065
|
+
#
|
1066
|
+
# The blocks passed to +add_setup_hook+ take an optional parameter that
|
1067
|
+
# will be the TestCase instance that is executing the block.
|
1068
|
+
|
1069
|
+
def self.add_setup_hook arg=nil, &block
|
1070
|
+
hook = arg || block
|
1071
|
+
@setup_hooks << hook
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
def self.setup_hooks # :nodoc:
|
1075
|
+
if superclass.respond_to? :setup_hooks then
|
1076
|
+
superclass.setup_hooks
|
1077
|
+
else
|
1078
|
+
[]
|
1079
|
+
end + @setup_hooks
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
def run_setup_hooks # :nodoc:
|
1083
|
+
self.class.setup_hooks.each do |hook|
|
1084
|
+
if hook.respond_to?(:arity) && hook.arity == 1
|
1085
|
+
hook.call(self)
|
1086
|
+
else
|
1087
|
+
hook.call
|
1088
|
+
end
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
##
|
1093
|
+
# Adds a block of code that will be executed after every TestCase is
|
1094
|
+
# run. Equivalent to +teardown+, but usable multiple times and without
|
1095
|
+
# re-opening any classes.
|
1096
|
+
#
|
1097
|
+
# All of the teardown hooks will run in reverse order after the
|
1098
|
+
# +teardown+ method, if one is defined.
|
1099
|
+
#
|
1100
|
+
# The argument can be any object that responds to #call or a block.
|
1101
|
+
# That means that this call,
|
1102
|
+
#
|
1103
|
+
# MiniTest::TestCase.add_teardown_hook { puts "foo" }
|
1104
|
+
#
|
1105
|
+
# ... is equivalent to:
|
1106
|
+
#
|
1107
|
+
# module MyTestTeardown
|
1108
|
+
# def call
|
1109
|
+
# puts "foo"
|
1110
|
+
# end
|
1111
|
+
# end
|
1112
|
+
#
|
1113
|
+
# MiniTest::TestCase.add_teardown_hook MyTestTeardown
|
1114
|
+
#
|
1115
|
+
# The blocks passed to +add_teardown_hook+ take an optional parameter
|
1116
|
+
# that will be the TestCase instance that is executing the block.
|
1117
|
+
|
1118
|
+
def self.add_teardown_hook arg=nil, &block
|
1119
|
+
hook = arg || block
|
1120
|
+
@teardown_hooks << hook
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
def self.teardown_hooks # :nodoc:
|
1124
|
+
if superclass.respond_to? :teardown_hooks then
|
1125
|
+
superclass.teardown_hooks
|
1126
|
+
else
|
1127
|
+
[]
|
1128
|
+
end + @teardown_hooks
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
def run_teardown_hooks # :nodoc:
|
1132
|
+
self.class.teardown_hooks.reverse.each do |hook|
|
1133
|
+
if hook.respond_to?(:arity) && hook.arity == 1
|
1134
|
+
hook.call(self)
|
1135
|
+
else
|
1136
|
+
hook.call
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
end
|
1140
|
+
|
1032
1141
|
include MiniTest::Assertions
|
1033
1142
|
end # class TestCase
|
1034
1143
|
end # class Unit
|
data/test/test_minitest_mock.rb
CHANGED
@@ -43,20 +43,16 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
|
|
43
43
|
util_verify_bad
|
44
44
|
end
|
45
45
|
|
46
|
-
def test_not_verify_if_unexpected_method_is_called
|
47
|
-
assert_raises NoMethodError do
|
48
|
-
@mock.unexpected
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
46
|
def test_blow_up_on_wrong_number_of_arguments
|
53
47
|
@mock.foo
|
54
48
|
@mock.meaning_of_life
|
55
49
|
@mock.expect(:sum, 3, [1, 2])
|
56
50
|
|
57
|
-
assert_raises ArgumentError do
|
51
|
+
e = assert_raises ArgumentError do
|
58
52
|
@mock.sum
|
59
53
|
end
|
54
|
+
|
55
|
+
assert_equal "mocked method 'sum' expects 2 arguments, got 0", e.message
|
60
56
|
end
|
61
57
|
|
62
58
|
def test_blow_up_on_wrong_arguments
|
@@ -75,9 +71,13 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
|
|
75
71
|
end
|
76
72
|
|
77
73
|
def test_no_method_error_on_unexpected_methods
|
78
|
-
assert_raises NoMethodError do
|
74
|
+
e = assert_raises NoMethodError do
|
79
75
|
@mock.bar
|
80
76
|
end
|
77
|
+
|
78
|
+
expected = "unmocked method 'bar', expected one of 'foo', 'meaning_of_life'"
|
79
|
+
|
80
|
+
assert_equal expected, e.message
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_assign_per_mock_return_values
|
@@ -98,6 +98,30 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
|
|
98
98
|
assert !MiniTest::Mock.new.respond_to?(:foo)
|
99
99
|
end
|
100
100
|
|
101
|
+
def test_mock_is_a_blank_slate
|
102
|
+
@mock.expect :kind_of?, true, [Fixnum]
|
103
|
+
@mock.expect :==, true, [1]
|
104
|
+
|
105
|
+
assert @mock.kind_of?(Fixnum), "didn't mock :kind_of?"
|
106
|
+
assert @mock == 1, "didn't mock :=="
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_verify_allows_called_args_to_be_loosely_specified
|
110
|
+
mock = MiniTest::Mock.new
|
111
|
+
mock.expect :loose_expectation, true, [Integer]
|
112
|
+
mock.loose_expectation 1
|
113
|
+
|
114
|
+
assert mock.verify
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_verify_raises_with_strict_args
|
118
|
+
mock = MiniTest::Mock.new
|
119
|
+
mock.expect :strict_expectation, true, [2]
|
120
|
+
mock.strict_expectation 1
|
121
|
+
|
122
|
+
util_verify_bad
|
123
|
+
end
|
124
|
+
|
101
125
|
def util_verify_bad
|
102
126
|
assert_raises MockExpectationError do
|
103
127
|
@mock.verify
|
data/test/test_minitest_spec.rb
CHANGED
@@ -239,8 +239,8 @@ class TestMeta < MiniTest::Unit::TestCase
|
|
239
239
|
assert_equal "inner thingy", y.desc
|
240
240
|
assert_equal "very inner thingy", z.desc
|
241
241
|
|
242
|
-
top_methods = %w(
|
243
|
-
inner_methods = %w(
|
242
|
+
top_methods = %w(test_0001_top_level_it)
|
243
|
+
inner_methods = %w(test_0001_inner_it)
|
244
244
|
|
245
245
|
assert_equal top_methods, x.instance_methods(false).sort.map {|o| o.to_s }
|
246
246
|
assert_equal inner_methods, y.instance_methods(false).sort.map {|o| o.to_s }
|
@@ -251,8 +251,9 @@ class TestMeta < MiniTest::Unit::TestCase
|
|
251
251
|
_, _, z, before_list, after_list = util_structure
|
252
252
|
|
253
253
|
tc = z.new(nil)
|
254
|
-
|
255
|
-
tc.
|
254
|
+
|
255
|
+
tc.run_setup_hooks
|
256
|
+
tc.run_teardown_hooks
|
256
257
|
|
257
258
|
assert_equal [1, 2, 3], before_list
|
258
259
|
assert_equal [3, 2, 1], after_list
|
data/test/test_minitest_unit.rb
CHANGED
@@ -436,6 +436,149 @@ Finished tests in 0.00
|
|
436
436
|
assert_report expected
|
437
437
|
end
|
438
438
|
|
439
|
+
def with_overridden_include
|
440
|
+
Class.class_eval do
|
441
|
+
def inherited_with_hacks klass
|
442
|
+
throw :inherited_hook
|
443
|
+
end
|
444
|
+
|
445
|
+
alias inherited_without_hacks inherited
|
446
|
+
alias inherited inherited_with_hacks
|
447
|
+
alias IGNORE_ME! inherited # 1.8 bug. god I love venture bros
|
448
|
+
end
|
449
|
+
|
450
|
+
yield
|
451
|
+
|
452
|
+
ensure
|
453
|
+
Class.class_eval do
|
454
|
+
alias inherited inherited_without_hacks
|
455
|
+
|
456
|
+
undef_method :inherited_with_hacks
|
457
|
+
undef_method :inherited_without_hacks
|
458
|
+
end
|
459
|
+
|
460
|
+
refute_respond_to Class, :inherited_with_hacks
|
461
|
+
refute_respond_to Class, :inherited_without_hacks
|
462
|
+
end
|
463
|
+
|
464
|
+
def test_inherited_hook_plays_nice_with_others
|
465
|
+
with_overridden_include do
|
466
|
+
assert_throws :inherited_hook do
|
467
|
+
Class.new MiniTest::Unit::TestCase
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
def test_setup_hooks
|
473
|
+
call_order = []
|
474
|
+
|
475
|
+
tc = Class.new(MiniTest::Unit::TestCase) do
|
476
|
+
define_method :setup do
|
477
|
+
super()
|
478
|
+
call_order << :method
|
479
|
+
end
|
480
|
+
|
481
|
+
define_method :test2 do
|
482
|
+
call_order << :test2
|
483
|
+
end
|
484
|
+
|
485
|
+
define_method :test1 do
|
486
|
+
call_order << :test1
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
tc.add_setup_hook lambda { call_order << :proc }
|
491
|
+
|
492
|
+
argument = nil
|
493
|
+
|
494
|
+
tc.add_setup_hook do |arg|
|
495
|
+
argument = arg
|
496
|
+
call_order << :block
|
497
|
+
end
|
498
|
+
|
499
|
+
@tu.run %w[--seed 42]
|
500
|
+
|
501
|
+
assert_kind_of tc, argument
|
502
|
+
|
503
|
+
expected = [:method, :proc, :block, :test1,
|
504
|
+
:method, :proc, :block, :test2]
|
505
|
+
|
506
|
+
assert_equal expected, call_order
|
507
|
+
end
|
508
|
+
|
509
|
+
def test_teardown_hooks
|
510
|
+
call_order = []
|
511
|
+
|
512
|
+
tc = Class.new(MiniTest::Unit::TestCase) do
|
513
|
+
define_method :teardown do
|
514
|
+
super()
|
515
|
+
call_order << :method
|
516
|
+
end
|
517
|
+
|
518
|
+
define_method :test2 do
|
519
|
+
call_order << :test2
|
520
|
+
end
|
521
|
+
|
522
|
+
define_method :test1 do
|
523
|
+
call_order << :test1
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
tc.add_teardown_hook lambda { call_order << :proc }
|
528
|
+
|
529
|
+
argument = nil
|
530
|
+
|
531
|
+
tc.add_teardown_hook do |arg|
|
532
|
+
argument = arg
|
533
|
+
call_order << :block
|
534
|
+
end
|
535
|
+
|
536
|
+
@tu.run %w[--seed 42]
|
537
|
+
|
538
|
+
assert_kind_of tc, argument
|
539
|
+
|
540
|
+
expected = [:test1, :block, :proc, :method,
|
541
|
+
:test2, :block, :proc, :method]
|
542
|
+
|
543
|
+
assert_equal expected, call_order
|
544
|
+
end
|
545
|
+
|
546
|
+
def test_setup_and_teardown_hooks_survive_inheritance
|
547
|
+
call_order = []
|
548
|
+
|
549
|
+
parent = Class.new(MiniTest::Unit::TestCase) do
|
550
|
+
define_method :setup do
|
551
|
+
super()
|
552
|
+
call_order << :setup_method
|
553
|
+
end
|
554
|
+
|
555
|
+
define_method :teardown do
|
556
|
+
super()
|
557
|
+
call_order << :teardown_method
|
558
|
+
end
|
559
|
+
|
560
|
+
define_method :test_something do
|
561
|
+
call_order << :test
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
parent.add_setup_hook { call_order << :setup_hook }
|
566
|
+
parent.add_teardown_hook { call_order << :teardown_hook }
|
567
|
+
|
568
|
+
_ = Class.new parent
|
569
|
+
|
570
|
+
parent.add_setup_hook { call_order << :setup_after }
|
571
|
+
parent.add_teardown_hook { call_order << :teardown_after }
|
572
|
+
|
573
|
+
@tu.run %w[--seed 42]
|
574
|
+
|
575
|
+
# Once for the parent class, once for the child
|
576
|
+
expected = [:setup_method, :setup_hook, :setup_after, :test,
|
577
|
+
:teardown_after, :teardown_hook, :teardown_method] * 2
|
578
|
+
|
579
|
+
assert_equal expected, call_order
|
580
|
+
end
|
581
|
+
|
439
582
|
def util_expand_bt bt
|
440
583
|
if RUBY_VERSION =~ /^1\.9/ then
|
441
584
|
bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 2.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: 2011-06-
|
39
|
+
date: 2011-06-18 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
{!��v(�ӒhGA�r꺤��D^���7� �Teؠ�݈^�>H~eTF0D���OQ��m�A�=��93:#[:
|