insert_example_cassette | R Documentation |
insert_example_cassette()
is a wrapper around insert_cassette()
that
stores cassettes in inst/_vcr/
. Call it in the first line of your examples
(typically wrapped in \dontshow{}
), and call eject_cassette()
on the
last line.
Run the example manually once to record the vignettte, then it will be
replayed during R CMD check
, ensuring that your example no longer uses
the internet.
insert_example_cassette(
name,
package,
record = NULL,
match_requests_on = NULL,
serialize_with = NULL,
preserve_exact_body_bytes = NULL,
re_record_interval = NULL
)
name |
The name of the cassette. This is used to name a file on disk, so it must be valid file name. |
package |
Package name. |
record |
Record mode. This will be To re-record all cassettes, you can delete |
match_requests_on |
Character vector of request matchers used to
determine which recorded HTTP interaction to replay. The default matches
on the The full set of possible values are:
If more than one is specified, all components must match in order for the
request to match. If not supplied, defaults to Note that the request header and body will only be included in the
cassette if |
serialize_with |
(string) Which serializer to use:
|
preserve_exact_body_bytes |
(logical) Force a binary (base64)
representation of the request and response bodies? By default, vcr
will look at the |
re_record_interval |
(integer) How frequently (in seconds) the
cassette should be re-recorded. Default: |
# In this example I'm showing the insert and eject commands, but you'd
# usually wrap these in \dontshow{} so the user doesn't see them and
# think that they're something they need to copy.
insert_example_cassette("httpbin-get", package = "vcr")
req <- httr2::request("https://hb.cran.dev/get")
resp <- httr2::req_perform(req)
str(httr2::resp_body_json(resp))
eject_cassette()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.