Skip to content

Instantly share code, notes, and snippets.

@gonzalo-bulnes
Last active August 29, 2015 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzalo-bulnes/eec3f73cc7d6605add21 to your computer and use it in GitHub Desktop.
Save gonzalo-bulnes/eec3f73cc7d6605add21 to your computer and use it in GitHub Desktop.
(Update: I've packaged this gist into a gem to make its use easier, see: https://github.com/gonzalo-bulnes/dredd-rack.) Add validation against an API blueprint to a Ruby test suite (by defining a Rake task).
# Rakefile
# Add Rainbow to the app dependencies. That's optional, but the result is worth it.
require 'rainbow'
# ...
# Validate an API against its API blueprint
#
# The API blueprints are expected to be stored in `doc/` and
# have the `.apib` or `.apib.md` extension. (The last one ensures
# that the blueprints are rendered as HTML on Github.)
#
# The 'blueprint:verify' task depends on Dredd being installed but
# does detect automatically if it is not and provides instructions
# to install it.
#
# The task also depends on the API being served at the API_HOST URL.
# It also detects when the connection is impossible and suggests to
# set the API_HOST environment variable and start the API server.
#
# Usage:
#
# API_HOST=http://localhost:4567 rake 'blueprint:verify'
#
# Returns nothing but does abort the rake tasks suite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment