2016-05-15 22:44:52 -04:00
|
|
|
require 'uri'
|
|
|
|
|
2015-03-13 21:00:51 -04:00
|
|
|
module Helpers
|
|
|
|
def response_double(opts={})
|
|
|
|
double('response', {:to_hash => {}}.merge(opts))
|
|
|
|
end
|
2015-03-14 18:18:36 -04:00
|
|
|
|
|
|
|
def fake_stderr
|
|
|
|
original_stderr = $stderr
|
|
|
|
$stderr = StringIO.new
|
|
|
|
yield
|
|
|
|
$stderr.string
|
|
|
|
ensure
|
|
|
|
$stderr = original_stderr
|
|
|
|
end
|
2016-05-01 16:57:54 -04:00
|
|
|
|
|
|
|
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,
|
2016-06-05 19:03:20 -04:00
|
|
|
user: nil, password: nil, cookie_jar: HTTP::CookieJar.new,
|
2016-05-01 16:57:54 -04:00
|
|
|
redirection_history: nil, args: {url: url, method: method})
|
|
|
|
end
|
2015-03-13 21:00:51 -04:00
|
|
|
end
|