Permalink
Browse files

Revert "Rewrite AS::TestCase setup/teardown as a single callback chain"

This reverts commit 610e94c.
  • Loading branch information...
1 parent d5d2426 commit efdc06245470fa7caf2a14f2cb59e8bf8c76de5e @jeremy jeremy committed Oct 14, 2009
Showing with 27 additions and 30 deletions.
  1. +27 −30 activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -6,7 +6,7 @@ def self.included(base)
extend ClassMethods
include ActiveSupport::Callbacks
- define_callbacks :test
+ define_callbacks :setup, :teardown
if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions
include ForMiniTest
@@ -18,31 +18,28 @@ def self.included(base)
module ClassMethods
def setup(*args, &block)
- set_callback(:test, :before, *args, &block)
+ set_callback(:setup, *args, &block)
end
def teardown(*args, &block)
- set_callback(:test, :after, *args, &block)
- end
-
- def wrap(*args, &block)
- set_callback(:test, :around, *args, &block)
+ set_callback(:teardown, *args, &block)
end
end
module ForMiniTest
def run(runner)
result = '.'
begin
- run_callbacks :test do
- begin
- result = super
- rescue Exception => e
- result = runner.puke(self.class, self.name, e)
- end
- end
+ run_callbacks :setup
+ result = super
rescue Exception => e
result = runner.puke(self.class, self.name, e)
+ ensure
+ begin
+ run_callbacks :teardown, :enumerator => :reverse_each
+ rescue Exception => e
+ result = runner.puke(self.class, self.name, e)
+ end
end
result
end
@@ -70,27 +67,27 @@ def run(result)
@_result = result
begin
begin
- run_callbacks :test do
- begin
- setup
- __send__(@method_name)
- mocha_verify(assertion_counter) if using_mocha
- rescue Mocha::ExpectationError => e
- add_failure(e.message, e.backtrace)
- rescue Test::Unit::AssertionFailedError => e
- add_failure(e.message, e.backtrace)
- rescue Exception => e
- raise if PASSTHROUGH_EXCEPTIONS.include?(e.class)
- add_error(e)
- ensure
- teardown
- end
- end
+ run_callbacks :setup
+ setup
+ __send__(@method_name)
+ mocha_verify(assertion_counter) if using_mocha
+ rescue Mocha::ExpectationError => e
+ add_failure(e.message, e.backtrace)
rescue Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Exception => e
raise if PASSTHROUGH_EXCEPTIONS.include?(e.class)
add_error(e)
+ ensure
+ begin
+ teardown
+ run_callbacks :teardown, :enumerator => :reverse_each
+ rescue Test::Unit::AssertionFailedError => e
+ add_failure(e.message, e.backtrace)
+ rescue Exception => e
+ raise if PASSTHROUGH_EXCEPTIONS.include?(e.class)
+ add_error(e)
+ end
end
ensure
mocha_teardown if using_mocha

0 comments on commit efdc062

Please sign in to comment.