commandFactory := command_factory.NewTaskRunnerCommandFactory(fakeTaskRunner, terminalUI, fakeExitHandler) submitTaskCommand = commandFactory.MakeSubmitTaskCommand() }) Context("when the json file exists", func() { BeforeEach(func() { var err error tmpFile, err = ioutil.TempFile("", "tmp_json") Expect(err).ToNot(HaveOccurred()) jsonContents = []byte(`{"Value":"test value"}`) Expect(ioutil.WriteFile(tmpFile.Name(), jsonContents, 0700)).To(Succeed()) }) It("submits a task from json", func() { fakeTaskRunner.SubmitTaskReturns("some-task", nil) args := []string{tmpFile.Name()} test_helpers.ExecuteCommandWithArgs(submitTaskCommand, args) Expect(outputBuffer).To(test_helpers.SayLine(colors.Green("Successfully submitted some-task"))) Expect(fakeTaskRunner.SubmitTaskCallCount()).To(Equal(1)) Expect(fakeTaskRunner.SubmitTaskArgsForCall(0)).To(Equal(jsonContents)) }) It("prints an error returned by the task_runner", func() { fakeTaskRunner.SubmitTaskReturns("some-task", errors.New("taskypoo")) args := []string{tmpFile.Name()} test_helpers.ExecuteCommandWithArgs(submitTaskCommand, args)