Methods
D
F
G
H
P
R
X
Instance Public methods
delete(path, parameters = nil, headers = nil)

Performs a DELETE request with the given parameters. See get for more details.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 50
50:       def delete(path, parameters = nil, headers = nil)
51:         process :delete, path, parameters, headers
52:       end
delete_via_redirect(path, parameters = nil, headers = nil)

Performs a DELETE request, following any subsequent redirect. See request_via_redirect for more information.

     # File actionpack/lib/action_dispatch/testing/integration.rb, line 114
114:       def delete_via_redirect(path, parameters = nil, headers = nil)
115:         request_via_redirect(:delete, path, parameters, headers)
116:       end
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.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 78
78:       def follow_redirect!
79:         raise "not a redirect! #{status} #{status_message}" unless redirect?
80:         get(response.location)
81:         status
82:       end
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 ActionDispatch::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.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 32
32:       def get(path, parameters = nil, headers = nil)
33:         process :get, path, parameters, headers
34:       end
get_via_redirect(path, parameters = nil, headers = nil)

Performs a GET request, following any subsequent redirect. See request_via_redirect for more information.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 96
96:       def get_via_redirect(path, parameters = nil, headers = nil)
97:         request_via_redirect(:get, path, parameters, headers)
98:       end
head(path, parameters = nil, headers = nil)

Performs a HEAD request with the given parameters. See get for more details.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 56
56:       def head(path, parameters = nil, headers = nil)
57:         process :head, path, parameters, headers
58:       end
post(path, parameters = nil, headers = nil)

Performs a POST request with the given parameters. See get for more details.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 38
38:       def post(path, parameters = nil, headers = nil)
39:         process :post, path, parameters, headers
40:       end
post_via_redirect(path, parameters = nil, headers = nil)

Performs a POST request, following any subsequent redirect. See request_via_redirect for more information.

     # File actionpack/lib/action_dispatch/testing/integration.rb, line 102
102:       def post_via_redirect(path, parameters = nil, headers = nil)
103:         request_via_redirect(:post, path, parameters, headers)
104:       end
put(path, parameters = nil, headers = nil)

Performs a PUT request with the given parameters. See get for more details.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 44
44:       def put(path, parameters = nil, headers = nil)
45:         process :put, path, parameters, headers
46:       end
put_via_redirect(path, parameters = nil, headers = nil)

Performs a PUT request, following any subsequent redirect. See request_via_redirect for more information.

     # File actionpack/lib/action_dispatch/testing/integration.rb, line 108
108:       def put_via_redirect(path, parameters = nil, headers = nil)
109:         request_via_redirect(:put, path, parameters, headers)
110:       end
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.

    # File actionpack/lib/action_dispatch/testing/integration.rb, line 88
88:       def request_via_redirect(http_method, path, parameters = nil, headers = nil)
89:         process(http_method, path, parameters, headers)
90:         follow_redirect! while redirect?
91:         status
92:       end
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.

This method is also aliased as xhr
    # File actionpack/lib/action_dispatch/testing/integration.rb, line 67
67:       def xml_http_request(request_method, path, parameters = nil, headers = nil)
68:         headers ||= {}
69:         headers['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
70:         headers['HTTP_ACCEPT'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ')
71:         process(request_method, path, parameters, headers)
72:       end