 	describe 'when limiter produces an error', ->
 
 		beforeEach ->
-			@limiterFn = sinon.stub().callsArgWith(1, new Error('woops'))
+			@requires["rolling-rate-limiter"] = (opts) =>
+				return sinon.stub().callsArgWith(1, new Error('woops'))
+			@limiter = SandboxedModule.require modulePath, requires: @requires
 
 		it 'should produce and error', (done) ->
 			@limiter.addCount {}, (err, should) ->

	describe 'when action is not permitted', ->

		beforeEach ->
			@limiterFn = sinon.stub().callsArgWith(1, null, 4000, 0)

		it 'should not produce and error', (done) ->
			@limiter.addCount {}, (err, should) ->

	describe 'when action is permitted', ->

		beforeEach ->
			@requires["rolling-rate-limiter"] = (opts) =>
				return sinon.stub().callsArgWith(1, null, 0, 22)
			@limiter = SandboxedModule.require modulePath, requires: @requires

		it 'should not produce and error', (done) ->
			@limiter.addCount {}, (err, should) ->
