1
Rails 3似乎忽略了我的rescue_from处理程序,所以我无法在下面测试我的重定向。如何测试Rails rescue_from?
class ApplicationController < ActionController::Base
rescue_from ActionController::RoutingError, :with => :rescue_404
def rescue_404
flash[:notice] = "Error 404. The url <i>'#{env["vidibus-routing_error.request_uri"]}'</i> does not exist on this website."
redirect_to root_path
end
end
在功能和集成测试,这rescue_from被忽略,并引发错误:
ActionController::RoutingError: No route matches "/non_existent_url"
test/integration/custom_404_test.rb:5:in `test_404'
我怎样才能确保在测试,这是正确的“抓”?