 	describe 'when action is permitted', ->
 
 		beforeEach ->
-			@limiterFn = sinon.stub().callsArgWith(1, null, 0, 22)
+			@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) ->

		@RedisWrapper =
			client: sinon.stub().returns(@rclient)

		@limiterFn = sinon.stub()
		@RollingRateLimiter = (opts) =>
			return @limiterFn

		@limiter = SandboxedModule.require modulePath, requires:
			"rolling-rate-limiter": @RollingRateLimiter
			"settings-sharelatex":@settings
			"logger-sharelatex" : @logger = {log:sinon.stub(), err:sinon.stub()}
			"./RedisWrapper": @RedisWrapper

		@endpointName = "compiles"
		@subject = "some-project-id"
		@timeInterval = 20
		@throttleLimit = 5

		@details = 
			endpointName: @endpointName

	describe 'when action is not permitted', ->

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

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