Main R6 class that is called from the main user facing
function use_cassette()
Points of webmockr integration
initialize()
: webmockr is used in theinitialize()
method to create webmockr stubs. Stubs are created on call toCassette$new()
withininsert_cassette()
, but then on exitinguse_cassette()
, or callingeject()
onCassette
class frominsert_cassette()
, stubs are cleaned up.eject()
method:webmockr::disable()
is called before exiting eject to disable webmock so that webmockr does not affect any HTTP requests that happen afterwards.serialize_to_crul()
method: webmockr::RequestSignature and webmockr::Response are used to build a request and response, respectively, then passed towebmockr::build_crul_response()
to make a completecrul
HTTP response object.
Public fields
name
(character) cassette name
record
(character) record mode
recorded_at
(character) date/time recorded at
serialize_with
(character) serializer to use (yaml|json)
serializer
(character) serializer to use (yaml|json)
match_requests_on
(character) matchers to use default: method & uri
re_record_interval
(numeric) the re-record interval
root_dir
root dir, gathered from
vcr_configuration()
allow_playback_repeats
(logical) Whether to allow a single HTTP interaction to be played back multiple times
preserve_exact_body_bytes
(logical) Whether to base64 encode the bytes of the requests and responses
http_interactions
(list) internal use
new_interactions
(boolean) Have any interactions been recorded?
clean_outdated_http_interactions
(logical) Should outdated interactions be recorded back to file
to_return
(logical) internal use
warn_on_empty
(logical) warn if no interactions recorded
new_cassette
is this a new cassette?
Methods
Method new()
Create a new Cassette
object
Usage
Cassette$new(
name,
dir = NULL,
record = NULL,
match_requests_on = NULL,
allow_playback_repeats = FALSE,
serialize_with = NULL,
preserve_exact_body_bytes = NULL,
re_record_interval = NULL,
clean_outdated_http_interactions = NULL,
warn_on_empty = NULL
)
Arguments
name
The name of the cassette. vcr will sanitize this to ensure it is a valid file name.
dir
The directory where the cassette will be stored.
record
The record mode. Default: "once".
match_requests_on
List of request matchers to use to determine what recorded HTTP interaction to replay. Defaults to
["method", "uri"]
. The built-in matchers are "method", "uri", "headers" and "body" ("host" and "path" not supported yet, but should be in a future version)allow_playback_repeats
(logical) Whether or not to allow a single HTTP interaction to be played back multiple times. Default:
FALSE
.serialize_with
(character) Which serializer to use. Valid values are "yaml" (default), the only one supported for now.
preserve_exact_body_bytes
(logical) Whether or not to base64 encode the bytes of the requests and responses for this cassette when serializing it. See also
preserve_exact_body_bytes
invcr_configure()
. Default:FALSE
re_record_interval
(numeric) When given, the cassette will be re-recorded at the given interval, in seconds.
clean_outdated_http_interactions
(logical) Should outdated interactions be recorded back to file. Default:
FALSE
warn_on_empty
Warn when ejecting the cassette if no interactions have been recorded.
Method print()
print method for Cassette
objects