You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can confirm this is necessary when using FakeWeb to stub requests from the RestClient gem (2.0.0+).
Without inspecting this IO stream data, there's no way to see what was sent. Since FakeWeb.last_request.body will be nil in the common case of sending a String payload with RestClient::Request.execute(...).
It is due to this code in RestClient::Request creating a RestClient::Payload::Base (or similar depending on the type of body data) and attaching it to the Net::HTTP request body_stream (rather than body).
This was documented here as a performance improvement with the release of RestClient v2.0.0
Add actual support for streaming request payloads. Previously rest-client would call .to_s even on RestClient::Payload::Streamed objects. Instead, treat any object that responds to .read as a streaming payload and pass it through to .body_stream= on the Net:HTTP object. This massively reduces the memory required for large file uploads.
This isn't an issue with Net::HTTP unless you're setting body_stream directly on the request.
Right now, if I want to verify that I'm POST'ing the right data, I need to do something like this:
Line 3 of this example should be encapsulated. For instance, it could be exposed as
FakeWeb.last_request.form_data
The text was updated successfully, but these errors were encountered: