Using this Railscast episode, ActiveRecord::RecordNotFound
errors ultimately redirect to the ErrorsController and the /app/views/errors/404.html.erb view. However, I have the following in one of my tests (Item belongs_to List):
scenario "item cannot be created without a list" do
visit new_item_path
# Because it's not the proper nested new_list_item_path(@some_list) path,
# @list is not created in the ItemsController.
page.should have_content('Not Found')
page.status_code.should be 404
end
However, the test fails with the following:
Failure/Error: visit new_item_path
ActiveRecord::RecordNotFound:
Couldn't find List without an ID
So the controller is working properly in requiring a list, but the test fails because it doesn't take into account the custom exception handling which should send the user to the 404.
How can I properly test for the redirect?