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

23 lines
554 B
Ruby
Raw Permalink Normal View History

2016-05-15 22:44:52 -04:00
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')
2016-05-15 22:44:52 -04:00
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