Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Cucumber steps to easily test REST-based XML and JSON APIs
Ruby
Tag: v0.6

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
features/support
lib/cucumber
.gitignore
.rvmrc
Gemfile
README.md
Rakefile
cucumber-api-steps.gemspec

README.md

Cucumber API Steps

A set of Cucumber step definitions utilizing Rack-Test that ease basic testing of REST-style APIs using either XML or JSON formats.

Adapted from a blog post by Anthony Eden with a few additions based on my own needs. I found myself copying these step definitions around to multiple projects, and decided that it would be worthwhile to gem them up to keep things nice and DRY.

Dependencies

Requires Cucumber (obviously). Also makes use of JSONPath for setting criteria against JSON responses. See the gemspec for more info.

Installation

Add the following line to your Gemfile, preferably in the test or cucumber group:

gem 'cucumber-api-steps', :require => false

Then add the following line to your env.rb to make the step definitions available in your features:

require 'cucumber/api_steps'

Usage

Still a work in progress. For now, read the api_steps.rb file or check out the stashboard-rails project - its Cucumber features make extensive use of the steps in this gem.

One major caveat is that the way the steps are currently built, the PUT and POST steps accept a heredoc-style string (demarcated with lines of three double quotes) as a body, instead of a hash as many people seem to expect. I found this way to be more natural/flexible for how I write API tests, but it seems like others do not, so I'll be changing the steps to accept either a hash or a string soon.

Contributors

  • Jay Zeschin
  • Justin Smestad

Copyright

Copyright (c) 2011 Jay Zeschin. Distributed under the MIT License.

Something went wrong with that request. Please try again.