0
我试图通过使用从this website下载的代码来学习ruby。这里应该等于什么?
我被困在这一点。
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
# makes 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(/__/, ex.message)
end
末
我应该用错误消息的一部分,以取代__,但我都没有成功。好吧,我是,因为经过几次尝试,我用一个空格替换了它,因为我发现错误消息在单词之间有空格。但是我怎么看这个错误信息呢?
就在您的例子并在我的控制台NoMethodError工作。你可以发布错误消息吗? – alony 2012-03-10 17:51:58
我认为我发布我的问题时犯了一个错误,所以我更新了它。 – 2012-03-10 19:55:37