Permalink
Browse files

Merge pull request #393 from ixti/fix/http-gem-with-follows

Fix HTTP Gem replayed Response object's init
  • Loading branch information...
2 parents 0cd6a12 + 321bd54 commit 16a725942d1cc0795b3f3f107a4324a0c99f049d @bblimke committed May 31, 2014
@@ -10,12 +10,13 @@ def to_webmock
webmock_response
end
- def self.from_webmock(webmock_response)
+ def self.from_webmock(webmock_response, request_signature = nil)
status = webmock_response.status.first
headers = webmock_response.headers || {}
body = Body.new Streamer.new webmock_response.body
+ uri = URI request_signature.uri.to_s if request_signature
- new(status, "1.1", headers, body)
+ new(status, "1.1", headers, body, uri)
end
end
end
@@ -37,7 +37,7 @@ def replay
webmock_response.raise_error_if_any
invoke_callbacks(webmock_response, :real_request => false)
- ::HTTP::Response.from_webmock webmock_response
+ ::HTTP::Response.from_webmock webmock_response, request_signature
end
def perform
@@ -47,4 +47,13 @@
expect(headers).to include "Host" => "www.example.com"
end
end
+
+ it "restores request uri on replayed response object" do
+ uri = URI "http://example.com/foo"
+
+ stub_request :get, "example.com/foo"
+ response = HTTP.get uri
+
+ expect(response.uri).to eq uri
+ end
end

0 comments on commit 16a7259

Please sign in to comment.