DockTest is an outside-in testing framework for ruby service api applications.
Different from the popular Rack::Test, DockTest focuses on just on service applications and tests 100% from outside.
- 100% end-to-end as it is based on HTTP requests/responses. When testing in local mode, it also racks up the local rack server.
- same tests can run for all deployment environments - development, test, staging, and production.
skippysetting to automatically skip tests with requests that create side-effects in production environments.
- provides custom assertions that are specific to api responses, including schema validation.
- same methods as Rack::Test for easy test reuse.
- support for OAuth requests
- support for displaying equivalent curl command using
- support for script_name localhost testing.
verify_sslfor specifying whether to enforce ssl verification in http connection. Optional, default is true.
- newark app: https://github.com/jackxxu/sample_dock_tested_app
- grape app: https://github.com/jackxxu/grape_dock_tested_app
- rails-api app: https://github.com/jackxxu/rails_api_dock_tested_app
Add this line to your application's Gemfile:
group :test do gem 'dock_test' end
And then execute:
In your test helper file (often
test/test_helper.rb), include the following DockTest configuration:
DockTest.configure do |c| case ENV['DOCK_ENV'] when 'production' c.url = 'http://vast-reaches-9635.herokuapp.com/' # your production service url c.skippy = true else c.url = 'http://localhost:9871' # your local service url with abitary unbound port number c.skippy = false end end
include DockTest::Methods to give your integration tests access to all the verb test methods and also assertions.
Now you can excute your test collectively or individually, such as:
$ bundle exec rake test $ DOCK_ENV=production bundle exec rake test
- when testing local application, a
config.ruexists that can be used to