У меня есть блок кода вроде этого:
def some_method
begin
do_some_stuff
rescue WWW::Mechanize::ResponseCodeError => e
if e.response_code.to_i == 503
handle_the_situation
end
end
end
Я хочу проверить, что происходит в этом разделе if e.response_code.to_i == 503
. Я могу высмеять do_some_stuff, чтобы выбросить правильный тип исключения:
whatever.should_receive(:do_some_stuff).and_raise(WWW::Mechanize::ResponseCodeError)
но как мне высмеять сам объект ошибки, чтобы вернуть 503, когда он получает "response_code"?