Skip to content

Commit

Permalink
Merge pull request #1038 from instrumentl/typhoeus-timings
Browse files Browse the repository at this point in the history
Set Typhoeus timing fields when constructing Response objects
  • Loading branch information
bblimke committed Feb 5, 2024
2 parents 2cb15eb + 5726636 commit 019aecc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
Expand Up @@ -96,15 +96,29 @@ def self.generate_typhoeus_response(request_signature, webmock_response)
status_message: "",
body: "",
headers: {},
return_code: :operation_timedout
return_code: :operation_timedout,
total_time: 0.0,
starttransfer_time: 0.0,
appconnect_time: 0.0,
pretransfer_time: 0.0,
connect_time: 0.0,
namelookup_time: 0.0,
redirect_time: 0.0
)
else
::Typhoeus::Response.new(
code: webmock_response.status[0],
status_message: webmock_response.status[1],
body: webmock_response.body,
headers: webmock_response.headers,
effective_url: request_signature.uri
effective_url: request_signature.uri,
total_time: 0.0,
starttransfer_time: 0.0,
appconnect_time: 0.0,
pretransfer_time: 0.0,
connect_time: 0.0,
namelookup_time: 0.0,
redirect_time: 0.0
)
end
response.mock = :webmock
Expand Down
9 changes: 9 additions & 0 deletions spec/acceptance/typhoeus/typhoeus_hydra_spec.rb
Expand Up @@ -29,6 +29,15 @@
expect(response.body).not_to be_nil
expect(response.headers).not_to be_nil
expect(response.effective_url).not_to be_nil
expect(response.total_time).to eq 0.0
expect(response.time).to eq 0.0 # aliased by Typhoeus::Response::Informations
expect(response.starttransfer_time).to eq 0.0
expect(response.start_transfer_time).to eq 0.0 # aliased by Typhoeus::Response::Informations
expect(response.appconnect_time).to eq 0.0
expect(response.pretransfer_time).to eq 0.0
expect(response.connect_time).to eq 0.0
expect(response.namelookup_time).to eq 0.0
expect(response.redirect_time).to eq 0.0
end
end

Expand Down

0 comments on commit 019aecc

Please sign in to comment.