File: vcr.R

package info (click to toggle)
r-cran-vcr 0.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,360 kB
  • sloc: cpp: 15; sh: 13; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 2,207 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
## ----echo=FALSE---------------------------------------------------------------
knitr::opts_chunk$set(
	comment = "#>",
	collapse = TRUE,
	warning = FALSE,
	message = FALSE,
  eval = FALSE
)

## ----eval=FALSE---------------------------------------------------------------
#  install.packages("vcr")

## ----eval=FALSE---------------------------------------------------------------
#  remotes::install_github("ropensci/vcr")

## -----------------------------------------------------------------------------
#  library("vcr")

## ---- echo=FALSE, message=FALSE-----------------------------------------------
library("vcr")

## ----echo=FALSE, results='hide', eval=identical(Sys.getenv("IN_PKGDOWN"), "true")----
#  suppressPackageStartupMessages(require(vcr, quietly = TRUE))
#  unlink(file.path(cassette_path(), "helloworld.yml"))
#  vcr_configure(dir = tempdir())

## ---- eval=identical(Sys.getenv("IN_PKGDOWN"), "true")------------------------
#  library(vcr)
#  library(crul)
#  
#  cli <- crul::HttpClient$new(url = "https://eu.httpbin.org")
#  system.time(
#    use_cassette(name = "helloworld", {
#      cli$get("get")
#    })
#  )

## ---- eval=identical(Sys.getenv("IN_PKGDOWN"), "true")------------------------
#  system.time(
#    use_cassette(name = "helloworld", {
#      cli$get("get")
#    })
#  )

## ----echo=FALSE, eval=identical(Sys.getenv("IN_PKGDOWN"), "true")-------------
#  unlink(file.path(cassette_path(), "helloworld.yml"))

## ---- echo = FALSE, results='asis', collapse=TRUE-----------------------------
defaults <- rev(vcr_config_defaults())
defaults[unlist(lapply(defaults, is.character))] <- paste0('"', defaults[unlist(lapply(defaults, is.character))], '"')
cat(sprintf("* %s = `%s`\n", names(defaults), defaults))

## -----------------------------------------------------------------------------
vcr_configuration()

## ----echo=FALSE---------------------------------------------------------------
unlink(file.path(cassette_path(), "one.yml"))

## ----eval = FALSE-------------------------------------------------------------
#  use_cassette(name = "one", {
#      cli$post("post", body = list(a = 5))
#    },
#    match_requests_on = c('method', 'headers', 'body')
#  )