Skip to content

Instantly share code, notes, and snippets.

@misablaha
Created March 7, 2014 10:26
Show Gist options
  • Save misablaha/9409100 to your computer and use it in GitHub Desktop.
Save misablaha/9409100 to your computer and use it in GitHub Desktop.
require('cson-config').load()
brokerClient = require 'broker-client'
config = process.config
app = brokerClient config.broker
# middleware
app.use (req, res, next)->
console.log "#{req.method} #{req.path} from #{req.headers['x-forwarded-for']}"
next()
app.listen config.port, ()->
console.log "listen #{config.port}"
describe 'workshop api', ->
@timeout 5000
get '/0/workshop', (req, body, done)->
assert.equal body.data.working, yes, "Bad response, working isn't yes"
done()
input=
data:
test: yes
post '/0/workshop/params', input, (req, body, done)->
assert.equal JSON.stringify(input.data), JSON.stringify(body.data), "Something went wrong :/"
done()
data=
data:
counter: 10
headers:
token: 'token'
post '/0/workshop/post', {data: data.data}, (req, body, done)->
assert.equal body.error.message, "bad token", "Expected error response!"
done()
post '/0/workshop/post', data, (req, body, done)->
assert.equal body.data.result, 5, "Bad result"
done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment