MeaningfulErrors: map[int]error{ http.StatusTeapot: errors.New("TEAPOT!"), http.StatusBadRequest: errors.New("bad request"), }, } }) AfterEach(func() { server.Close() }) It("uses the provided http client", func() { err := jsonClient.BuildAndDo(config) Expect(err).NotTo(HaveOccurred()) Expect(roundTripper.RoundTripCallCount()).To(Equal(1)) }) It("marshals the request payload into the request body", func() { err := jsonClient.BuildAndDo(config) Expect(err).NotTo(HaveOccurred()) Expect(marshaler.MarshalCallCount()).To(Equal(1)) }) Context("when the request payload is missing", func() { BeforeEach(func() { config.RequestPayload = nil }) It("should not try to marshal", func() {