class ActionDispatch::Integration::Session
def process(method, path, parameters = nil, rack_environment = nil)
def process(method, path, parameters = nil, rack_environment = nil) if path =~ %r{://} location = URI.parse(path) https! URI::HTTPS === location if location.scheme host! location.host if location.host path = location.query ? "#{location.path}?#{location.query}" : location.path end unless ActionController::Base < ActionController::Testing ActionController::Base.class_eval do include ActionController::Testing end end env = { :method => method, :params => parameters, "SERVER_NAME" => host.split(':')[0], "SERVER_PORT" => (https? ? "443" : "80"), "HTTPS" => https? ? "on" : "off", "rack.url_scheme" => https? ? "https" : "http", "REQUEST_URI" => path, "HTTP_HOST" => host, "REMOTE_ADDR" => remote_addr, "CONTENT_TYPE" => "application/x-www-form-urlencoded", "HTTP_ACCEPT" => accept } session = Rack::Test::Session.new(_mock_session) (rack_environment || {}).each do |key, value| env[key] = value end # NOTE: rack-test v0.5 doesn't build a default uri correctly # Make sure requested path is always a full uri uri = URI.parse('/') uri.scheme ||= env['rack.url_scheme'] uri.host ||= env['SERVER_NAME'] uri.port ||= env['SERVER_PORT'].try(:to_i) uri += path session.request(uri.to_s, env) @request_count += 1 @request = ActionDispatch::Request.new(session.last_request.env) response = _mock_session.last_response @response = ActionDispatch::TestResponse.new(response.status, response.headers, response.body) @html_document = nil @controller = session.last_request.env['action_controller.instance'] return response.status end