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
Am trying to use Hi8 to automatically record and playback HTTP interactions for a Web service client, but am using Cossack rather than just HTTP::Client.
The first time the spec is executed, it passes and HI8 records the interaction as expected. However, subsequent test runs fail with Real HTTP connections are disabled. Unregistered request: ....
Further investigation reveals that the recorded uri in the cassette has the base URL "doubled". E.g., "https://api.fixer.io/latest" becomes "https://api.fixer.iohttps://api.fixer.io/latest".
The same behaviour was not observed using whether using HTTP::Client.get() or HTTP::Client.new().
Sample code
HI8.use_cassette("using_cossack_client") do
client = Cossack::Client.new("https://api.fixer.io")
resp = client.get("/latest?base=USD")
resp.status.should eq(200)
end
Real HTTP connections are disabled. Unregistered request: GET https://api.fixer.iohttps://api.fixer.io/latest?base=USD with headers {"User-Agent" => "Cossack v0.1.4", "Host" => "api.fixer.io"}
So I've traced through this and I seem to have isolated where the problem occurs.
In HI8::HTTPHelpers#uri_creator (episode.cr:15) it concatenates host + resources.
For some reason, when using Cossack the @request.resource.to_s (episode.cr:47) also embeds the host. Hence, the "doubling" when the interaction is recorded.
Not sure if this is a Cossack issue or whether it should be treated as a special case by HI8.
Issue Summary
Am trying to use Hi8 to automatically record and playback HTTP interactions for a Web service client, but am using Cossack rather than just
HTTP::Client
.The first time the spec is executed, it passes and HI8 records the interaction as expected. However, subsequent test runs fail with
Real HTTP connections are disabled. Unregistered request: ...
.Further investigation reveals that the recorded
uri
in the cassette has the base URL "doubled". E.g.,"https://api.fixer.io/latest"
becomes"https://api.fixer.iohttps://api.fixer.io/latest"
.The same behaviour was not observed using whether using
HTTP::Client.get()
orHTTP::Client.new()
.Sample code
The full gist can be found at here
Expected behaviour
Spec should pass.
Actual behaviour
Environment
The text was updated successfully, but these errors were encountered: