Skip to content

Instantly share code, notes, and snippets.

@andrewsardone
Created October 26, 2013 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsardone/7175213 to your computer and use it in GitHub Desktop.
Save andrewsardone/7175213 to your computer and use it in GitHub Desktop.
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