- Inheritance
- < Object
- Included Modules
- Test::Unit::Assertions, ActionController::TestCase::Assertions, ActionController::TestProcess
An integration Session instance represents a set of requests and responses performed sequentially by some virtual user. Becase you can instantiate multiple sessions and run them side-by-side, you can also mimic (to some limited extent) multiple simultaneous users interacting with your system.
Typically, you will instantiate a new session using IntegrationTest#open_session, rather than instantiating Integration::Session directly.
Classes & Modules
Attributes
Name | Visibility | R/W | Description |
---|---|---|---|
accept | public | RW | The Accept header to send. |
application | public | RW | Rack application to use |
body | public | R | The body of the last request. |
controller | public | R | A reference to the controller instance used by the last request. |
cookies | public | R | A map of the cookies returned by the last response, and which will be sent with the next request. |
headers | public | R | A map of the headers returned by the last response. |
host | public | RW | The hostname used in the last request. |
path | public | R | The URI of the last request. |
remote_addr | public | RW | The remote_addr used in the last request. |
request | public | R | A reference to the request instance used by the last request. |
request_count | public | RW | A running counter of the number of requests processed. |
response | public | R | A reference to the response instance used by the last request. |
status | public | R | The integer HTTP status code of the last request. |
status_message | public | R | The status message that accompanied the status code of the last request. |
Methods
Class
Visibility | Signature |
---|---|
public | new (app = nil) |
Instance
Visibility | Signature |
---|---|
public | delete (path, parameters = nil, headers = nil) |
public | delete_via_redirect (path, parameters = nil, headers = nil) |
public | follow_redirect! () |
public | get (path, parameters = nil, headers = nil) |
public | get_via_redirect (path, parameters = nil, headers = nil) |
public | head (path, parameters = nil, headers = nil) |
public | host! (name) |
public | https! (flag = true) |
public | https? () |
public | post (path, parameters = nil, headers = nil) |
public | post_via_redirect (path, parameters = nil, headers = nil) |
public | put (path, parameters = nil, headers = nil) |
public | put_via_redirect (path, parameters = nil, headers = nil) |
public | redirect? () |
public | request_via_redirect (http_method, path, parameters = nil, headers = nil) |
public | reset! () |
public | url_for (options) |
public | xhr (request_method, path, parameters = nil, headers = nil) |
public | xml_http_request (request_method, path, parameters = nil, headers = nil) |
Class Method Detail
new(app = nil)
Instance Method Detail
delete(path, parameters = nil, headers = nil)
Performs a DELETE request with the given parameters. See get() for more details.
delete_via_redirect(path, parameters = nil, headers = nil)
Performs a DELETE request, following any subsequent redirect. See request_via_redirect for more information.
follow_redirect!()
Follow a single redirect response. If the last response was not a redirect, an exception will be raised. Otherwise, the redirect is performed on the location header.
get(path, parameters = nil, headers = nil)
Performs a GET request with the given parameters.
- path: The URI (as a String) on which you want to perform a GET request.
- parameters: The HTTP parameters that you want to pass. This may be nil, a Hash, or a String that is appropriately encoded (application/x-www-form-urlencoded or multipart/form-data).
- headers: Additional HTTP headers to pass, as a Hash. The keys will automatically be upcased, with the prefix ‘HTTP_’ added if needed.
This method returns an Response object, which one can use to inspect the details of the response. Furthermore, if this method was called from an ActionController::IntegrationTest object, then that object‘s @response instance variable will point to the same response object.
You can also perform POST, PUT, DELETE, and HEAD requests with post, put, delete, and head.
get_via_redirect(path, parameters = nil, headers = nil)
Performs a GET request, following any subsequent redirect. See request_via_redirect for more information.
head(path, parameters = nil, headers = nil)
Performs a HEAD request with the given parameters. See get() for more details.
host!(name)
Set the host name to use in the next request.
session.host! "www.example.com"
https!(flag = true)
Specify whether or not the session should mimic a secure HTTPS request.
session.https! session.https!(false)
https?()
Return true if the session is mimicking a secure HTTPS request.
if session.https? ... end
post(path, parameters = nil, headers = nil)
Performs a POST request with the given parameters. See get() for more details.
post_via_redirect(path, parameters = nil, headers = nil)
Performs a POST request, following any subsequent redirect. See request_via_redirect for more information.
put(path, parameters = nil, headers = nil)
Performs a PUT request with the given parameters. See get() for more details.
put_via_redirect(path, parameters = nil, headers = nil)
Performs a PUT request, following any subsequent redirect. See request_via_redirect for more information.
redirect?()
Returns true if the last response was a redirect.
request_via_redirect(http_method, path, parameters = nil, headers = nil)
Performs a request using the specified method, following any subsequent redirect. Note that the redirects are followed until the response is not a redirect—this means you may run into an infinite loop if your redirect loops back to itself.
reset!()
Resets the instance. This can be used to reset the state information in an existing session instance, so it can be used from a clean-slate condition.
session.reset!
url_for(options)
Returns the URL for the given options, according to the rules specified in the application‘s routes.
xhr(request_method, path, parameters = nil, headers = nil)
Alias for xml_http_request
xml_http_request(request_method, path, parameters = nil, headers = nil)
Performs an XMLHttpRequest request with the given parameters, mirroring a request from the Prototype library.
The request_method is :get, :post, :put, :delete or :head; the parameters are nil, a hash, or a url-encoded or multipart string; the headers are a hash. Keys are automatically upcased and prefixed with ‘HTTP_’ if not already.