Skip to content

Instantly share code, notes, and snippets.

@mdornseif
Created February 1, 2011 07:26
Show Gist options
  • Save mdornseif/805540 to your computer and use it in GitHub Desktop.
Save mdornseif/805540 to your computer and use it in GitHub Desktop.
Beispiel für eine DSL zum Testen von REST-Interfaces
# This is just a comment
GET http://www.spiegel.de/ -> 200 containing "\willkommen\w"
# the same as
# curl -X GET http://www.spiegel.de/
# check it returns 200
# check the reply contains the regular expression "\willkommen\w"
POST http://www.postbin.org/nqg379 {'JSON': 'data, urlencoded'} -> 201
# the same as
# curl -X GET http://www.spiegel.de/
# check it returns 201
POST http://www.postbin.org/nqg379 {'JSON': 'data, urlencoded'} -> 302 to ".*/blafasel.*"
# the same as
# curl -X POST http://www.postbin.org/nqg379 --data-urlencode "JSON=data, urlencoded"
# check it returns 302
# check the Location-Header matches the regular expression ".*/blafasel.*"
POST http://www.postbin.org/nqg379 "rawbody" -> 302 to ".*/blafasel.*"
# the same as
# curl -X POST http://www.postbin.org/nqg379 --data-binary "rawbody"
# check it returns 302
# check the Location-Header matches the regular expression ".*/blafasel.*"
POST http://www.postbin.org/nqg379 @filename_for_rawbody -> 302 to ".*/blafasel.*"
# the same as
# curl -X POST http://www.postbin.org/nqg379 --data @filename_for_rawbody
# check it returns 302
# check the Location-Header matches the regular expression ".*/blafasel.*"
GET http://edihub.hudora.biz/ -> 302
# the same as
# curl -X GET http://edihub.hudora.biz/
# check it returns 302
use headers {'Accept': '*/*'}
GET http://edihub.hudora.biz/ -> 401
# the same as
# curl -H "Accept: */*" -X GET http://edihub.hudora.biz/
# check it returns 401
# In future use default accept header
use headers {'Accept': None}
# In future use only default headers
use headers None
# in Future use thes credentials
use credentials "user:pass"
GET http://edihub.hudora.biz/ -> 302 to http://edihub.hudora.biz/admin
# the same as
# curl -u "user:pass" -X GET http://edihub.hudora.biz/
# check it returns a 302 redirect to "http://edihub.hudora.biz/admin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment