HTTP module for stripity_stripe that enables PaperTiger sandbox isolation.
When using stripity_stripe with PaperTiger, this module ensures that all HTTP requests include the namespace header needed for test isolation.
Configuration
In your config/test.exs:
config :stripity_stripe,
http_module: PaperTiger.StripityStripeHackneyHow It Works
- Test calls
PaperTiger.Test.checkout_paper_tiger(%{})which sets up namespace - This module reads the namespace and adds it as an HTTP header
- PaperTiger's Sandbox plug reads the header and scopes all operations
- Test data is isolated between tests
Child Process Support
For tests that spawn child processes (like Phoenix LiveView tests), the
namespace is automatically shared via Application env. When you call
checkout_paper_tiger/1, it sets both the process dictionary (for the
test process) and Application env (for child processes like LiveView).
This means LiveView tests "just work" - no extra configuration needed.
Example
defmodule MyApp.BillingTest do
use MyApp.ConnCase, async: true
import PaperTiger.Test
setup do
:ok = checkout_paper_tiger(%{})
# ... rest of setup
end
test "creates subscription", %{conn: conn} do
# Stripe calls from this test AND from LiveView are isolated
{:ok, _sub} = Stripe.Subscription.create(%{...})
{:ok, live, _html} = live(conn, "/billing")
# LiveView's Stripe calls use the same sandbox!
end
end
Summary
Functions
Wraps :hackney.request/5 and injects the PaperTiger namespace header.
Functions
@spec request(atom(), String.t(), list(), iodata(), list()) :: {:ok, integer(), list(), any()} | {:error, term()}
Wraps :hackney.request/5 and injects the PaperTiger namespace header.
This function has the same signature as :hackney.request/5 so it can
be used as a drop-in replacement via stripity_stripe's http_module config.