Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rack-test

> 测试质量
Open source

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

953 stars0 likes4 views
WebsiteGitHub

About

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

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.

…

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:

ruby
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:

ruby
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

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyrubytesting

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.