在我们的rails 2.3应用程序中,我为路由错误设置了一个解救工具,如下所示:
rescue_from ActionController::RoutingError, :with => :redirect_or_render_error
rescue_from ActionController::UnknownController, :with => :redirect_or_render_error
rescue_from ActionController::UnknownAction, :with => :redirect_or_render_error
redirect_or_render_error
方法我重定向某些URL(从数据库中提取,因此不能只使用routes.rb),我想测试一下。我是在索引页的功能测试中做的(这是正确的位置吗?)因此:
@request.remote_addr = '12.34.56.78'
get '/example'
assert_redirected_to '/example_things/123456'
ActionController::RoutingError: No route matches {:action=>"/example", :controller=>"home"}
即使它在发展中起作用。如何测试路由故障的救援功能?