diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-07-26 09:41:53 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-26 16:48:50 +0200 |
commit | 78c8242d2f92bccc4caedc235b8cfbcfcb3650cf (patch) | |
tree | 7d6df3dc76ae977e2290afe96571571a1c520ac4 /activesupport | |
parent | a5bb1f511f6d4ea63360eefe8c3850f9bbb7505a (diff) | |
download | rails-78c8242d2f92bccc4caedc235b8cfbcfcb3650cf.tar.gz rails-78c8242d2f92bccc4caedc235b8cfbcfcb3650cf.tar.bz2 rails-78c8242d2f92bccc4caedc235b8cfbcfcb3650cf.zip |
strengthening the test suite for rescue_from
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/rescuable_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/test/rescuable_test.rb b/activesupport/test/rescuable_test.rb index 8d2577c64a..1c74ce8b2a 100644 --- a/activesupport/test/rescuable_test.rb +++ b/activesupport/test/rescuable_test.rb @@ -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 |