requestBody = &models.TaskByGuidRequest{ TaskGuid: taskGuid, } }) JustBeforeEach(func() { request := newTestRequest(requestBody) handler.TaskByGuid(responseRecorder, request) }) Context("when reading a task from the DB succeeds", func() { var task *models.Task BeforeEach(func() { task = &models.Task{TaskGuid: taskGuid} fakeTaskDB.TaskByGuidReturns(task, nil) }) It("fetches task by guid", func() { Expect(fakeTaskDB.TaskByGuidCallCount()).To(Equal(1)) _, actualGuid := fakeTaskDB.TaskByGuidArgsForCall(0) Expect(actualGuid).To(Equal(taskGuid)) }) It("returns the task", func() { Expect(responseRecorder.Code).To(Equal(http.StatusOK)) response := models.TaskResponse{} err := response.Unmarshal(responseRecorder.Body.Bytes()) Expect(err).NotTo(HaveOccurred()) Expect(response.Error).To(BeNil())