- Add a new test helper, response_from_res_double, which is a handy way
to create a RestClient::Response given doubles for the
Net::HTTPResponse and RestClient::Request.
- Rename response_double to res_double to better reflect that it is a
stand-in for Net::HTTPResponse.
This conversion is done by Transpec 3.2.2 with the following command:
transpec
* 317 conversions
from: obj.should
to: expect(obj).to
* 160 conversions
from: obj.stub(:message)
to: allow(obj).to receive(:message)
* 100 conversions
from: obj.should_receive(:message)
to: expect(obj).to receive(:message)
* 30 conversions
from: lambda { }.should
to: expect { }.to
* 22 conversions
from: obj.should_not_receive(:message)
to: expect(obj).not_to receive(:message)
* 4 conversions
from: obj.should_not
to: expect(obj).not_to
* 2 conversions
from: == expected
to: eq(expected)
* 1 conversion
from: expect(collection).to have_at_least(n).items
to: expect(collection.size).to be >= n
* 1 conversion
from: obj.unstub(:message)
to: allow(obj).to receive(:message).and_call_original
For more details: https://github.com/yujinakayama/transpec#supported-conversions
Refactor response cookie handling to use our new Request#cookie_jar.
Instead of creating a jar from scratch, make a copy of the request's
cookie jar and populate it with any additional cookies from the response
headers.
Also refactor the redirection code to use this cookie jar, which solves
the question of how to handle cookies from the original request.
Previous refactoring would have broken the ability to call
`.follow_redirection` on a redirection response exception like
RestClient::Found. Instead, raise the exception at the time that the
response is first prepared.
When there is no Location header, we cannot follow any redirection.
Per RFC 7231, a server SHOULD generate a Location header field in the
response for redirection requests, but servers do not always do this.
https://tools.ietf.org/html/rfc7231#section-6.4.3Fixes: #481
It is redundant and confusing to pass both the Request args and the
Request when creating a RestClient::Response. Instead, when the response
object needs to read args from the request, access them on the request
object itself. For determining the HTTP method of the request, switch to
calling RestClient::Request#method.
Also normalize the Request#method to be a lowercase string. This makes
handling of redirection and other method-specific functionality actually
work regardless of how the method was provided to Request.new (:get,
'GET', 'get').
Fixes: #461Fixes: #462Fixes: #463
- Store the request object on responses. We need this in order to be
able to correctly process the cookie jar with the right request URI.
- Fix tests that rely on the old broken Set-Cookie processing code.
- Add test that cookies are not passed across domains on redirect.
* Put unit and integration specs into separate subdirectories
* Consolidate all requires of 'webmock/rspec' into spec_helper.rb
* Use WebMock.{disable!,enable!} for specs calling live server
2013-08-30 18:45:06 -07:00
Renamed from spec/abstract_response_spec.rb (Browse further)