Ω(err).ShouldNot(HaveOccurred()) rw = &TestResponseWriter{ ParentHeader: http.Header{}, } ctx = goa.NewContext(nil, req, rw, params, payload) handler = new(testHandler) logger := log15.New("test", "test") logger.SetHandler(handler) ctx.Logger = logger }) It("encodes response using gzip", func() { h := func(ctx *goa.Context) error { ctx.Write([]byte("gzip me!")) ctx.WriteHeader(http.StatusOK) return nil } t := goa.Gzip(gzip.BestCompression)(h) err := t(ctx) Ω(err).ShouldNot(HaveOccurred()) Ω(ctx.ResponseStatus()).Should(Equal(http.StatusOK)) gzr, err := gzip.NewReader(bytes.NewReader(rw.Body)) Ω(err).ShouldNot(HaveOccurred()) buf := bytes.NewBuffer(nil) io.Copy(buf, gzr) Ω(err).ShouldNot(HaveOccurred()) Ω(buf.String()).Should(Equal("gzip me!")) })