aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-10-14 16:12:09 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-10-14 16:12:57 -0700
commitefdc06245470fa7caf2a14f2cb59e8bf8c76de5e (patch)
tree4ec995be24d49c299c8d1dbe7f8728ad04717f48 /activesupport
parentd5d242660c6f772548366cf2440b70d2ceca8b46 (diff)
downloadrails-efdc06245470fa7caf2a14f2cb59e8bf8c76de5e.tar.gz
rails-efdc06245470fa7caf2a14f2cb59e8bf8c76de5e.tar.bz2
rails-efdc06245470fa7caf2a14f2cb59e8bf8c76de5e.zip
Revert "Rewrite AS::TestCase setup/teardown as a single callback chain"
This reverts commit 610e94c097fcc41aaf11bf5ddd45898718aeeb55.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/testing/setup_and_teardown.rb57
1 files changed, 27 insertions, 30 deletions
diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb
index b738ef334c..97773dc2c0 100644
--- a/activesupport/lib/active_support/testing/setup_and_teardown.rb
+++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -6,7 +6,7 @@ module ActiveSupport
extend ClassMethods
include ActiveSupport::Callbacks
- define_callbacks :test
+ define_callbacks :setup, :teardown
if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions
include ForMiniTest
@@ -18,15 +18,11 @@ module ActiveSupport
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
@@ -34,15 +30,16 @@ module ActiveSupport
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 @@ module ActiveSupport
@_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