Representation of a mock or expectation rule for HTTP requests.
Rules are evaluated by HttpDouble.MockEngine and can match on method, path,
host, query, headers, body, connection id and call index, or use arbitrary
predicate functions.
Summary
Functions
Builds a rule from a keyword options list.
Produces metadata from a request and optional call index.
Types
@type kind() :: :stub | :expect
Rule kind.
@type meta() :: %{conn_id: non_neg_integer(), call_index: non_neg_integer()}
Metadata provided to predicate functions and callbacks.
@type t() :: %HttpDouble.MockRule{ call_range: Range.t() | nil, conn_ids: [non_neg_integer()] | nil, id: reference(), kind: kind(), matcher: term(), max_calls: :infinity | non_neg_integer(), respond: HttpDouble.response_spec(), times_used: non_neg_integer() }
Internal struct type.
Functions
Builds a rule from a keyword options list.
Supported options:
:matcher– seeHttpDouble.matcher/0:respond– response specification:conn_id/:conn_ids– restrict to specific connection(s):call_range– restrict to a specific range of call indices:max_calls– maximum number of times the rule may match
@spec meta_from_request(HttpDouble.Request.t(), non_neg_integer() | nil) :: meta()
Produces metadata from a request and optional call index.