Skip to content

Instantly share code, notes, and snippets.

Created May 8, 2015 20:00
Show Gist options
  • Save anonymous/b635362ad58f9eeb5a6e to your computer and use it in GitHub Desktop.
Save anonymous/b635362ad58f9eeb5a6e to your computer and use it in GitHub Desktop.
Stubbing with Faraday
def stub_request
faraday_stub = Faraday.new do |builder|
builder.adapter :test do |stub|
stub.post('/api/service', {id: '111', data: {'a': 1}}) {|env| [200, {}, mock_response]}
stub.get('/api/another_service', {query: 'foo'}) {|env| [200, {}, second_mock_response]}
end
end
Service::Something.stubs(:connection).returns(faraday_stub)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment