module ActionController::TestCase::Behavior

def setup_controller_request_and_response

def setup_controller_request_and_response
  @controller = nil unless defined? @controller
  @response_klass = ActionDispatch::TestResponse
  if klass = self.class.controller_class
    if klass < ActionController::Live
      @response_klass = LiveTestResponse
    end
    unless @controller
      begin
        @controller = klass.new
      rescue
        warn "could not construct controller #{klass}" if $VERBOSE
      end
    end
  end
  @request          = TestRequest.create(@controller.class)
  @response         = build_response @response_klass
  @response.request = @request
  if @controller
    @controller.request = @request
    @controller.params = {}
  end
end