underlyingRequirement.ExecuteReturns(errors.New("TERRIBLE THINGS")) r.Execute() Expect(configRefresher.RefreshCallCount()).To(Equal(1)) }) It("returns the value of calling execute on the underlying requirement again", func() { var count int disaster := errors.New("TERRIBLE THINGS") secondaryDisaster := errors.New("REALLY TERRIBLE THINGS") underlyingRequirement.ExecuteStub = func() error { if count == 0 { count++ return disaster } return secondaryDisaster } err := r.Execute() Expect(underlyingRequirement.ExecuteCallCount()).To(Equal(2)) Expect(err).To(Equal(secondaryDisaster)) }) Context("if config refresh fails", func() { It("returns the error", func() { underlyingRequirement.ExecuteReturns(errors.New("TERRIBLE THINGS")) oops := errors.New("Can't get things") configRefresher.RefreshReturns(nil, oops)