提交 78c8242d 编写于 作者: N Neeraj Singh 提交者: José Valim

strengthening the test suite for rescue_from

Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 a5bb1f51
......@@ -9,6 +9,9 @@ class NuclearExplosion < StandardError
class MadRonon < StandardError
end
class CoolError < StandardError
end
class Stargate
attr_accessor :result
......@@ -54,9 +57,23 @@ def sos_first
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 @@ def test_rescues_defined_later_are_added_at_end_of_the_rescue_handlers_array
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册