jsonClient not ending request

20 views
Skip to first unread message

opensas opensas

unread,
Mar 19, 2013, 11:14:05 AM3/19/13
to res...@googlegroups.com
I'm using jasmine-node to test a restify web service

I have the fowllowing test, which passes ok

describe 'web service', ->

  it 'should respond to /ping', (done) ->
    request.get url + 'ping', (res) ->
      expect(res.statusCode).toBe 200
      res.on 'data', (body) ->
        json = JSON.parse(body)
        expect(json.message).toBe "Hi, I'm alive"
        expect(json.date).toBeDefined()
        done()

I tried to rewrite it with jsonClient to make it a little less verbose, like this:

describe 'web service', ->

  it 'should respond to /ping', (done) ->
    http.get url + 'ping', (err, req, res, json) ->
      expect(res.statusCode).toBe 200
      expect(json).toBeDefined()
      expect(json.message).toBe "Hi, I'm alive"
      expect(json.date).toBeDefined()
      done()

sas@ubuntu:~/Ubuntu One/apps/ideas/webservice$ jasmine-node --coffee tests/coffee/pg/g
....

Finished in 0.06 seconds
4 tests, 10 assertions, 0 failures

^C (it gets hanged, so I press ctrl-C)
sas@ubuntu:~/Ubuntu One/apps/ideas/webservice$

The test passes ok, but the command line doesn't return, got to kill it with ctrl-c

It seems like the res.on('data') is not being executed, or something like that

Any idea what might I be missing?
Reply all
Reply to author
Forward
0 new messages