Skip to content

Instantly share code, notes, and snippets.

@dangerbell
Created November 1, 2012 20:10
Show Gist options
  • Save dangerbell/3996156 to your computer and use it in GitHub Desktop.
Save dangerbell/3996156 to your computer and use it in GitHub Desktop.
Mocha Example with SuperTest and Nock
request = require 'supertest'
scope = require 'nock'
app = require process.cwd() + '/app.coffee'
backend = require process.cwd() + 'lib/backend.coffee'
URL =
describe 'Collections', ->
describe 'show', ->
it "should return a 404 if the object doesn't exist", (done) ->
scope = nock(backend.url)
.filteringPath(/^\/backend\.php.*$/, "/backend.php") # ignore any GET params
.get("/backend.php")
.reply(404)
request(app)
.get("/connectors/#{connectorId}/collections/#{collectionId}")
.set( 'Authorization', "MoverApi app_id=embiggen app_secret=cromulent" )
.end (err, res) ->
res.should.have.status(404)
scope.done()
done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment