A running Pact mock server.
Start one with PactEx.Consumer.start_mock_server/3, or let
PactEx.Consumer.run/4 manage it. Send the requests of your test to url.
Summary
Functions
Returns true if every expected request arrived and no unexpected request did.
Returns the mismatches seen so far, as decoded maps.
Stops the server and frees its resources. Always returns :ok, also when
the server was already stopped.
Writes the pact file to the server's pact_dir, creating the directory if needed.
Types
@type t() :: %PactEx.MockServer{ pact_dir: Path.t(), pact_ref: reference(), port: pos_integer(), url: String.t() }
Functions
Returns true if every expected request arrived and no unexpected request did.
Returns false for a server that was already stopped.
Returns the mismatches seen so far, as decoded maps.
Returns [] when there are none, and for a server that was already stopped.
See PactEx.MismatchError for the "type" values.
@spec stop(t()) :: :ok
Stops the server and frees its resources. Always returns :ok, also when
the server was already stopped.
Read matched?/1 and mismatches/1 before calling it.
@spec write_pact(t(), keyword()) :: :ok | {:error, PactEx.Error.t()}
Writes the pact file to the server's pact_dir, creating the directory if needed.
The file is named <consumer>-<provider>.json.
Options
:overwrite- whenfalse(the default), merges with an existing file. Whentrue, replaces it.
Returns {:error, %PactEx.Error{}} if the file cannot be written, or if the
server was already stopped (code 3). Raises ArgumentError on unknown
options or a non-boolean :overwrite.