It("should succeed", func() { Expect(err).To(Succeed()) }) It("should build a new image", ExpectDockerBuildImage) } Describe("create a docker image", func() { JustBeforeEach(func() { err = Compose(d, ls, c) }) Context("when the configuration is valid", func() { Context("and no previous image exists", func() { BeforeEach(func() { c = getDefaultConfiguration() d = docker.NewMock() d.ImageIDHandler = getImageIDHandler("", "e4785f57b931") }) AssertSuccessfulCompose() It("should not remove any previous image", func() { Expect(d.RemoveImageCalled).To(BeFalse()) }) }) Context("and a previous image exists", func() { BeforeEach(func() { c = getDefaultConfiguration() d = docker.NewMock() d.ImageIDHandler = getImageIDHandler("2dc8f5484fd8", "e4785f57b931") }) AssertSuccessfulCompose() It("should remove the previous image", func() { Expect(d.RemoveImageCalled).To(BeTrue())