Help with Ruby Koans #6 - What exception has been caught?
I had to put the assert_equal statement into parens to get this one to pass. Must be a bug.
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
# What happens when you call a method that doesn't exist. The
# following begin/rescue/end code block captures the exception and
# make some assertions about it.
begin
nil.some_method_nil_doesnt_know_about
rescue Exception => ex
# What exception has been caught?
assert_equal(NoMethodError, ex.class)
# What message was attached to the exception?
# (HINT: replace __ with part of the error message.)
assert_match("undefined method", ex.message)
end
end
You need to substitute __ with the actual
assert_equal NoMethodError, ex.class
The answer here is "NoMethodError"
you need the items on either side of the , to be equal, therefore making them both ex.class will do that.
Then you'll need to go on to /__/ Below.