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.ErrorHandler = TErrorHandler(&errorHandlerCalled) }) Context("by returning an error", func() { BeforeEach(func() { handler = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { return fmt.Errorf("boom") } }) It("triggers the error handler", func() { Ω(errorHandlerCalled).Should(BeTrue()) }) }) })