File: helpers.rb

package info (click to toggle)
ruby-rest-client 2.0.2-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 664 kB
  • sloc: ruby: 3,734; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 554 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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