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.
- Host: GitHub
- URL: https://github.com/rack/rack-test
- Owner: rack
- License: mit
- Created: 2009-02-24T02:13:47.000Z (almost 17 years ago)
- Default Branch: main
- Last Pushed: 2025-12-22T00:47:38.000Z (27 days ago)
- Last Synced: 2026-01-11T13:41:37.946Z (7 days ago)
- Topics: ruby, testing
- Language: Ruby
- Homepage:
- Size: 602 KB
- Stars: 937
- Watchers: 26
- Forks: 244
- 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
- Issues event: 4
- Watch event: 20
- Issue comment event: 21
- Push event: 7
- Pull request review event: 13
- Pull request review comment event: 9
- Pull request event: 6
- Fork event: 2
- Create event: 1
Last Year
- Issues event: 4
- Watch event: 15
- Issue comment event: 16
- Push event: 4
- Pull request review comment event: 5
- Pull request review event: 8
- Pull request event: 3
- Fork event: 1
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 | 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:
- shopify.com: 3
- econsultancy.com: 1
- speedy.(none): 1
- maisweb.org: 1
- dartmouth.edu: 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
- igels.net: 1
- jaredbeck.com: 1
- trms.com: 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
- heilmannsoftware.de: 1
- ad-signal.io: 1
- professionalnerd.com: 1
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
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
- Total packages: 3
-
Total downloads:
- rubygems: 1,458,284,585 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: 87
- Total maintainers: 2
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
- 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.41610966850123