A summary of data about the Ruby ecosystem.

https://github.com/rack/rack-test

Rack::Test is a small, simple testing API for Rack apps.
https://github.com/rack/rack-test

Keywords

ruby testing

Keywords from Contributors

activerecord activejob mvc rack rubygems sinatra crash-reporting ruby-gem rspec static-code-analysis

Last synced: about 3 hours ago
JSON representation

Repository metadata

Rack::Test is a small, simple testing API for Rack apps.

README.md

Rack::Test

Gem Version

Code: https://github.com/rack/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.

Features

  • Allows for submitting requests and testing responses
  • Maintains a cookie jar across requests
  • Supports request headers used for subsequent requests
  • Follow redirects when requested

Examples

These examples use test/unit but it's equally possible to use rack-test with
other testing frameworks such as minitest or rspec.

require "test/unit"
require "rack/test"
require "json"

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

  def app
    lambda { |env| [200, {'content-type' => 'text/plain'}, ['All responses are OK']] }
  end

  def test_response_is_ok
    # Optionally set headers used for all requests in this spec:
    #header 'accept-charset', 'utf-8'

    # First argument is treated as the path
    get '/'

    assert last_response.ok?
    assert_equal 'All responses are OK', last_response.body
  end

  def delete_with_url_params_and_body
    # First argument can have a query string
    #
    # Second argument is used as the parameters for the request, which will be
    # included in the request body for non-GET requests.
    delete '/?foo=bar', JSON.generate('baz' => 'zot')
  end

  def post_with_json
    # Third argument is the rack environment to use for the request.  The following
    # entries in the submitted rack environment are treated specially (in addition
    # to options supported by `Rack::MockRequest#env_for`:
    #
    # :cookie : Set a cookie for the current session before submitting the request.
    #
    # :query_params : Set parameters for the query string (as opposed to the body).
    #                 Value should be a hash of parameters.
    #
    # :xhr : Set HTTP_X_REQUESTED_WITH env key to XMLHttpRequest.
    post(uri, JSON.generate('baz' => 'zot'), 'CONTENT_TYPE' => 'application/json')
  end
end

rack-test will test the app returned by the app method. If you are loading middleware
in a config.ru file, and want to test that, you should load the Rack app created from
the config.ru file:

OUTER_APP = Rack::Builder.parse_file("config.ru").first

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

  def app
    OUTER_APP
  end

  def test_root
    get "/"
    assert last_response.ok?
  end
end

If your application does not automatically use the Rack::Lint middleware in test mode,
and you want to test that requests to and responses from your application are compliant
with the Rack specification, you should manually use the Rack::Lint middleware:

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

  APP = Rack::Lint.new(YOUR_APP)

  def app
    APP
  end
end

Install

To install the latest release as a gem:

gem install rack-test

Or add to your Gemfile:

gem 'rack-test'

Contribution

Contributions are welcome. Please make sure to:

  • Use a regular forking workflow
  • Write tests for the new or changed behaviour
  • Provide an explanation/motivation in your commit message / PR message
  • Ensure History.md is updated

Authors

  • Contributions from Bryan Helmkamp, Jeremy Evans, Simon Rozet, and others
  • Much of the original code was extracted from Merb 1.0's request helper

License

rack-test is released under the MIT License.

Supported platforms

  • Ruby 2.0+
  • JRuby 9.1+

Releasing

  • Bump VERSION in lib/rack/test/version.rb
  • Ensure History.md is up-to-date, including correct version and date
  • git commit . -m 'Release $VERSION'
  • git push
  • git tag -a -m 'Tag the $VERSION release' $VERSION
  • git push --tags
  • gem build rack-test.gemspec
  • gem push rack-test-$VERSION.gem
  • Add a discussion post for the release

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 2 days ago

Total Commits: 522
Total Committers: 89
Avg Commits per committer: 5.865
Development Distribution Score (DDS): 0.596

Commits in past year: 8
Committers in past year: 3
Avg Commits per committer in past year: 2.667
Development Distribution Score (DDS) in past year: 0.375

