ReqVCR.Tape (ReqVCR v0.3.0)
View SourceA struct representing a tape.
Summary
Functions
Builds a new tape from a request and an optional response.
Records a tape to a file.
Replays a tape from a file.
Types
@type replay() :: %{ url: String.t(), request: map(), response: map(), recorded_at: DateTime.t() }
@type t() :: %{ url: String.t(), path: String.t(), file: String.t(), filename: String.t(), request: Req.Request.t(), response: Req.Response.t(), recorded_at: nil | DateTime.t(), opts: keyword() }
Functions
@spec new(Req.Request.t(), Req.Response.t()) :: t()
Builds a new tape from a request and an optional response.
Parameters
request
- the original requestresponse
- the optional response (default:nil
)
Returns
- a
%Tape{}
struct representing the tape
Records a tape to a file.
Parameters
tape
- the tape to record
Returns
:ok
if the tape was successfully recorded{:error, reason}
if there was an error recording the tape
Replays a tape from a file.
Parameters
tape
- the tape to replay
Returns
{:ok, map()}
if the tape was successfully replayed{:error, reason}
if there was an error replaying the tape