class ActionDispatch::TestRequest

Parent:
ActionDispatch::Request

Constants

DEFAULT_ENV

Public Class Methods

create(env = {}) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 13
def self.create(env = {})
  env = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application
  env["rack.request.cookie_hash"] ||= {}.with_indifferent_access
  new(default_env.merge(env))
end

Create a new test request with default `env` values

Public Instance Methods

accept=(mime_types) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 64
def accept=(mime_types)
  delete_header('action_dispatch.request.accepts')
  set_header('HTTP_ACCEPT', Array(mime_types).collect(&:to_s).join(","))
end
action=(action_name) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 44
def action=(action_name)
  path_parameters[:action] = action_name.to_s
end
host=(host) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 28
def host=(host)
  set_header('HTTP_HOST', host)
end
if_modified_since=(last_modified) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 48
def if_modified_since=(last_modified)
  set_header('HTTP_IF_MODIFIED_SINCE', last_modified)
end
if_none_match=(etag) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 52
def if_none_match=(etag)
  set_header('HTTP_IF_NONE_MATCH', etag)
end
path=(path) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 40
def path=(path)
  set_header('PATH_INFO', path)
end
port=(number) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 32
def port=(number)
  set_header('SERVER_PORT', number.to_i)
end
remote_addr=(addr) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 56
def remote_addr=(addr)
  set_header('REMOTE_ADDR', addr)
end
request_method=(method) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 24
def request_method=(method)
  super(method.to_s.upcase)
end
Calls superclass method
request_uri=(uri) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 36
def request_uri=(uri)
  set_header('REQUEST_URI', uri)
end
user_agent=(user_agent) Show source
# File actionpack/lib/action_dispatch/testing/test_request.rb, line 60
def user_agent=(user_agent)
  set_header('HTTP_USER_AGENT', user_agent)
end

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