JustBeforeEach(func() { request := newTestRequest(requestBody) handler.StartTask(responseRecorder, request) }) It("calls StartTask", func() { Expect(fakeTaskDB.StartTaskCallCount()).To(Equal(1)) taskLogger, taskGuid, cellId := fakeTaskDB.StartTaskArgsForCall(0) Expect(taskLogger.SessionName()).To(ContainSubstring("start-task")) Expect(taskGuid).To(Equal("task-guid")) Expect(cellId).To(Equal("cell-id")) }) Context("when the task should start", func() { BeforeEach(func() { fakeTaskDB.StartTaskReturns(true, nil) }) It("responds with true", func() { Expect(responseRecorder.Code).To(Equal(http.StatusOK)) response := &models.StartTaskResponse{} err := response.Unmarshal(responseRecorder.Body.Bytes()) Expect(err).NotTo(HaveOccurred()) Expect(response.Error).To(BeNil()) Expect(response.ShouldStart).To(BeTrue()) }) }) Context("when the task should not start", func() { BeforeEach(func() {