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
Status_message is nil and the return_message is "Could't resolve host name"
When the status is created it is done as
webmock_response.status = [typhoeus_response.code, typhoeus_response.status_message]
From there on the actual problem for my case is that this gets saved in a vcr cassette as
where the status code is 0 and the message is empty.
This leads to the following situation. The first time a request is made and there is no cassette typhoeus has return_message as "Could not resolve host" and we can test in our specs that the host was not reached and we've shown the user the error message.
The second time the spec is ran there is already a cassette. The cassette has status message as empty and the test no longer works as it does not load "could not resolve host" into the typhoeus return_message
could be useful, but it will mess up status_message with return_message and return message should probably be saved/loaded in another way
The text was updated successfully, but these errors were encountered:
thebravoman
changed the title
Typhoeus return message lost when creating a Webmock response
Typhoeus return_message lost when creating a Webmock response
May 3, 2024
The return_message information is not based on the response code but on the return_code, which is not part of HTTP but rather an internal aspect of libcurl. For example, status code 0 is also returned on a timeout.
WebMock::Response only contains HTTP attributes and doesn't carry any HTTP client-specific data, only pure HTTP response information like status code and status message.
The recorded response in the VCR YAML is correct since the response status message is nil:
irb(main):010> res.status_message
=> nil
We could possibly extend WebMock::Response to carry client_specific_response_attributes that would contain return_code and return_message. However, even then, VCR would not record these attributes as VCR also doesn't support any attributes other than pure HTTP data. Therefore, the solution is not going to work unless both WebMock and VCR support client-specific response attributes.
Send request to "http://post_zip.pixel/2"
This is invalid and typhoeus will return code:0 return_message: "Couldn't resolve host name"
This is lost when creating the webmock response
Status_message is nil and the return_message is "Could't resolve host name"
When the status is created it is done as
webmock_response.status = [typhoeus_response.code, typhoeus_response.status_message]
From there on the actual problem for my case is that this gets saved in a vcr cassette as
where the status code is 0 and the message is empty.
This leads to the following situation. The first time a request is made and there is no cassette typhoeus has return_message as "Could not resolve host" and we can test in our specs that the host was not reached and we've shown the user the error message.
The second time the spec is ran there is already a cassette. The cassette has status message as empty and the test no longer works as it does not load "could not resolve host" into the typhoeus return_message
Probably something along the lines of
could be useful, but it will mess up status_message with return_message and return message should probably be saved/loaded in another way
The text was updated successfully, but these errors were encountered: