Skip to content

Commit

Permalink
Merge pull request #540 from cmrd-senya/stub-effective-url-typhoeus
Browse files Browse the repository at this point in the history
Stub an "effective_url" attribute of Typhoeus::Response
  • Loading branch information
bblimke committed Nov 2, 2015
2 parents caa219f + cca0d23 commit ec9783b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def self.generate_typhoeus_response(request_signature, webmock_response)
:code => webmock_response.status[0],
:status_message => webmock_response.status[1],
:body => webmock_response.body,
:headers => webmock_response.headers
:headers => webmock_response.headers,
:effective_url => request_signature.uri
)
end
response.mock = :webmock
Expand Down
12 changes: 12 additions & 0 deletions spec/acceptance/typhoeus/typhoeus_hydra_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
WebMock.reset!
end

describe "supposed response fields" do
it "present" do
stub_request(:get, "http://www.example.com").to_return(:headers => {'X-Test' => '1'})
response = Typhoeus.get("http://www.example.com")
expect(response.code).not_to be_nil
expect(response.status_message).not_to be_nil
expect(response.body).not_to be_nil
expect(response.headers).not_to be_nil
expect(response.effective_url).not_to be_nil
end
end

describe "when params are used" do
it "should take into account params for POST request" do
stub_request(:post, "www.example.com/?hello=world").with(:query => {:hello => 'world'})
Expand Down

0 comments on commit ec9783b

Please sign in to comment.