Pact

A module for managing dependencies in your application. You can set, get, and override dependencies globally or per-pid.

Example

Pact.start
Pact.put(:http, HTTPoison)

Pact.get(:http).get("https://google.com")

# You can also override per module

Pact.override(self, :http, FakeHTTP)

spawn(fn ->
  Pact.get(:http).get("https://google.com") # Calls HTTPoison
end)

Pact.get(:http).get("https://google.com") # Calls FakeHTTP
Source

Summary

get(name)

Gets the dependency with name

override(pid, name, module)

Override all calls to name in pid with module

put(name, module)

Assign module to the key name

start(initial_modules \\ %{})
stop()

Stop Pact

Functions

get(name)

Gets the dependency with name

Source
override(pid, name, module)

Override all calls to name in pid with module

Source
put(name, module)

Assign module to the key name

Source
start(initial_modules \\ %{})
Source
stop()

Stop Pact

Source