diff options
author | Azul <azul@riseup.net> | 2016-09-20 09:14:43 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-09-21 12:48:06 +0200 |
commit | dd71240fe4f4f968b9b687917cb6d7ad5812ba48 (patch) | |
tree | da0e5718dddba4f435e0ab8f7c596c438ffab403 /test/unit | |
parent | a1c7d68b05f142322a190b450971d27c076310a9 (diff) |
rescue and track exceptions in handler chain
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/handler_chain_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unit/handler_chain_test.rb b/test/unit/handler_chain_test.rb index 067f11e..fae0418 100644 --- a/test/unit/handler_chain_test.rb +++ b/test/unit/handler_chain_test.rb @@ -23,6 +23,26 @@ class HandlerChainTest < Minitest::Test assert_equal :result, chain.handle end + def test_raise_exception + chain handler_raising, handler_with_result + assert_raises RuntimeError do + chain.handle + end + end + + def test_continue_on_exception + chain handler_raising, handler_with_result + chain.continue_on(RuntimeError) + assert_equal :result, chain.handle + assert_equal [RuntimeError], chain.rescued_exceptions.map(&:class) + end + + def test_continue_on_exception_with_nil + chain handler_raising, handler_with_nil + chain.continue_on(RuntimeError) + assert_nil chain.handle + assert_equal [RuntimeError], chain.rescued_exceptions.map(&:class) + end protected @@ -42,4 +62,7 @@ class HandlerChainTest < Minitest::Test Proc.new { :result } end + def handler_raising(exception = RuntimeError) + Proc.new { raise exception } + end end |