Pact.MockServer (pact_consumer_ex v0.2.1)

A mock server that handles the requests described in a Pact, intended for use in tests, and validates that the requests made to that server are correct.

Because this is intended for use in tests, it will panic if something goes wrong.

Summary

Functions

Returns a specification to start this module under a supervisor.

Given a path string, return a URL pointing to that path on the mock server. If the path cannot be parsed as URL, this function will panic. For a non-panicking version, call Pact.MockServer.url/1 instead and build this path yourself.

The base URL of the mock server. You can make normal HTTP requests using this as the base URL (if it is a HTTP-based mock server).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

path(pid, path)

@spec path(pid :: pid(), path :: String.t()) :: String.t()

Given a path string, return a URL pointing to that path on the mock server. If the path cannot be parsed as URL, this function will panic. For a non-panicking version, call Pact.MockServer.url/1 instead and build this path yourself.

start(pact_builder)

@spec start(pact_builder :: Pact.Native.PactConsumer.PactBuilder.t()) ::
  :ignore | {:error, any()} | {:ok, pid()}

url(pid)

@spec url(pid :: pid()) :: String.t()

The base URL of the mock server. You can make normal HTTP requests using this as the base URL (if it is a HTTP-based mock server).