Created
September 11, 2012 07:24
-
-
Save pftg/3696658 to your computer and use it in GitHub Desktop.
Rails Isolation snippet with Faraday
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lib/client.rb | |
require 'faraday_middleware' | |
module Client | |
def connection | |
@connection ||= Faraday.new url: APP_URL do |faraday| | |
=begin | |
Some Faraday Builder's code | |
... | |
=end | |
faraday.adapter *Faraday.default_adapter | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/initializers/faraday_stubs.rb | |
require 'faraday' | |
stubs = Faraday::Adapter::Test::Stubs.new do |stub| | |
stub.get('/resources') { | |
[200, { }, { resources: Stubs::Resources }] | |
} | |
end | |
Faraday.default_adapter = [:test, stubs] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment