public
Description: Rack::Test is a layer on top of Rack's MockRequest similar to Merb's RequestHelper
Homepage:
Clone URL: git://github.com/brynary/rack-test.git
brynary (author)
Wed Mar 04 18:51:34 -0800 2009
commit  f79784993ca4c6ff7e0fa4aaca36b47881af2d62
tree    8ad97dc503da178259d9785ef008f695828cd678
parent  8db578d2354169c226763b7533f98a54e811b4a7
name age message
file .document Mon Mar 02 19:45:51 -0800 2009 Readme [brynary]
file .gitignore Mon Mar 02 20:20:15 -0800 2009 Adding rake task for rcov [brynary]
file History.txt Loading commit data...
file MIT-LICENSE.txt Mon Mar 02 19:45:51 -0800 2009 Readme [brynary]
file README.rdoc Mon Mar 02 20:13:43 -0800 2009 Update README to use Rack::Test::Methods [brynary]
file Rakefile
directory lib/
directory spec/
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

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.