Skip to content

Instantly share code, notes, and snippets.

@openfirmware
Created January 12, 2012 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save openfirmware/1603022 to your computer and use it in GitHub Desktop.
Save openfirmware/1603022 to your computer and use it in GitHub Desktop.
When /^I send a GET request for "([^"]*)"$/ do |path|
get path
end
Then /^the response code should be "([^"]*)"$/ do |code|
last_response.status.should == code.to_i
end
# features/my_dumb_api.feature
Feature: My Dumb API
In order to retrieve an API response
As a web API developer
I want an API to respond to my requests
Scenario: API is available
When I send a GET request for "http://example.com/api/"
Then the response code should be "200"
# routes.rb
RailsApp::Application.routes.draw do
mount proc { |env|
[200, {}, ["OK"]]
} => "/api"
# your other Rails routes
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment