Context("when saving to the compiled package repo fails", func() { JustBeforeEach(func() { expectSave.Return(errors.New("fake-error")).Times(1) }) It("returns error", func() { _, err := compiler.Compile(pkg) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Saving compiled package")) Expect(err.Error()).To(ContainSubstring("fake-error")) }) }) Context("when creating packages dir fails", func() { JustBeforeEach(func() { fs.RegisterMkdirAllError(installPath, errors.New("fake-error")) }) It("returns error", func() { _, err := compiler.Compile(pkg) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Creating package install dir")) Expect(err.Error()).To(ContainSubstring("fake-error")) }) }) Context("when finding compiled package in the repo fails", func() { JustBeforeEach(func() { expectFind.Return(bistatepkg.CompiledPackageRecord{}, false, errors.New("fake-error")).Times(1) })