) Context("when the product can be found", func() { It("returns the located product", func() { response := fmt.Sprintf(`{"id": 3, "slug": "%s"}`, slug) server.AppendHandlers( ghttp.CombineHandlers( ghttp.VerifyRequest("GET", fmt.Sprintf( "%s/products/%s", apiPrefix, slug)), ghttp.RespondWith(http.StatusOK, response), ), ) product, err := client.FindProductForSlug(slug) Expect(err).NotTo(HaveOccurred()) Expect(product.Slug).To(Equal(slug)) }) }) Context("when the server responds with a non-2XX status code", func() { It("returns an error", func() { server.AppendHandlers( ghttp.CombineHandlers( ghttp.VerifyRequest("GET", fmt.Sprintf( "%s/products/%s", apiPrefix, slug)), ghttp.RespondWith(http.StatusTeapot, nil), ),