1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
require_relative '_lib'
require 'json'
require 'zlib'
describe RestClient::Request do
before(:all) do
WebMock.disable!
end
after(:all) do
WebMock.enable!
end
def default_httpbin_url
# add a hack to work around java/jruby bug
# java.lang.RuntimeException: Could not generate DH keypair with backtrace
# Also (2017-04-09) Travis Jruby versions have a broken CA keystore
if ENV['TRAVIS_RUBY_VERSION'] =~ /\Ajruby-/
'http://httpbin.org/'
else
'https://httpbin.org/'
end
end
def httpbin(suffix='')
url = ENV.fetch('HTTPBIN_URL', default_httpbin_url)
unless url.end_with?('/')
url += '/'
end
url + suffix
end
def execute_httpbin(suffix, opts={})
opts = {url: httpbin(suffix)}.merge(opts)
RestClient::Request.execute(opts)
end
def execute_httpbin_json(suffix, opts={})
JSON.parse(execute_httpbin(suffix, opts))
end
describe '.execute' do
end
end
|