Context("invalid syntax", func() { It("validates that the name is passed in", func() { args := []string{} test_helpers.ExecuteCommandWithArgs(removeCommand, args) Expect(outputBuffer).To(test_helpers.Say("Incorrect Usage: App Name required")) Expect(fakeAppRunner.RemoveAppCallCount()).To(Equal(0)) Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.InvalidSyntax})) }) }) Context("when the receptor returns an error", func() { It("outputs error messages when trying to remove the app", func() { fakeAppRunner.RemoveAppReturns(errors.New("Major Fault")) args := []string{"cool-web-app"} test_helpers.ExecuteCommandWithArgs(removeCommand, args) Expect(outputBuffer).To(test_helpers.Say("Error stopping cool-web-app: Major Fault")) Expect(fakeAppRunner.RemoveAppCallCount()).To(Equal(1)) Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.CommandFailed})) }) It("outputs error messages when trying to remove the app", func() { fakeAppRunner.RemoveAppStub = func(name string) error { if name == "app2" { return errors.New("Major Fault") } return nil