Rack::Test is a small, simple testing API for Rack apps.
Rack::Test is a small, simple testing API for Rack apps.
Code: https://github.com/rack/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.
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:
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
endIf 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
endTo install the latest release as a gem:
gem install rack-testOr add to your Gemfile:
gem 'rack-test'Contributions are welcome. Please make sure to:
History.md is updatedrack-test is released under the MIT License.
History.md is up-to-date, including correct version and dategit commit . -m 'Release $VERSION'git pushgit tag -a -m 'Tag the $VERSION release' $VERSIONgit push --tagsgem build rack-test.gemspecgem push rack-test-$VERSION.gemNo open issues yet, or sync has not completed.