Class: Rack::Test::Session

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

### Methods

authorize basic_authorize delete digest_authorize follow_redirect! get head header new post put request

### Included Modules

Rack::Test::Utils

### Public Class methods

new(app, default_host = DEFAULT_HOST)

Initialize a new session for the given Rack app

### Public Instance methods

authorize(username, password)

Alias for basic_authorize

basic_authorize(username, password)

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"

delete(uri, params = {}, env = {}, &block)

Issue a DELETE request for the given URI. See get

Example:

      delete "/"

digest_authorize(username, password)
follow_redirect!()

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.

get(uri, params = {}, env = {}, &block)

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 "/"

head(uri, params = {}, env = {}, &block)

Issue a HEAD request for the given URI. See get

Example:

      head "/"

header(name, value)

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"

post(uri, params = {}, env = {}, &block)

Issue a POST request for the given URI. See get

Example:

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

put(uri, params = {}, env = {}, &block)

Issue a PUT request for the given URI. See get

Example:

      put "/"

request(uri, env = {}, &block)

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]