1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

strengthening the test suite for rescue_from

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Neeraj Singh 2010-07-26 09:41:53 -04:00 committed by José Valim
parent a5bb1f511f
commit 78c8242d2f

View file

@ -9,6 +9,9 @@ end
class MadRonon < StandardError
end
class CoolError < StandardError
end
class Stargate
attr_accessor :result
@ -54,9 +57,23 @@ class Stargate
end
class CoolStargate < Stargate
attr_accessor :result
include ActiveSupport::Rescuable
rescue_from CoolError, :with => :sos_cool_error
def sos_cool_error
@result = 'sos_cool_error'
end
end
class RescueableTest < Test::Unit::TestCase
def setup
@stargate = Stargate.new
@cool_stargate = CoolStargate.new
end
def test_rescue_from_with_method
@ -80,4 +97,10 @@ class RescueableTest < Test::Unit::TestCase
assert_equal expected, result
end
def test_children_should_inherit_rescue_defintions_from_parents_and_child_rescue_should_be_appended
expected = ["WraithAttack", "WraithAttack", "NuclearExplosion", "MadRonon", "CoolError"]
result = @cool_stargate.send(:rescue_handlers).collect {|e| e.first}
assert_equal expected, result
end
end