這是test_symbols_cannot_be_concatenated練習中的Ruby Koans。以前的練習使用了assert_equal
測試。這是通往啓蒙之路的第一個assert_raise
。代碼中這個空白的解決方案是什麼?
def test_symbols_cannot_be_concatenated
assert_raise(_____) do
:cats + :dogs
end
end
這是test_symbols_cannot_be_concatenated練習中的Ruby Koans。以前的練習使用了assert_equal
測試。這是通往啓蒙之路的第一個assert_raise
。代碼中這個空白的解決方案是什麼?
def test_symbols_cannot_be_concatenated
assert_raise(_____) do
:cats + :dogs
end
end
NoMethodError
我想,因爲試圖總結或鏈接兩個符號是沒有意義的。
我收到錯誤消息是(換行符增加了可讀性):
[] exception expected, not Class: <NoMethodError>
Message: <"undefined method `+' for :cats:Symbol">
---Backtrace---
/Ruby_on_Rails/koans/about_symbols.rb:89:in
`block in test_symbols_cannot_be_concatenated'
繼我以爲我已經成立了尋找「預期,但」我認爲答案是「格局exception
「。這顯然不起作用,但基於noodl的回答,我意識到對於assert_raise()
,線索是預計將被調用的類,在這種情況下爲< NoMethodError
>。
這似乎是與APIdock文件指示ARG遊戲的每個被評估爲__check_exception_class
請不要張貼答案功課的問題是一致的。相反,發佈提示以幫助OP自己解決問題。 – 2011-02-09 15:20:42