Skip to contents

List cassettes, get current cassette, etc.

Usage

cassettes(on_disk = TRUE, verb = FALSE)

current_cassette()

cassette_path()

Arguments

on_disk

(logical) Check for cassettes on disk + cassettes in session (TRUE), or check for only cassettes in session (FALSE). Default: TRUE

verb

(logical) verbose messages

Details

  • cassettes(): returns cassettes found in your R session, you can toggle whether we pull from those on disk or not

  • current_cassette(): returns an empty list when no cassettes are in use, while it returns the current cassette (a Cassette object) when one is in use

  • cassette_path(): just gives you the current directory path where cassettes will be stored

Examples

vcr_configure(dir = tempdir())
#> <vcr configuration>
#>   Cassette Dir: /tmp/RtmpV0XHMo
#>   Record: once
#>   Serialize with: yaml
#>   URI Parser: crul::url_parse
#>   Match Requests on: method, uri
#>   Preserve Bytes?: FALSE
#>   Logging?: FALSE
#>   ignored hosts: 
#>   ignore localhost?: FALSE
#>   Write disk path: 

# list all cassettes
cassettes()
#> list()
cassettes(on_disk = FALSE)
#> list()

# list the currently active cassette
insert_cassette("stuffthings")
#> <vcr - Cassette> stuffthings
#>   Record method: once
#>   Serialize with: yaml
#>   Persist with: FileSystem
#>   Re-record interval (s): 
#>   Clean outdated interactions?: FALSE
#>   update_content_length_header: FALSE
#>   allow_playback_repeats: FALSE
#>   allow_unused_http_interactions: 
#>   exclusive: 
#>   preserve_exact_body_bytes: FALSE
current_cassette()
#> <vcr - Cassette> stuffthings
#>   Record method: once
#>   Serialize with: yaml
#>   Persist with: FileSystem
#>   Re-record interval (s): 
#>   Clean outdated interactions?: FALSE
#>   update_content_length_header: FALSE
#>   allow_playback_repeats: FALSE
#>   allow_unused_http_interactions: 
#>   exclusive: 
#>   preserve_exact_body_bytes: FALSE
eject_cassette()
#> Warning: Empty cassette (stuffthings) deleted; consider the following:
#>  - If an error occurred resolve that first, then check:
#>  - vcr only supports crul, httr & httr2; requests w/ curl, download.file, etc. are not supported
#>  - If you are using crul/httr/httr2, are you sure you made an HTTP request?
#> net connect disabled
#> <vcr - Cassette> stuffthings
#>   Record method: once
#>   Serialize with: yaml
#>   Persist with: FileSystem
#>   Re-record interval (s): 
#>   Clean outdated interactions?: FALSE
#>   update_content_length_header: FALSE
#>   allow_playback_repeats: FALSE
#>   allow_unused_http_interactions: 
#>   exclusive: 
#>   preserve_exact_body_bytes: FALSE

cassettes()
#> list()
cassettes(on_disk = FALSE)
#> list()

# list the path to cassettes
cassette_path()
#> [1] "/tmp/RtmpV0XHMo"
vcr_configure(dir = file.path(tempdir(), "foo"))
#> <vcr configuration>
#>   Cassette Dir: /tmp/RtmpV0XHMo/foo
#>   Record: once
#>   Serialize with: yaml
#>   URI Parser: crul::url_parse
#>   Match Requests on: method, uri
#>   Preserve Bytes?: FALSE
#>   Logging?: FALSE
#>   ignored hosts: 
#>   ignore localhost?: FALSE
#>   Write disk path: 
cassette_path()
#> [1] "/tmp/RtmpV0XHMo/foo"

vcr_configure_reset()