Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (48 sloc) 1.223 kB
a90a076 @spastorino Missing requires added
spastorino authored
1 require 'active_support/concern'
2 require 'active_support/callbacks'
3
139b924 @jeremy * Continue evolution toward ActiveSupport::TestCase and friends. #10…
jeremy authored
4 module ActiveSupport
5 module Testing
6 module SetupAndTeardown
7d8e5fa @floehopper Avoid dependency on MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.
floehopper authored
7
8 PASSTHROUGH_EXCEPTIONS = [
9 NoMemoryError,
10 SignalException,
11 Interrupt,
12 SystemExit
13 ]
14
e58ad8e @josevalim Setup and teardown now use new callbacks.
josevalim authored
15 extend ActiveSupport::Concern
139b924 @jeremy * Continue evolution toward ActiveSupport::TestCase and friends. #10…
jeremy authored
16
e58ad8e @josevalim Setup and teardown now use new callbacks.
josevalim authored
17 included do
18 include ActiveSupport::Callbacks
19 define_callbacks :setup, :teardown
20
21 end
22
23 module ClassMethods
24 def setup(*args, &block)
25 set_callback(:setup, :before, *args, &block)
26 end
27
28 def teardown(*args, &block)
29 set_callback(:teardown, :after, *args, &block)
34c51c9 @jeremy Rubinious: setup/teardown override for miniunit
jeremy authored
30 end
31 end
32
579acb4 @tenderlove just mix the run method in for minitest
tenderlove authored
33 def run(runner)
34 result = '.'
35 begin
36 run_callbacks :setup do
37 result = super
38 end
7d8e5fa @floehopper Avoid dependency on MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.
floehopper authored
39 rescue *PASSTHROUGH_EXCEPTIONS
b057fab @floehopper Exceptions like Interrupt should not be rescued.
floehopper authored
40 raise
579acb4 @tenderlove just mix the run method in for minitest
tenderlove authored
41 rescue Exception => e
42 result = runner.puke(self.class, method_name, e)
43 ensure
34c51c9 @jeremy Rubinious: setup/teardown override for miniunit
jeremy authored
44 begin
579acb4 @tenderlove just mix the run method in for minitest
tenderlove authored
45 run_callbacks :teardown
7d8e5fa @floehopper Avoid dependency on MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.
floehopper authored
46 rescue *PASSTHROUGH_EXCEPTIONS
b057fab @floehopper Exceptions like Interrupt should not be rescued.
floehopper authored
47 raise
34c51c9 @jeremy Rubinious: setup/teardown override for miniunit
jeremy authored
48 rescue Exception => e
c44fb4c @jeremy Ruby 1.9: use method_name to work around miniunit API changes
jeremy authored
49 result = runner.puke(self.class, method_name, e)
34c51c9 @jeremy Rubinious: setup/teardown override for miniunit
jeremy authored
50 end
139b924 @jeremy * Continue evolution toward ActiveSupport::TestCase and friends. #10…
jeremy authored
51 end
579acb4 @tenderlove just mix the run method in for minitest
tenderlove authored
52 result
139b924 @jeremy * Continue evolution toward ActiveSupport::TestCase and friends. #10…
jeremy authored
53 end
21e7b84 @josh Callbacks, DeprecatedCallbacks = NewCallbacks, Callbacks
josh authored
54
139b924 @jeremy * Continue evolution toward ActiveSupport::TestCase and friends. #10…
jeremy authored
55 end
56 end
57 end
Something went wrong with that request. Please try again.