You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://www.repostatus.org/#active)
[](https://www.repostatus.org/#active)
{vcr} records and replays HTTP requests so you can test your API package
19
-
with speed and confidence. It makes your tests independent of your
20
-
internet connection (so they work on CRAN!) and because your tests get
21
-
much much faster, you can write even more, increasing the coverage of
22
-
your package. {vcr} works with {crul}, {httr} and {httr2}.
11
+
{vcr} records and replays HTTP requests so you can test your API package with speed and confidence. It makes your tests independent of your internet connection (so they work on CRAN!) and because your tests get much much faster, you can write even more, increasing the coverage of your package. {vcr} works with {crul}, {httr} and {httr2}.
23
12
24
-
{vcr} draws inspiration from Ruby’s [vcr](https://github.com/vcr/vcr).
13
+
{vcr} draws inspiration from Ruby's [vcr](https://github.com/vcr/vcr).
25
14
26
15
## Installation
27
16
17
+
28
18
```r
29
19
# Install the latest released version from CRAN
30
20
install.packages("vcr")
@@ -43,11 +33,8 @@ pak::pak("ropensci/vcr")
43
33
44
34
## Usage
45
35
46
-
Using vcr in a test is straightforward: just call
47
-
`vcr::local_cassette()`. The first time your test is run, vcr will
48
-
automatically record every HTTP request, saving the request and reponse
49
-
in `tests/testthat/_vcr`. After that, it will replay those recorded
50
-
requests, meaning that your test no longer needs an active connection.
36
+
Using vcr in a test is straightforward: just call `vcr::local_cassette()`. The first time your test is run, vcr will automatically record every HTTP request, saving the request and reponse in `tests/testthat/_vcr`. After that, it will replay those recorded requests, meaning that your test no longer needs an active connection.
37
+
51
38
52
39
```r
53
40
test_that("can retrieve current version", {
@@ -56,12 +43,9 @@ test_that("can retrieve current version", {
56
43
})
57
44
```
58
45
59
-
The first argument to `local_cassette()` is the cassette name: it’s used
60
-
to name the cassette file so needs to be unique across tests. In this
61
-
case, running the above test will generate
62
-
`tests/testthat/_vcr/rl_version.yaml` which looks something like this:
46
+
The first argument to `local_cassette()` is the cassette name: it's used to name the cassette file so needs to be unique across tests. In this case, running the above test will generate `tests/testthat/_vcr/rl_version.yaml` which looks something like this:
63
47
64
-
```yaml
48
+
```yaml
65
49
http_interactions:
66
50
- request:
67
51
method: GET
@@ -80,26 +64,15 @@ http_interactions:
80
64
recorded_with: VCR-vcr/2.0.0
81
65
```
82
66
83
-
If you look carefully at this file, you’ll notice an `Authorization`
84
-
header is not recorded in the request headers despite it being used in
85
-
the actual HTTP request. Read more about protecting secrets in the
86
-
vignette `vignette("secrets")`.
67
+
If you look carefully at this file, you'll notice an `Authorization` header is not recorded in the request headers despite it being used in the actual HTTP request. Read more about protecting secrets in the vignette `vignette("secrets")`.
87
68
88
69
## Learn more
89
70
90
-
Start with `vignette("vcr")` to learn more about how {vcr} works,
91
-
especially how requests are matched to the recordeded cassette. You
92
-
might also enjoy the [HTTP
93
-
testing](https://books.ropensci.org/http-testing/) book for a lot more
94
-
details about {vcr}, {webmockr}, {curl} and more.
71
+
Start with `vignette("vcr")` to learn more about how {vcr} works, especially how requests are matched to the recordeded cassette. You might also enjoy the [HTTP testing](https://books.ropensci.org/http-testing/) book for a lot more details about {vcr}, {webmockr}, {curl} and more.
- Please note that this package is released with a [Contributor Code of
104
-
Conduct](https://ropensci.org/code-of-conduct/). By contributing to
105
-
this project, you agree to abide by its terms.
75
+
* Please [report any issues or bugs](https://github.com/ropensci/vcr/issues)
76
+
* License: MIT
77
+
* Get citation information for `vcr` in R doing `citation(package = 'vcr')`
78
+
* Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.
0 commit comments