Module: ActionController::TestCase::RaiseActionExceptions

Defined in:
lib/action_controller/test_case.rb

Overview

When the request.remote_addr remains the default for testing, which is 0.0.0.0, the exception is simply raised inline (bystepping 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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception.



26
27
28
# File 'lib/action_controller/test_case.rb', line 26

def exception
  @exception
end

Instance Method Details

#rescue_action(e) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/action_controller/test_case.rb', line 28

def rescue_action(e)
  self.exception = e
  
  if request.remote_addr == "0.0.0.0"
    raise(e)
  else
    super(e)
  end
end