 			beforeEach ->
 				@CompileManager.doCompileWithLock @request, @callback
 
+			it "should ensure that the compile directory exists", ->
+				@fse.ensureDir.calledWith(@compileDir)
+				.should.equal true
+
 			it "should call doCompile with the request", ->
 				@CompileManager.doCompile
 				.calledWith(@request)

			"./TikzManager": @TikzManager = {}
			"./LockManager": @LockManager = {}
			"fs": @fs = {}
		@callback = sinon.stub()

	describe "doCompileWithLock", ->

				project_id: @project_id = "project-id-123"
				user_id: @user_id = "1234"
			@output_files = ["foo", "bar"]
			@Settings.compileDir = "compiles"
			@compileDir = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}"
			@CompileManager.doCompile = sinon.stub().callsArgWith(1, null, @output_files)
			@LockManager.runWithLock = (lockFile, runner, callback) ->
				runner (err, result...) ->
