Skip to content

Instantly share code, notes, and snippets.

@raul
Created May 26, 2013 09:38
Show Gist options
  • Save raul/5652222 to your computer and use it in GitHub Desktop.
Save raul/5652222 to your computer and use it in GitHub Desktop.
Proposal for Weasel Diesel's DSL: describe different scenarios for a given response, including support status codes and headers
# Based on http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
describe_service "/gists/:id/star" do |service|
service.http_verb :get
# documentation
service.documentation do |doc|
doc.overall "Check if a gist is starred"
doc.example '<code>curl http://localhost:9292/gists/:id/star</code>'
end
# input
service.param.integer :id, required: true, doc: "The gist id"
# output
service.response do |response|
response.when do |scenario|
scenario.description "gist is starred"
scenario.status 204
scenario.header 'X-RateLimit-Limit', 5000
scenario.header 'X-RateLimit-Remaining', 4999
end
response.when do |scenario|
scenario.description "gist is not starred"
scenario.status 404
scenario.header 'X-RateLimit-Limit', 5000
scenario.header 'X-RateLimit-Remaining', 4999
end
end
# implementation
service.implementation do
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment