BeforeEach(func() { context = &fakes.Context{} linkFactory = &fakes.LinkFactory{} context.LinkFactoryReturns(linkFactory) createBridge = commands.CreateBridge{ Name: "my-bridge", } }) It("creates a bridge device", func() { err := createBridge.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(linkFactory.CreateBridgeCallCount()).To(Equal(1)) Expect(linkFactory.CreateBridgeArgsForCall(0)).To(Equal("my-bridge")) }) Context("when creating the bridge fails", func() { BeforeEach(func() { linkFactory.CreateBridgeReturns(errors.New("no bridge for sale")) }) It("wraps and propagates the error", func() { err := createBridge.Execute(context) Expect(err).To(MatchError("create bridge: no bridge for sale")) }) }) Describe("String", func() { It("is self describing", func() {