app_test.coffee
request = require 'request'
should = require 'should'
..
describe "POST /api/sessions.json", ->
url = "http://localhost:3000/api/sessions.json"
json = {email: "
[email protected]", password: "password"}
it "correct email/password combo", (done) ->
request.post {url: url, json: json}, (e, res) ->
json = res.body
json.success.should.equal(true)
json.should.have.property('token')
done()
it "wrong password", (done) ->
json.password = "WRONGPASSWORD"
request.post {url: url, json: json}, (e, res) ->
json = res.body
json.success.should.equal(false)
done()
it "non-existing email", (done) ->
json.email = "
[email protected]"
request.post {url: url, json: json}, (e, res) ->
json = res.body
json.success.should.equal(false)
done()
Thursday, August 2, 2012