 
 		describe "when the document is not present", ->
 			beforeEach ->
-				@rclient.exec = sinon.stub().callsArgWith(0, null, [null, null, null, null, null, null, null])
+				@multi.exec = sinon.stub().callsArgWith(0, null, [null, null, null, null, null, null, null])
 				@rclient.sadd = sinon.stub().yields()
 				@RedisManager.getDoc @project_id, @doc_id, @callback
 


	describe "removeDocFromMemory", ->
		beforeEach (done) ->
			@rclient.del = sinon.stub()
			@rclient.srem = sinon.stub()
			@rclient.exec.yields()
			@RedisManager.removeDocFromMemory @project_id, @doc_id, done

		it "should delete the lines", ->
			@rclient.del
				.calledWith("doclines:#{@doc_id}")
				.should.equal true

		it "should delete the version", ->
			@rclient.del
				.calledWith("DocVersion:#{@doc_id}")
				.should.equal true

		it "should delete the hash", ->
			@rclient.del
				.calledWith("DocHash:#{@doc_id}")
				.should.equal true

		it "should delete the unflushed time", ->
			@rclient.del
				.calledWith("UnflushedTime:#{@doc_id}")
				.should.equal true

		it "should delete the project_id for the doc", ->
			@rclient.del
				.calledWith("ProjectId:#{@doc_id}")
				.should.equal true

		it "should remove the doc_id from the project set", ->
			@rclient.srem
				.calledWith("DocsIn:#{@project_id}", @doc_id)
				.should.equal true

		it "should delete the pathname for the doc", ->
			@rclient.del
				.calledWith("Pathname:#{@doc_id}")
				.should.equal true



		describe "with no updates", ->
			beforeEach ->
				@multi.rpush = sinon.stub().callsArg(1)
				@RedisManager.getDocVersion.withArgs(@doc_id).yields(null, @version)
				@RedisManager.updateDocument @doc_id, @lines, @version, [], @ranges, @callback

			it "should not do an rpush", ->
				@multi.rpush
					.called
					.should.equal false

			it "should still set the doclines", ->
				@multi.eval
					.calledWith(sinon.match(/redis.call/), 1, "doclines:#{@doc_id}", JSON.stringify(@lines))
					.should.equal true

