Forum: RSpec RSpec2 error codes testing

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Robert L. (Guest)
on 2013-07-20 16:20
I have an issue with testing error codes. If a record is not found, it
raises exception ActiveRecord::RecordNotFound. The thing is, I wanna
check if 404 is returned. If I go ahead and just check :

 response.status.should == 404

Then this will make the test case fail as RecordNotFound exception is
thrown and not caught. If I go ahead and say

expect {<call controller action>}.to

and then check for the status code, then it will fail again, as this
catches the exception and the response code is 200.

How should I test if 404 is returned in this kind of case ?
This topic is locked and can not be replied to.