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'm trying to write a test to ensure that rack-reverse-proxy is working correctly, but it looks like WebMock / VCR is causing a conflict with the net_http_hacked changes in this library.
It looks like @socket is nil, maybe because WebMock is also stubbing parts of Net::HTTP?
Note that this gem does work great in production, but it's really dangerous that I am unable to write any integration tests to ensure that it keeps working properly.
UPDATE: I can get the test to pass if I call WebMock.disable!:
around(:each) do |example|
WebMock.disable!
example.run
WebMock.enable!
end
But it would be great if I could actually mock the requests and save the request/response in VCR.
The text was updated successfully, but these errors were encountered:
I've found a workaround for this in tests, but it short-circuits streaming responses, so I would not use the workaround in production due to performance concerns.
The solution is to pass the streaming: false option to the Rack::Proxy middleware when initializing it.
The problem seems to be that WebMock monkey-patches Net::HTTP#request and Net::HTTP#start, including injecting a stubbed socket. Meanwhile, (but only in streaming mode), Rack::Proxy bypasses Net::HTTP#request to use lower-level Net::HTTP methods and obtain a streamable rack response, so the WebMock abstraction is broken and the socket is never set before being used by the underlying Net::HTTP implementation.
you may choose to disable streaming only in tests, since webmock should only monkey-patch in that environment.
I'm using rack-reverse-proxy, which uses
rack-proxy
.I'm trying to write a test to ensure that
rack-reverse-proxy
is working correctly, but it looks like WebMock / VCR is causing a conflict with thenet_http_hacked
changes in this library.When I call
get
in my test, I see this error:Code:
It looks like
@socket
is nil, maybe because WebMock is also stubbing parts ofNet::HTTP
?Note that this gem does work great in production, but it's really dangerous that I am unable to write any integration tests to ensure that it keeps working properly.
UPDATE: I can get the test to pass if I call
WebMock.disable!
:But it would be great if I could actually mock the requests and save the request/response in VCR.
The text was updated successfully, but these errors were encountered: