 
 	describe "removeDocFromMemory", ->
 		beforeEach (done) ->
-			@rclient.del = sinon.stub()
-			@rclient.srem = sinon.stub()
-			@rclient.exec.yields()
+			@multi.del = sinon.stub()
+			@multi.srem = sinon.stub()
+			@multi.exec.yields()
 			@RedisManager.removeDocFromMemory @project_id, @doc_id, done
 
 		it "should delete the lines", ->
-			@rclient.del
+			@multi.del
 				.calledWith("doclines:#{@doc_id}")
 				.should.equal true
 
 		it "should delete the version", ->
-			@rclient.del
+			@multi.del
 				.calledWith("DocVersion:#{@doc_id}")
 				.should.equal true
 
 		it "should delete the hash", ->
-			@rclient.del
+			@multi.del
 				.calledWith("DocHash:#{@doc_id}")
 				.should.equal true
 
 		it "should delete the unflushed time", ->
-			@rclient.del
+			@multi.del
 				.calledWith("UnflushedTime:#{@doc_id}")
 				.should.equal true
 
 		it "should delete the project_id for the doc", ->
-			@rclient.del
+			@multi.del
 				.calledWith("ProjectId:#{@doc_id}")
 				.should.equal true
 
 		it "should remove the doc_id from the project set", ->
-			@rclient.srem
+			@multi.srem
 				.calledWith("DocsIn:#{@project_id}", @doc_id)
 				.should.equal true
 
 		it "should delete the pathname for the doc", ->
-			@rclient.del
+			@multi.del
 				.calledWith("Pathname:#{@doc_id}")
 				.should.equal true
 

		describe "with a corrupted document", ->
			beforeEach ->
				@badHash = "INVALID-HASH-VALUE"
				@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonlines, @version, @badHash, @project_id, @json_ranges])
				@RedisManager.getDoc @project_id, @doc_id, @callback

			it 'should log a hash error', ->

				@RedisManager.updateDocument @doc_id, @lines, @version, @ops, {}, @callback

			it "should not set the ranges", ->
				@multi.set
					.calledWith("Ranges:#{@doc_id}", JSON.stringify(@ranges))
					.should.equal false

			it "should delete the ranges key", ->
				@multi.del
					.calledWith("Ranges:#{@doc_id}")
					.should.equal true

		describe "with a corrupted write", ->
			beforeEach ->
				@badHash = "INVALID-HASH-VALUE"
				@multi.exec = sinon.stub().callsArgWith(0, null, [@badHash])
				@RedisManager.getDocVersion.withArgs(@doc_id).yields(null, @version - @ops.length)
				@RedisManager.updateDocument @doc_id, @lines, @version, @ops, @ranges, @callback

