- Notifications
You must be signed in to change notification settings - Fork0
Rack::Test is a layer on top of Rack's MockRequest similar to Merb's RequestHelper
License
mperham/rack-test
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Rack::Test<img src=“https://codeclimate.com/github/brynary/rack-test.png” /><img src=“https://codeclimate.com/github/brynary/rack-test/coverage.png” />¶↑
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. Most of its initial functionality is an extraction of Merb 1.0’s request helpers feature.
Maintains a cookie jar across requests
Easily follow redirects when desired
Set request headers to be used by all subsequent requests
Small footprint. Approximately 200 LOC
require"rack/test"classHomepageTest<Test::Unit::TestCaseincludeRack::Test::MethodsdefappMyApp.newenddeftest_redirect_logged_in_users_to_dashboardauthorize"bryan","secret"get"/"follow_redirect!assert_equal"http://example.org/redirected",last_request.urlassertlast_response.ok?endend
If you want to test one app in isolation, you just return that app as shown above. But if you want to test the entire app stack, including middlewares, cascades etc. you need to parse the app defined in config.ru.
OUTER_APP =Rack::Builder.parse_file('config.ru').firstclassTestApp<Test::Unit::TestCaseincludeRack::Test::MethodsdefappOUTER_APPenddeftest_rootget'/'assertlast_response.ok?endend
To install the latest release as a gem:
sudogeminstallrack-test
Or via Bundler:
gem"rack-test",require:"rack/test"
Maintained byBryan Helmkamp
Contributions from Simon Rozet, Pat Nakajima and others
Much of the original code was extracted from Merb 1.0’s request helper
Copyright © 2008-2009 Bryan Helmkamp, Engine Yard Inc. See MIT-LICENSE.txt in this directory.
Ensure History.txt is up-to-date
Bump VERSION in lib/rack/test.rb
thor :release
About
Rack::Test is a layer on top of Rack's MockRequest similar to Merb's RequestHelper
Resources
License
Stars
Watchers
Forks
Packages0
Languages
- Ruby100.0%