{"id":13493293,"url":"https://github.com/rack/rack-test","last_synced_at":"2026-04-07T19:31:48.741Z","repository":{"id":508349,"uuid":"135912","full_name":"rack/rack-test","owner":"rack","description":"Rack::Test is a small, simple testing API for Rack apps.","archived":false,"fork":false,"pushed_at":"2025-03-17T21:07:40.000Z","size":628,"stargazers_count":925,"open_issues_count":1,"forks_count":249,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-05-08T17:17:27.732Z","etag":null,"topics":["ruby","testing"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rack.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2009-02-24T02:13:47.000Z","updated_at":"2025-04-13T21:43:29.000Z","dependencies_parsed_at":"2024-06-17T16:30:38.521Z","dependency_job_id":"5a9a5ba4-34cd-4e45-8764-5cfa185296c7","html_url":"https://github.com/rack/rack-test","commit_stats":{"total_commits":513,"total_committers":87,"mean_commits":5.896551724137931,"dds":0.5886939571150098,"last_synced_commit":"20c0646184f256931e7279f683455d46dc002a18"},"previous_names":["brynary/rack-test","rack-test/rack-test"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rack","download_url":"https://codeload.github.com/rack/rack-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253417402,"owners_count":21905232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","testing"],"created_at":"2024-07-31T19:01:13.966Z","updated_at":"2026-04-07T19:31:48.695Z","avatar_url":"https://github.com/rack.png","language":"Ruby","readme":"# Rack::Test\n[![Gem Version](https://badge.fury.io/rb/rack-test.svg)](https://badge.fury.io/rb/rack-test)\n\nCode: https://github.com/rack/rack-test\n\n## Description\n\nRack::Test is a small, simple testing API for Rack apps. It can be used on its\nown or as a reusable starting point for Web frameworks and testing libraries\nto build on.\n\n## Features\n\n* Allows for submitting requests and testing responses\n* Maintains a cookie jar across requests\n* Supports request headers used for subsequent requests\n* Follow redirects when requested\n\n## Examples\n\nThese examples use `test/unit` but it's equally possible to use `rack-test` with\nother testing frameworks such as `minitest` or `rspec`.\n\n```ruby\nrequire \"test/unit\"\nrequire \"rack/test\"\nrequire \"json\"\n\nclass HomepageTest \u003c Test::Unit::TestCase\n  include Rack::Test::Methods\n\n  def app\n    lambda { |env| [200, {'content-type' =\u003e 'text/plain'}, ['All responses are OK']] }\n  end\n\n  def test_response_is_ok\n    # Optionally set headers used for all requests in this spec:\n    #header 'accept-charset', 'utf-8'\n\n    # First argument is treated as the path\n    get '/'\n\n    assert last_response.ok?\n    assert_equal 'All responses are OK', last_response.body\n  end\n\n  def delete_with_url_params_and_body\n    # First argument can have a query string\n    #\n    # Second argument is used as the parameters for the request, which will be\n    # included in the request body for non-GET requests.\n    delete '/?foo=bar', JSON.generate('baz' =\u003e 'zot')\n  end\n\n  def post_with_json\n    # Third argument is the rack environment to use for the request.  The following\n    # entries in the submitted rack environment are treated specially (in addition\n    # to options supported by `Rack::MockRequest#env_for`:\n    #\n    # :cookie : Set a cookie for the current session before submitting the request.\n    #\n    # :query_params : Set parameters for the query string (as opposed to the body).\n    #                 Value should be a hash of parameters.\n    #\n    # :xhr : Set HTTP_X_REQUESTED_WITH env key to XMLHttpRequest.\n    post(uri, JSON.generate('baz' =\u003e 'zot'), 'CONTENT_TYPE' =\u003e 'application/json')\n  end\nend\n```\n\n`rack-test` will test the app returned by the `app` method.  If you are loading middleware\nin a `config.ru` file, and want to test that, you should load the Rack app created from\nthe `config.ru` file:\n\n```ruby\nOUTER_APP = Rack::Builder.parse_file(\"config.ru\").first\n\nclass TestApp \u003c Test::Unit::TestCase\n  include Rack::Test::Methods\n\n  def app\n    OUTER_APP\n  end\n\n  def test_root\n    get \"/\"\n    assert last_response.ok?\n  end\nend\n```\n\nIf your application does not automatically use the `Rack::Lint` middleware in test mode,\nand you want to test that requests to and responses from your application are compliant\nwith the Rack specification, you should manually use the `Rack::Lint` middleware:\n\n```ruby\nclass TestApp \u003c Test::Unit::TestCase\n  include Rack::Test::Methods\n\n  APP = Rack::Lint.new(YOUR_APP)\n\n  def app\n    APP\n  end\nend\n```\n\n## Install\n\nTo install the latest release as a gem:\n\n```\ngem install rack-test\n```\n\nOr add to your `Gemfile`:\n\n```\ngem 'rack-test'\n```\n\n## Contribution\n\nContributions are welcome. Please make sure to:\n\n* Use a regular forking workflow\n* Write tests for the new or changed behaviour\n* Provide an explanation/motivation in your commit message / PR message\n* Ensure `History.md` is updated\n\n## Authors\n\n- Contributions from Bryan Helmkamp, Jeremy Evans, Simon Rozet, and others\n- Much of the original code was extracted from Merb 1.0's request helper\n\n## License\n\n`rack-test` is released under the [MIT License](MIT-LICENSE.txt).\n\n## Supported platforms\n\n* Ruby 2.0+\n* JRuby 9.1+\n\n## Releasing\n\n* Bump VERSION in lib/rack/test/version.rb\n* Ensure `History.md` is up-to-date, including correct version and date\n* `git commit . -m 'Release $VERSION'`\n* `git push`\n* `git tag -a -m 'Tag the $VERSION release' $VERSION`\n* `git push --tags`\n* `gem build rack-test.gemspec`\n* `gem push rack-test-$VERSION.gem`\n* Add a discussion post for the release\n","funding_links":[],"categories":["Testing","Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frack%2Frack-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frack%2Frack-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frack%2Frack-test/lists"}