Project

dock_test

0.0
No commit activity in last 3 years
No release in over 3 years
an outside-in service api test framework.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

 Project Readme

DockTest Gem

DockTest Gem

Description

DockTest is an outside-in testing framework for ruby service api applications.

Features

Different from the popular Rack::Test, DockTest focuses on just on service applications and tests 100% from outside.

  1. 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.
  2. same tests can run for all deployment environments - development, test, staging, and production.
  3. environment-specific skippy setting to automatically skip tests with requests that create side-effects in production environments.
  4. focuses on service applications to strip out sessions, cookies, javascript, file uploads, and other browser-related features.
  5. provides custom assertions that are specific to api responses, including schema validation.
  6. same methods as Rack::Test for easy test reuse.
  7. support for OAuth requests
  8. support for displaying equivalent curl command using OUTPUT_CURL environment variable.
  9. support for script_name localhost testing.
  10. support verify_ssl for specifying whether to enforce ssl verification in http connection. Optional, default is true.

Sample Application

  1. newark app: https://github.com/jackxxu/sample_dock_tested_app
  2. grape app: https://github.com/jackxxu/grape_dock_tested_app
  3. rails-api app: https://github.com/jackxxu/rails_api_dock_tested_app

Install

Add this line to your application's Gemfile:

  group :test do
    gem 'dock_test'
  end

And then execute:

$ bundle

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

Add 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

Assumptions

  1. when testing local application, a config.ru exists that can be used to rackup the server.