BeforeEach(func() { s.Use(TMiddleware(&middlewareCalled)) s.Use(SecondMiddleware(&middlewareCalled, &secondCalled)) }) It("calls the middleware in the right order", func() { Ω(middlewareCalled).Should(BeTrue()) Ω(secondCalled).Should(BeTrue()) }) }) Context("with a handler that fails", func() { errorHandlerCalled := false BeforeEach(func() { s.SetErrorHandler(TErrorHandler(&errorHandlerCalled)) }) Context("by returning an error", func() { BeforeEach(func() { handler = func(ctx *goa.Context) error { return fmt.Errorf("boom") } }) It("triggers the error handler", func() { Ω(errorHandlerCalled).Should(BeTrue()) }) }) Context("by not handling the request", func() {