← ClaudeAtlas

ruby-testinglisted

Unit-test code that calls the PayPal Server SDK Ruby SDK. Load before stubbing the SDK. The argument list won't tell you the seam is a `Faraday::Connection` you build yourself and pass as `connection:`, that `http_callback` observes rather than substitutes, or that a stubbed 5xx needs `max_retries: 0` to fail on the first attempt.
MuHamza30/paypal-api-plugin · ★ 0 · Testing & QA · score 70
Install: claude install-skill MuHamza30/paypal-api-plugin
# Testing code that uses an APIMatic Ruby SDK The SDK has **no mocking helpers for consumers**. Its transport is **Faraday**, and the `Client` constructor exposes two relevant keyword arguments: - **`connection:`** — a `Faraday::Connection` you build yourself, used for every request. Building it with **Faraday's test adapter** is the in-process seam: no network, no global patching. - **`http_callback:`** — an `HttpCallBack` whose `on_before_request` / `on_after_response` hooks **observe** the request and response. This is what the SDK's own generated tests use for assertions — it cannot stub anything. The samples below use Minitest for reference only — mirror whatever the project already uses. ## A reusable stub helper ```ruby require 'faraday' require 'paypal_server_sdk' def client_returning(status, body, path) stubs = Faraday::Adapter::Test::Stubs.new stubs.get(path) do [status, { 'Content-Type' => 'application/json' }, JSON.generate(body)] end connection = Faraday.new do |builder| builder.adapter(:test, stubs) end client = PaypalServerSdk::Client.new( connection: connection, max_retries: 0 # a stubbed 5xx fails on the first attempt, with no backoff wait ) [client, stubs] end ``` Faraday's test adapter is Faraday's own API, not the SDK's — check the Faraday version the SDK's gems resolve to for the exact stub syntax, and use `stubs.verify_stubbed_calls` to assert every stub was hit. **A scheme that fetches a token send