Skip to content

Instantly share code, notes, and snippets.

@keokilee
Created April 11, 2013 00:04
Show Gist options
  • Save keokilee/5359541 to your computer and use it in GitHub Desktop.
Save keokilee/5359541 to your computer and use it in GitHub Desktop.
Example of Mocha spec using Chai BDD assertions and SuperTest to abstract HTTP requests and responses.
should = require('chai').should()
request = require 'supertest'
express = require 'express'
api = require('../routes').api
describe "api", ->
describe "#locations", ->
before ->
@app = express()
@app.get('/locations', api.locations)
it "should return an error message if request has no latitude or longitude", (done) ->
request(@app).get('/locations').expect(200).end (err, res) ->
res.body.error.should.be.ok
done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment