Class Rack::Test::Session
In: lib/rack/test.rb
Parent: Object

Methods

Included Modules

Rack::Test::Utils

Public Class methods

Initialize a new session for the given Rack app

Public Instance methods

authorize(username, password)

Alias for basic_authorize

Set the username and password for HTTP Basic authorization, to be included in subsequent requests in the HTTP_AUTHORIZATION header.

Example:

  basic_authorize "bryan", "secret"

Issue a DELETE request for the given URI. See get

Example:

  delete "/"

Rack::Test will not follow any redirects automatically. This method will follow the redirect returned in the last response. If the last response was not a redirect, an error will be raised.

Issue a GET request for the given URI with the given params and Rack environment. Stores the issues request object in last_request and the app‘s response in last_response. Yield last_response to a block if given.

Example:

  get "/"

Issue a HEAD request for the given URI. See get

Example:

  head "/"

Set a header to be included on all subsequent requests through the session. Use a value of nil to remove a previously configured header.

Example:

  header "User-Agent", "Firefox"

Issue a POST request for the given URI. See get

Example:

  post "/signup", "name" => "Bryan"

Issue a PUT request for the given URI. See get

Example:

  put "/"

Issue a request to the Rack app for the given URI and optional Rack environment. Stores the issues request object in last_request and the app‘s response in last_response. Yield last_response to a block if given.

Example:

  request "/"

[Validate]