Class: Merb::Test::RequestHelper::FakeRequest
- Defined in:
- lib/merb-core/test/helpers/mock_request_helper.rb
Overview
FakeRequest sets up a default enviroment which can be overridden either by passing and env into initialize or using request = ‘foo’
Constant Summary collapse
- DEFAULT_ENV =
Mash.new({ 'SERVER_NAME' => 'localhost', 'PATH_INFO' => '/', 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060214 Camino/1.0', 'SCRIPT_NAME' => '/', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'HTTP_CACHE_CONTROL' => 'max-age=0', 'HTTP_ACCEPT_LANGUAGE' => 'en,ja;q=0.9,fr;q=0.9,de;q=0.8,es;q=0.7,it;q=0.7,nl;q=0.6,sv;q=0.5,nb;q=0.5,da;q=0.4,fi;q=0.3,pt;q=0.3,zh-Hans;q=0.2,zh-Hant;q=0.1,ko;q=0.1', 'HTTP_HOST' => 'localhost', 'REMOTE_ADDR' => '127.0.0.1', 'SERVER_SOFTWARE' => 'Mongrel 1.1', 'HTTP_KEEP_ALIVE' => '300', 'HTTP_REFERER' => 'http://localhost/', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_VERSION' => 'HTTP/1.1', 'REQUEST_URI' => '/', 'SERVER_PORT' => '80', 'GATEWAY_INTERFACE' => 'CGI/1.2', 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_CONNECTION' => 'keep-alive', 'REQUEST_METHOD' => 'GET' })
Constants inherited from Request
Constants included from ControllerExceptions
ControllerExceptions::STATUS_CODES
Instance Attribute Summary
Attributes inherited from Request
#env, #route, #route_params, #start
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(env = {}, req = StringIO.new) ⇒ FakeRequest
constructor
Parameters env<Hash>:: Environment options that override the defaults.
Methods inherited from Request
#_process_block_return, #accept, #accept_charset, #accept_encoding, #accept_language, #cache_control, #connection, #content_length, #content_type, #controller, #domain, #exceptions, #find_route!, #full_uri, #gateway, #handle, #handled?, #host, #if_modified_since, #if_none_match, #keep_alive, #matched!, #matched?, #message, #method, #params, #path, #path_info, #port, #protocol, #query_string, #rack_response, #raw_post, #referer, #remote_ip, #reset_params!, #script_name, #server_name, #server_software, #ssl?, #subdomains, #uri, #user_agent, #version, #xml_http_request?
Constructor Details
#initialize(env = {}, req = StringIO.new) ⇒ FakeRequest
Parameters
- env<Hash>
-
Environment options that override the defaults.
- req<StringIO>
-
The request to set as input for Rack.
13 14 15 16 17 18 |
# File 'lib/merb-core/test/helpers/mock_request_helper.rb', line 13 def initialize(env = {}, req = StringIO.new) env.environmentize_keys! env['rack.input'] = req @start = Time.now super(DEFAULT_ENV.merge(env)) end |
Class Method Details
.new(env = {}, req = StringIO.new) ⇒ Object
20 21 22 |
# File 'lib/merb-core/test/helpers/mock_request_helper.rb', line 20 def self.new(env = {}, req = StringIO.new) super end |