pub struct Cassette { /* private fields */ }Expand description
A collection of RecordedExchanges, typically loaded from a JSONL
file. Mount on a wiremock::MockServer via mount_cassette.
Implementations§
Source§impl Cassette
impl Cassette
Sourcepub fn from_exchanges(exchanges: Vec<RecordedExchange>) -> Self
pub fn from_exchanges(exchanges: Vec<RecordedExchange>) -> Self
Build from an in-memory list of exchanges. Useful for tests that inline their fixtures.
Sourcepub async fn from_path(path: impl AsRef<Path>) -> Result<Self>
pub async fn from_path(path: impl AsRef<Path>) -> Result<Self>
Async-load a cassette from a JSONL file at path. Lines that are
blank or start with # are skipped (so cassettes can carry
human-readable comments).
Sourcepub fn from_path_sync(path: impl AsRef<Path>) -> Result<Self>
pub fn from_path_sync(path: impl AsRef<Path>) -> Result<Self>
Synchronous version of Self::from_path. Convenient when you
don’t have a runtime in scope.
Sourcepub fn parse_jsonl(jsonl: &str) -> Result<Self>
pub fn parse_jsonl(jsonl: &str) -> Result<Self>
Parse a JSONL string into a cassette. Renamed from from_str
to avoid clashing with std::str::FromStr::from_str.
Sourcepub fn push(&mut self, exchange: RecordedExchange) -> &mut Self
pub fn push(&mut self, exchange: RecordedExchange) -> &mut Self
Append an exchange.
Sourcepub fn skip_request_match(self) -> Self
pub fn skip_request_match(self) -> Self
Disable request-body matching. The wiremock matcher will pair
requests by (method, path) only. Useful when the request body
includes nondeterministic fields (timestamps, request IDs).
Sourcepub fn exchanges(&self) -> &[RecordedExchange]
pub fn exchanges(&self) -> &[RecordedExchange]
Borrow the underlying exchange list.
Sourcepub fn to_jsonl(&self) -> Result<String>
pub fn to_jsonl(&self) -> Result<String>
Serialize back to JSONL. Round-trips with Self::parse_jsonl.