1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00
rest-client--rest-client/spec/helpers.rb
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

22 lines
554 B
Ruby

require 'uri'
module Helpers
def response_double(opts={})
double('response', {:to_hash => {}}.merge(opts))
end
def fake_stderr
original_stderr = $stderr
$stderr = StringIO.new
yield
$stderr.string
ensure
$stderr = original_stderr
end
def request_double(url: 'http://example.com', method: 'get')
double('request', url: url, uri: URI.parse(url), method: method,
user: nil, password: nil, cookie_jar: HTTP::CookieJar.new,
redirection_history: nil, args: {url: url, method: method})
end
end