Skip to content

Commit

Permalink
Followed the hints
Browse files Browse the repository at this point in the history
* In `about_exceptions.rb` I followed the hints and filled in the empty value.

* Modified lines: 9-12, 23, 25-26, 31, 43-44, 57, 63.

[#131336149]
  • Loading branch information
drewesk committed Nov 30, 2016
1 parent 522b449 commit 1556128
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions about_exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class MySpecialError < RuntimeError
end

def test_exceptions_inherit_from_Exception
assert_equal __, MySpecialError.ancestors[1]
assert_equal __, MySpecialError.ancestors[2]
assert_equal __, MySpecialError.ancestors[3]
assert_equal __, MySpecialError.ancestors[4]
assert_equal RuntimeError, MySpecialError.ancestors[1]
assert_equal StandardError, MySpecialError.ancestors[2]
assert_equal Exception, MySpecialError.ancestors[3]
assert_equal Object, MySpecialError.ancestors[4]
end

def test_rescue_clause
Expand All @@ -20,15 +20,15 @@ def test_rescue_clause
result = :exception_handled
end

assert_equal __, result
assert_equal :exception_handled, result

assert_equal __, ex.is_a?(StandardError), "Should be a Standard Error"
assert_equal __, ex.is_a?(RuntimeError), "Should be a Runtime Error"
assert_equal true, ex.is_a?(StandardError), "Should be a Standard Error"
assert_equal true, ex.is_a?(RuntimeError), "Should be a Runtime Error"

assert RuntimeError.ancestors.include?(StandardError),
"RuntimeError is a subclass of StandardError"

assert_equal __, ex.message
assert_equal "Oops", ex.message
end

def test_raising_a_particular_error
Expand All @@ -40,8 +40,8 @@ def test_raising_a_particular_error
result = :exception_handled
end

assert_equal __, result
assert_equal __, ex.message
assert_equal :exception_handled, result
assert_equal "My Message", ex.message
end

def test_ensure_clause
Expand All @@ -54,13 +54,13 @@ def test_ensure_clause
result = :always_run
end

assert_equal __, result
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(___) do
assert_raise(Exception) do
raise MySpecialError.new("New instances can be raised directly.")
end
end
Expand Down

0 comments on commit 1556128

Please sign in to comment.