Name Email Commits
Bryan Helmkamp b****n@b****m 211
Jeremy Evans c****e@j****t 110
Simon Rozet s****n@r****e 35
Jun Aruga j****a 22
Per Lundberg p****g@e****m 20
Dennis Sivia d****a@m****e 9
Dennis Sivia s****s 6
Joshua Peek j****h@j****m 5
Murray Steele m****z@h****m 4
Alan Kennedy a****0@g****m 4
Darío Javier Cravero d****o@q****r 4
Paul (Pololu) d****l@p****m 3
Pat Nakajima p****a@g****m 3
Adam Tanner a****m@a****g 2
Krekoten' Marjan k****n@g****m 2
Samuel Williams s****s@o****z 2
Ryunosuke Sato t****s@g****m 2
Chris Waters c****s@s****m 2
Istvan Hoka i****a@g****m 2
Jon Dufresne j****e@g****m 2
Josef Šimánek j****k@g****m 2
Michael Fellinger m****r@g****m 2
Larry Diehl l****y@l****) 2
Guillaume Malette g****e@s****m 1
Geoff Buesing g****g@g****m 1
Edouard Chin e****n@s****m 1
Drew Goddyn d****n@c****m 1
David Lee d****o@g****m 1
Ben Sales b****s@r****m 1
Ben Fritsch b****e@b****e 1
and 59 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 3 months ago

Total issues: 48
Total pull requests: 78
Average time to close issues: 9 months
Average time to close pull requests: 3 months
Total issue authors: 43
Total pull request authors: 35
Average comments per issue: 4.73
Average comments per pull request: 2.27
Merged pull request: 55
Bot issues: 0
Bot pull requests: 0

Past year issues: 2
Past year pull requests: 9
Past year average time to close issues: 30 minutes
Past year average time to close pull requests: about 24 hours
Past year issue authors: 2
Past year pull request authors: 5
Past year average comments per issue: 1.5
Past year average comments per pull request: 3.0
Past year merged pull request: 5
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/rack/rack-test

Top Issue Authors

  • rocket-turtle (3)
  • junaruga (3)
  • ioquatix (2)
  • sriedel (1)
  • lustickd (1)
  • voxik (1)
  • isimluk (1)
  • arielvalentin (1)
  • matoro (1)
  • HoneyryderChuck (1)
  • grozwalker (1)
  • unikitty37 (1)
  • nicholasrobertm (1)
  • kyori19 (1)
  • mmarinova-mm (1)

Top Pull Request Authors

  • jeremyevans (24)
  • junaruga (5)
  • beanieboi (3)
  • simi (3)
  • tricknotes (3)
  • ioquatix (3)
  • jdufresne (3)
  • djensenius (2)
  • mperham (2)
  • m-nakamura145 (2)
  • gmalette (2)
  • schmijos (2)
  • martinemde (2)
  • schinery (1)
  • jmschp (1)

Top Issue Labels

  • wontfix (3)
  • pinned (3)
  • bug (3)
  • stale (2)
  • pending (1)
  • enhancement (1)

Top Pull Request Labels

  • pinned (1)

Package metadata

gem.coop: rack-test

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.

  • Homepage: https://github.com/rack/rack-test
  • Documentation: http://www.rubydoc.info/gems/rack-test/
  • Licenses: MIT
  • Latest release: 2.2.0 (published about 1 year ago)
  • Last Synced: 2026-01-17T23:09:43.401Z (about 6 hours ago)
  • Versions: 29
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 729,186,701 Total
  • Docker Downloads: 1,219,362,469
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Downloads: 0.019%
    • Average: 0.023%
    • Docker downloads count: 0.074%
  • Maintainers (2)
rubygems.org: rack-test

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.

  • Homepage: https://github.com/rack/rack-test
  • Documentation: http://www.rubydoc.info/gems/rack-test/
  • Licenses: MIT
  • Latest release: 2.2.0 (published about 1 year ago)
  • Last Synced: 2026-01-17T02:37:33.377Z (1 day ago)
  • Versions: 29
  • Dependent Packages: 2,952
  • Dependent Repositories: 960,135
  • Downloads: 729,097,884 Total
  • Docker Downloads: 1,219,362,469
  • Rankings:
    • Dependent repos count: 0.007%
    • Dependent packages count: 0.02%
    • Downloads: 0.02%
    • Docker downloads count: 0.106%
    • Average: 0.623%
    • Forks count: 1.618%
    • Stargazers count: 1.964%
  • Maintainers (2)
proxy.golang.org: github.com/rack/rack-test

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/rack/rack-test#section-documentation
  • Licenses: mit
  • Latest release: v2.2.0+incompatible (published about 1 year ago)
  • Last Synced: 2026-01-16T11:07:39.734Z (2 days ago)
  • Versions: 29
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.442%
    • Average: 5.624%
    • Dependent repos count: 5.807%

Dependencies

Gemfile rubygems
  • rack >= 0
  • rack ~> 2.0
rack-test.gemspec rubygems
  • minitest >= 5.0 development
  • minitest-global_expectations >= 0 development
  • rake >= 0 development
  • rack >= 1.3
.github/workflows/ci.yml actions
  • actions/checkout v2 composite
  • ruby/setup-ruby v1 composite

Score: 33.41610966850123