ActionController::TestCase::RaiseActionExceptions

module ActionController::TestCase::RaiseActionExceptions

When the request.remote_addr remains the default for testing, which is 0.0.0.0, the exception is simply raised inline (skipping the regular exception handling from rescue_action). If the request.remote_addr is anything else, the regular rescue_action process takes place. This means you can test your rescue_action code by setting remote_addr to something else than 0.0.0.0.

The exception is stored in the exception accessor for further inspection.

Protected Instance Methods

rescue_action_without_handler(e) Show source
Calls superclass method
# File actionpack/lib/action_controller/test_case.rb, line 704
def rescue_action_without_handler(e)
  self.exception = e

  if request.remote_addr == "0.0.0.0"
    raise(e)
  else
    super(e)
  end
end

© 2004–2016 David Heinemeier Hansson
Licensed under the MIT License.

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部