   describe 'rateLimit', ->
     describe 'when limit function returns an error', ->
       beforeEach ->
-        @throttles = query: sinon.stub().yields new Error
+        @throttles = query: rateLimit: sinon.stub().yields new Error
         @sut = new MeshbluWebsocketHandler throttles: @throttles
 
         @sut.rateLimit '1234', 'foo', (@error) =>

  describe 'onMessage', ->
    describe 'when rateLimit exceeded', ->
      beforeEach ->
        @throttles = query: sinon.stub().yields new Error('rate limit exceeded')
        @sut = new MeshbluWebsocketHandler throttles: @throttles
        @sut.socket = id: '1555'
        @sut.sendError = sinon.spy()


    describe 'when rateLimit not exceeded', ->
      beforeEach (done) ->
        @throttles = query: rateLimit: sinon.stub().yields null, false
        @sut = new MeshbluWebsocketHandler throttles: @throttles
        @sut.socket = id: '1555'
        @sut.addListener 'test', (@data) => done()
