7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/rspec-api/http_client.rb', line 7
def send_request(options = {})
conn = Faraday.new options[:host] do |c|
c.use FaradayMiddleware::EncodeJson
c.adapter *(options.fetch :adapter, [:net_http])
end
conn.[:user_agent] = 'RSpec API'
conn.[:accept] = 'application/json'
conn.authorization *options[:authorize_with].flatten if options[:authorize_with]
sleep options[:throttle] if options[:throttle]
conn.send *options.values_at(:action, :route, :body)
rescue Faraday::Error::ConnectionFailed => e
pending "Could not connect: #{e}"
end
|