Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rubygems'
require 'rspec'
require 'faraday'
describe Faraday do
it "stubs HTTP responses" do
conn = Faraday.new do |f|
f.adapter :test do |stub|
stub.get '/example' do
[200, {}, 'hi world']
end
end
end
response = conn.get '/example'
expect(response.status).to eq(200)
expect(response.body).to eq('hi world')
end
end
# rspec faraday_stub_spec.rb
# .
#
# Finished in 0.00217 seconds
# 1 example, 0 failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.