Skip to content

Commit

Permalink
Workaround missing Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS in Ru…
Browse files Browse the repository at this point in the history
…by < 1.8.6. [#224 state:resolved]
  • Loading branch information
jeremy committed May 19, 2008
1 parent e6f5079 commit 2b6bec5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions activesupport/lib/active_support/testing/setup_and_teardown.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
module ActiveSupport
module Testing
module SetupAndTeardown
# For compatibility with Ruby < 1.8.6
PASSTHROUGH_EXCEPTIONS =
if defined?(Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS)
Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
else
[NoMemoryError, SignalException, Interrupt, SystemExit]
end

def self.included(base)
base.send :include, ActiveSupport::Callbacks
base.define_callbacks :setup, :teardown
Expand All @@ -25,7 +33,7 @@ def run_with_callbacks(result) #:nodoc:
__send__(@method_name)
rescue Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue *Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
rescue *PASSTHROUGH_EXCEPTIONS
raise
rescue Exception
add_error($!)
Expand All @@ -35,7 +43,7 @@ def run_with_callbacks(result) #:nodoc:
run_callbacks :teardown, :enumerator => :reverse_each
rescue Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue *Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
rescue *PASSTHROUGH_EXCEPTIONS
raise
rescue Exception
add_error($!)
Expand Down

0 comments on commit 2b6bec5

Please sign in to comment.