httpx/test/support/requests/with_chunked_body.rb
HoneyryderChuck 108d9257c8 added support for HTTP#with_ methods
these will reapply options accordingly (i.e. HTTPX.with_headers(...)).

Because we now have these, HTTPX.headers and HTTPX.timeout have been
deprecated.
2020-03-10 18:58:31 +00:00

20 lines
674 B
Ruby

# frozen_string_literal: true
module Requests
module WithChunkedBody
%w[post put patch delete].each do |meth|
define_method :"test_#{meth}_chunked_body_params" do
uri = build_uri("/#{meth}")
response = HTTPX.with_headers("transfer-encoding" => "chunked")
.send(meth, uri, body: %w[this is a chunked response])
verify_status(response, 200)
body = json_body(response)
verify_header(body["headers"], "Transfer-Encoding", "chunked")
assert body.key?("data")
# assert body["data"] == "thisisachunkedresponse",
# "unexpected body (#{body["data"]})"
end
end
end
end