module Devise::Test::ControllerHelpers

def _catch_warden(&block)

Returns nil when interrupted, otherwise the normal result of the block.
Catch warden continuations and handle like the middleware would.
def _catch_warden(&block)
  result = catch(:warden, &block)
  env = @controller.request.env
  result ||= {}
  # Set the response. In production, the rack result is returned
  # from Warden::Manager#call, which the following is modelled on.
  case result
  when Array
    if result.first == 401 && intercept_401?(env) # does this happen during testing?
      _process_unauthenticated(env)
    else
      result
    end
  when Hash
    _process_unauthenticated(env, result)
  else
    result
  end
end