Skip to content

Instantly share code, notes, and snippets.

@yixizhang
Last active December 29, 2015 08:49

Revisions

  1. yixizhang revised this gist Nov 25, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions nock.coffee
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,11 @@ quest = require 'quest'

    # chaining
    scope = nock('http://url.ly')
    .filteringRequestBody (path) ->
    if path == '*'
    return '-'
    else
    return '*'
    .post('/', '*')
    .reply(404)
    .post('/', '-')
  2. yixizhang created this gist Nov 25, 2013.
    17 changes: 17 additions & 0 deletions nock.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    nock = require 'nock'
    quest = require 'quest'


    # chaining
    scope = nock('http://url.ly')
    .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