Rack::Test is a layer on top of Rack's MockRequest similar to Merb's RequestHelper
Pull request Compare This branch is 36 commits behind brynary:master.
Latest commit cab8eb9 Jan 24, 2012 @noahd1 noahd1 committed with brynary pending spec to demonstrate how cookie jar does not comply to the coo…
…kie spec

Relevant spec is RFC 2109, section 4.3.1: Interpreting Set-Cookie:

"Path: Defaults to the path of the request URL that generated the
Set-Cookie response, up to, but not including, the right-most /."

Rack/test strips the entire final component of the URL instead of just
the right-most "/".
Permalink
Failed to load latest commit information.
lib/rack
spec
.document
.gitignore
Gemfile
Gemfile.lock
History.txt Adds support for PATCH method Jan 9, 2012
MIT-LICENSE.txt Readme Mar 3, 2009
README.rdoc
Rakefile
Thorfile Use a simple Thorfile for release (to Gemcutter) instead of Jeweler Oct 27, 2009
rack-test.gemspec

README.rdoc

Rack::Test

Description

Rack::Test is a small, simple testing API for Rack apps. It can be used on its own or as a reusable starting point for Web frameworks and testing libraries to build on. Most of its initial functionality is an extraction of Merb 1.0's request helpers feature.

Features

  • Maintains a cookie jar across requests

  • Easily follow redirects when desired

  • Set request headers to be used by all subsequent requests

  • Small footprint. Approximately 200 LOC

Example

require "rack/test"

class HomepageTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    MyApp.new
  end

  def test_redirect_logged_in_users_to_dashboard
    authorize "bryan", "secret"
    get "/"
    follow_redirect!

    assert_equal "http://example.org/redirected", last_request.url
    assert last_response.ok?
  end

end

Install

To install the latest release as a gem:

sudo gem install rack-test

Or via Bundler:

gem "rack-test", require: "rack/test"

Authors

  • Maintained by Bryan Helmkamp

  • Contributions from Simon Rozet and Pat Nakajima

  • Much of the original code was extracted from Merb 1.0's request helper

License

Copyright © 2008-2009 Bryan Helmkamp, Engine Yard Inc. See MIT-LICENSE.txt in this directory.