Skip to content

Instantly share code, notes, and snippets.

@yixizhang
Last active December 29, 2015 08:49
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 yixizhang/7645566 to your computer and use it in GitHub Desktop.
Save yixizhang/7645566 to your computer and use it in GitHub Desktop.
nock sample
nock = require 'nock'
quest = require 'quest'
# chaining
scope = nock('http://url.ly')
.filteringRequestBody (path) ->
if path == '*'
return '-'
else
return '*'
.post('/', '*')
.reply(404)
.post('/', '-')
.reply(200)
quest {uri: 'http://url.ly', method: 'POST', body: '*'}, (err, resp, body) ->
console.log resp.statusCode
quest {uri: 'http://url.ly', method: 'POST', body: '-'}, (err, resp, body) ->
console.log resp.statusCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment