itFailsWhenTheContainerIsNotFound := func(example func() error) { Context("when the container is not found", func() { It("fails", func() { serverBackend.LookupReturns(nil, errors.New("not found")) Ω(example()).Should(MatchError("not found")) }) }) } Describe("stopping", func() { It("stops the container and sends a StopResponse", func() { err := container.Stop(true) Ω(err).ShouldNot(HaveOccurred()) Ω(fakeContainer.StopArgsForCall(0)).Should(Equal(true)) }) itFailsWhenTheContainerIsNotFound(func() error { return container.Stop(true) }) Context("when stopping the container fails", func() { BeforeEach(func() { fakeContainer.StopReturns(errors.New("oh no!")) }) It("returns an error", func() { err := container.Stop(true) Ω(err).Should(HaveOccurred()) })