diff options
Diffstat (limited to 'test')
-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 |