1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00
Commit graph

19 commits

Author SHA1 Message Date
Andy Brody
571a6dc958 Fix tests for logging and Response object changes.
- 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.
2017-05-03 10:31:19 -04:00
Kyle Meyer
72bd7b1e04 Add optional Resource-specific logging 2017-02-28 13:51:15 -08:00
Andy Brody
aaeab33184 Fix warnings and accidentally passing test. 2016-06-05 20:02:46 -04:00
Andy Brody
4971d1a6e1 Convert specs to RSpec 2.99.2 syntax with Transpec
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
2016-06-05 19:52:16 -04:00
Andy Brody
718c5ffb4e Merge pull request #498 from rest-client/ab-cookie-jar
Use cookie jars consistently for requests, responses, and redirection.
2016-06-05 19:38:36 -04:00
Andy Brody
00e3358489 Use request cookie jar as basis for response.
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.
2016-06-05 19:14:39 -04:00
Andy Brody
00e12b35c2 Move max_redirects check into Response#return!
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.
2016-06-05 19:02:26 -04:00
Jun Aruga
d9f6677304 Update to webmock 2.0 2016-05-24 17:05:52 +02:00
Andy Brody
e85a954ed8 Remove args from Response and normalize method.
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: #461
Fixes: #462
Fixes: #463
2016-05-01 16:57:54 -04:00
Andy Brody
5e5fcd9580 Store redirection history on reqs/responses.
This allows callers to actually determine whether a given request
followed redirection, and if so, what the original responses to each
intermediate request were.

Due to the way the code is organized, the simplest way to achieve this
involves storing the history on request objects as well. This isn't
ideal, but will work for now.
2015-04-15 15:14:29 -07:00
Andy Brody
38afe2c895 Refactor redirection handling.
- Remove MaxRedirectsReached, instead raise the normal
  ExceptionWithResponse subclasses.
- Handle max_redirects < 0.
- Remove unnecessary arguments to AbstractResponse#return! and
  #follow_redirection.
- Generally clean up the redirection code to be somewhat saner.
2015-04-15 13:03:02 -07:00
Andy Brody
2e0649f403 Add tests for new header multi value handling. 2015-03-23 21:55:40 -07:00
Andy Brody
6c6b8f2fc0 Merge pull request #365 from rest-client/ab-cookies
Add standards-compliant cookie handling.

Merge branch 'ab-cookies' into 2.0.x

Conflicts:
	history.md
	lib/restclient/abstract_response.rb
	lib/restclient/response.rb
	lib/restclient/version.rb
	spec/unit/request_spec.rb
	spec/unit/response_spec.rb
2015-03-22 17:54:14 -07:00
Andy Brody
c215b22bdb Fix up cookie redirect functionality and tests.
- 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.
2015-03-21 19:14:51 -07:00
Andy Brody
23210393bb Warn when to_i is called on response objects. 2015-03-14 15:58:08 -07:00
Andy Brody
1907f03c22 Merge remote-tracking branch 'godfat/no-to_i'
Conflicts:
	spec/unit/response_spec.rb
2015-03-14 15:36:40 -07:00
Andy Brody
5ce0c6ebde Fix up tests for encoding changes.
Add a `.to_hash => {}` for the Net HTTP response mocks.
2015-03-13 18:00:51 -07:00
Andy Brody
543dbc3816 Fix a large number of style nits.
Working slowly through the rubocop list.
2014-07-08 03:54:01 -07:00
Larry Gilbert
d7a11503af Reorganize specs
* 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/response_spec.rb (Browse further)