Stubbing with Faraday
✓ Published0🌍 Public
Aafbroman
Last edited May 8, 2015
Created on Jun 3, 2016
This example shows how to stub HTTP requests in Faraday using its built-in test adapter. The code defines a method that constructs a Faraday connection with the `:test` adapter, registering two stubbed responses: a POST to `/api/service` with a JSON payload and a GET to `/api/another_service` with a query parameter. It then returns this stubbed connection to replace the real one via `Service::Something.stubs(:connection)`. The mock responses are provided as HTTP status 200 with empty headers and predefined response bodies.
AI-generated description