From 9b5dfb4e4290c1ad34439d7030ca3cb30e97afc3 Mon Sep 17 00:00:00 2001 From: Matt Yoho Date: Tue, 21 Sep 2010 17:12:50 -0400 Subject: [PATCH] Add koan on asserting exceptions --- koans/about_exceptions.rb | 8 ++++++++ src/about_exceptions.rb | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/koans/about_exceptions.rb b/koans/about_exceptions.rb index 33b538a..c44833e 100644 --- a/koans/about_exceptions.rb +++ b/koans/about_exceptions.rb @@ -57,4 +57,12 @@ class AboutExceptions < EdgeCase::Koan assert_equal __, result end + # Sometimes, we must know about the unknown + def test_asserting_an_error_is_raised + # A do-end is a block, a topic to explore more later + assert_raise(___) do + raise MySpecialError.new("New instances can be raised directly.") + end + end + end diff --git a/src/about_exceptions.rb b/src/about_exceptions.rb index e65ed82..2960552 100644 --- a/src/about_exceptions.rb +++ b/src/about_exceptions.rb @@ -57,4 +57,12 @@ class AboutExceptions < EdgeCase::Koan assert_equal __(:always_run), result end + # Sometimes, we must know about the unknown + def test_asserting_an_error_is_raised + # A do-end is a block, a topic to explore more later + assert_raise(___(MySpecialError)) do + raise MySpecialError.new("New instances can be raised directly.") + end + end + end