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 code-formatter
Last synced: about 22 hours ago
JSON representation
Repository metadata
Rack::Test is a small, simple testing API for Rack apps.
- Host: GitHub
- URL: https://github.com/rack/rack-test
- Owner: rack
- License: mit
- Created: 2009-02-24T02:13:47.000Z (over 17 years ago)
- Default Branch: main
- Last Pushed: 2026-09-20T03:58:28.000Z (5 days ago)
- Last Synced: 2026-09-21T19:09:03.370Z (3 days ago)
- Topics: ruby, testing
- Language: Ruby
- Homepage:
- Size: 641 KB
- Stars: 955
- Watchers: 25
- Forks: 245
- Open Issues: 1
- Releases: 6
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: MIT-LICENSE.txt
README.md
Rack::Test
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.mdis 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.mdis up-to-date, including correct version and date git commit . -m 'Release $VERSION'git pushgit tag -a -m 'Tag the $VERSION release' $VERSIONgit push --tagsgem build rack-test.gemspecgem push rack-test-$VERSION.gem- Add a discussion post for the release
Owner metadata
- Name: Official Rack repositories
- Login: rack
- Email:
- Kind: organization
- Description:
- Website: http://rack.github.com
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/42379?v=4
- Repositories: 10
- Last ynced at: 2024-03-25T19:32:49.958Z
- Profile URL: https://github.com/rack
GitHub Events
Total
- Create event: 1
- Fork event: 2
- Issue comment event: 22
- Issues event: 4
- Pull request event: 6
- Pull request review comment event: 9
- Pull request review event: 13
- Push event: 7
- Watch event: 22
Last Year
- Fork event: 1
- Issue comment event: 6
- Pull request event: 1
- Pull request review comment event: 5
- Pull request review event: 8
- Push event: 1
- Watch event: 4
Committers metadata
Last synced: about 23 hours ago
Total Commits: 543
Total Committers: 91
Avg Commits per committer: 5.967
Development Distribution Score (DDS): 0.611
Commits in past year: 24
Committers in past year: 4
Avg Commits per committer in past year: 6.0
Development Distribution Score (DDS) in past year: 0.333
| Name | Commits | |
|---|---|---|
| Bryan Helmkamp | b****n@b****m | 211 |
| Jeremy Evans | c****e@j****t | 125 |
| 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 |
| Oskar Eichler | 6****r | 5 |
| 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 |
| Haruki Kobayashi | k****4@g****m | 1 |
| 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 |
| and 61 more... | ||
Committer domains:
- shopify.com: 3
- trms.com: 1
- econsultancy.com: 1
- speedy.(none): 1
- maisweb.org: 1
- dio.jp: 1
- gmx.de: 1
- benle.de: 1
- reevoo.com: 1
- clio.com: 1
- laptoptheliquid.(none): 1
- oriontransfer.co.nz: 1
- adamtanner.org: 1
- pololu.com: 1
- qinnova.com.ar: 1
- h-lame.com: 1
- joshpeek.com: 1
- metrigo.de: 1
- ecraft.com: 1
- rozet.name: 1
- jeremyevans.net: 1
- brynary.com: 1
- newrelic.com: 1
- perham.net: 1
- mwdesilva.com: 1
- github.com: 1
- mekyle.com: 1
- koenpunt.nl: 1
- renuo.ch: 1
- technicalpickles.com: 1
- dartmouth.edu: 1
- igels.net: 1
- jaredbeck.com: 1
- ad-signal.io: 1
- heilmannsoftware.de: 1
- lxxxvi.ch: 1
- redhat.com: 1
- toshimaru.net: 1
- sheetmusicplus.com: 1
- tjschuck.com: 1
- dosire.com: 1
- railsnewbie.com: 1
- segiddins.me: 1
- professionalnerd.com: 1
Issue and Pull Request metadata
Last synced: 2 days ago
Total issues: 50
Total pull requests: 87
Average time to close issues: 9 months
Average time to close pull requests: 2 months
Total issue authors: 45
Total pull request authors: 37
Average comments per issue: 4.66
Average comments per pull request: 2.16
Merged pull request: 57
Bot issues: 0
Bot pull requests: 0
Past year issues: 2
Past year pull requests: 13
Past year average time to close issues: 2 days
Past year average time to close pull requests: 1 day
Past year issue authors: 2
Past year pull request authors: 4
Past year average comments per issue: 3.0
Past year average comments per pull request: 2.31
Past year merged pull request: 5
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- rocket-turtle (3)
- junaruga (3)
- ioquatix (2)
- sriedel (1)
- lustickd (1)
- voxik (1)
- isimluk (1)
- ahukkanen (1)
- arielvalentin (1)
- matoro (1)
- HoneyryderChuck (1)
- grozwalker (1)
- unikitty37 (1)
- nicholasrobertm (1)
- kyori19 (1)
Top Pull Request Authors
- jeremyevans (24)
- OskarEichler (8)
- junaruga (5)
- tricknotes (3)
- jdufresne (3)
- simi (3)
- ioquatix (3)
- beanieboi (3)
- djensenius (2)
- mperham (2)
- m-nakamura145 (2)
- schmijos (2)
- martinemde (2)
- gmalette (2)
- mshibuya (1)
Top Issue Labels
- bug (3)
- wontfix (3)
- pinned (3)
- stale (2)
- enhancement (1)
- pending (1)
Top Pull Request Labels
- pinned (1)
Package metadata
- Total packages: 12
-
Total downloads:
- rubygems: 1,628,677,182 total
- Total docker downloads: 2,438,724,938
- Total dependent packages: 2,952 (may contain duplicates)
- Total dependent repositories: 960,135 (may contain duplicates)
- Total versions: 96
- Total maintainers: 3
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 almost 2 years ago)
- Last Synced: 2026-09-23T03:33:35.787Z (2 days ago)
- Versions: 29
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 814,338,591 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)
ubuntu-23.10: ruby-rack-test
- Homepage: https://github.com/rack/rack-test
- Licenses: mit
- Latest release: 2.0.2-2 (published 7 months ago)
- Last Synced: 2026-07-28T07:01:02.657Z (about 2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.394%
- Forks count: 0.587%
- Stargazers count: 0.988%
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 almost 2 years ago)
- Last Synced: 2026-09-23T03:33:26.862Z (2 days ago)
- Versions: 29
- Dependent Packages: 2,952
- Dependent Repositories: 960,135
- Downloads: 814,338,591 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 almost 2 years ago)
- Last Synced: 2026-09-22T12:13:18.488Z (3 days ago)
- Versions: 29
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 5.442%
- Average: 5.624%
- Dependent repos count: 5.807%
openbsd-7.9-amd64: www/ruby-rack-test
small, simple testing API for Rack apps
- Homepage: https://github.com/rack/rack-test
- Licenses: mit
- Latest release: 2.1.0 (published 5 months ago)
- Last Synced: 2026-05-28T03:52:46.369Z (4 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
- Maintainers (1)
guix: ruby-rack-test
Testing API for Rack applications
- Homepage: https://github.com/rack/rack-test
- Documentation: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/ruby-xyz.scm#n8361
- Licenses: expat
- Latest release: 2.1.0 (published 7 months ago)
- Last Synced: 2026-04-27T16:19:57.048Z (5 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-rack-test
- Homepage: https://github.com/rack/rack-test
- Status: removed
- Documentation: https://packages.debian.org/bookworm/ruby-rack-test
- Licenses: mit
- Latest release: 2.0.2-2 (published 7 months ago)
- Last Synced: 2026-08-21T23:28:54.990Z (about 1 month ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-24.10: ruby-rack-test
- Homepage: https://github.com/rack/rack-test
- Licenses: mit
- Latest release: 2.1.0-1 (published 8 months ago)
- Last Synced: 2026-03-09T18:22:31.433Z (7 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
gentoo-portage: dev-ruby/rack-test
Rack::Test is a small, simple testing API for Rack apps
- Homepage: https://github.com/rack/rack-test
- Documentation: https://packages.gentoo.org/packages/dev-ruby/rack-test
- Licenses: MIT
- Latest release: 2.2.0 (published 5 months ago)
- Last Synced: 2026-05-27T02:49:07.553Z (4 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-rack-test
- Homepage: https://github.com/rack/rack-test
- Licenses: mit
- Latest release: 2.0.2-2 (published 8 months ago)
- Last Synced: 2026-03-11T15:30:03.108Z (7 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-13: ruby-rack-test
- Homepage: https://github.com/rack/rack-test
- Documentation: https://packages.debian.org/trixie/ruby-rack-test
- Licenses: mit
- Latest release: 2.2.0-1 (published 7 months ago)
- Last Synced: 2026-03-14T18:08:04.497Z (6 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- rack >= 0
- rack ~> 2.0
- minitest >= 5.0 development
- minitest-global_expectations >= 0 development
- rake >= 0 development
- rack >= 1.3
- actions/checkout v2 composite
- ruby/setup-ruby v1 composite
Score: 33.500125405614824