Ruby Hooks Handler for Dredd API Testing Framework

Gem Version Build Status Dependency Status Code Climate Inline Docs

Test your API with the Dredd HTTP API testing framework and write hooks in Ruby!

DISCLAIMER: This is an early version of dred-hooks-ruby, please be aware that it will not be stable until v1.0.0. At any moment, feedback is welcome! : )

Installation

Add the gem to your Gemfile:

# Gemfile

gem 'dredd_hooks', '0.1.2' # see semver.org

Usage

Create a hook file (the file name is arbitrary):

# ./hooks.rb

require 'dredd_hooks/methods'

include DreddHooks::Methods

before "Machines > Machines collection > Get Machines" do |transaction|
  transaction['skip'] = "true"
end

Run it with Dredd:

# note that the hooks file was named ./hooks.rb
dredd apiary.apib localhost:3000 --language ruby --hookfiles ./hooks.rb

Documentation

API

The DreddHooks::Methods module provides the following methods to be used with transaction names:

  • before
  • after
  • before_validation

And these ones to be used without them:

  • before_all
  • after_all
  • before_each
  • after_each
  • before_each_validation

See also the official Hooks documentation.

Change log

Releases are commented to provide a brief change log, details can be found in the CHANGELOG file.

Development

Testing

# Run the test suite
rake

A few Cucumber features provide an end-to-end test harness, and a set of RSpec specs provide both a more granular documentation and a unit test harness.

RSpec tags are used to categorize the spec examples.

Spec examples that are tagged as public describe aspects of the gem public API, and MAY be considered as its documentation.

The private or protected specs are written for development purpose only. Because they describe internal behaviour which may change at any moment without notice, they are only executed as a secondary task by the continuous integration service and SHOULD be ignored.

Run rake spec:public to print the gem public documentation.

Maintenance

Extending the DSL to support new hooks is meant to be easy, see the maintenance documentation for details. : )

Refactored with love, internet style.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Update the CHANGELOG
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

License

See LICENSE.