Expect(val).To(BeFalse()) }) Context("when retrieving the App fails", func() { BeforeEach(func() { fakeAppFactory.GetReturns(app.App{}, errors.New("get failed")) }) It("returns an err", func() { err := cmd.DisableSSH([]string{"disable-ssh", "myapp"}, fakeAppFactory) Expect(err).To(MatchError("get failed")) Expect(fakeAppFactory.GetCallCount()).To(Equal(1)) Expect(fakeAppFactory.SetBoolCallCount()).To(Equal(0)) }) }) Context("when setting the value fails", func() { BeforeEach(func() { fakeAppFactory.GetReturns(myApp, nil) fakeAppFactory.SetBoolReturns(errors.New("set failed")) }) It("returns an err", func() { err := cmd.DisableSSH([]string{"disable-ssh", "myapp"}, fakeAppFactory) Expect(err).To(MatchError("set failed")) Expect(fakeAppFactory.GetCallCount()).To(Equal(1)) Expect(fakeAppFactory.SetBoolCallCount()).To(Equal(1)) }) }) })