vcr 0.5.4
NEW FEATURES
- Error messages when tests using vcr fail are now simpler, primarily to reduce the space error messages take up. The user can toggle whether they get the new simplified error messages or the older format more verbose messages using the
verbose_errors
setting in the vcr_configure()
function. In addition, vcr_last_error()
gives the last full error, but that doesn’t help in non-interactive mode; if in non-interactive mode, which most users will be in when running the entire test suite for a package, you can set an environment variable (VCR_VERBOSE_ERRORS
) to toggle this setting (e.g., Sys.setenv(VCR_VERBOSE_ERRORS=TRUE); devtools::test()
) (#121) (#154)
MINOR IMPROVEMENTS
- changed
write_disk_path
handling internally to not run it through normalizePath
before recording it to the cassette; passing the path through normalizePath
was leading to the full path recorded in the cassette, which means in a package testing context that a test that uses a file on disk will (likely) only work on the machine the cassette was first created on. with relative paths in a package context, a test that has a file written on disk should now work in different testing contexts (locally, and various continuous integration platforms) (#135) (#166)
- added a bit of documentation about large files created when using vcr, and how to ignore them if needed within
.Rinstignore
and/or .Rbuildignore
(#164)
vcr 0.5.0
NEW FEATURES
- new function
check_cassette_names
to use in your helper-pkgname.R
file in your test suite; it checks for duplicated cassette names only. Any use of insert_cassette()
(thereby, any use of use_cassette()
) uses a revamped version of an internal fxn that checks for an improved list of potential problems in cassette names (#116) (#159)
use_vcr()
adds gitignore cassette diffs via the addition of a gitattributes
file (#109)
vcr_configure()
overhaul: function no longer has each setting as a parameter; rather, it has an ellipsis (...
), and internally we check parameters passed in. The documentation (?vcr_configure
) lists the details for each available parameter. Importantly, each call to vcr_configure()
now only changes the vcr settings for parameters passed in to the function; to reset all vcr settings, run vcr_configure_reset()
(#136) (#141)
insert_cassette()
and use_cassette()
now inherit any vcr settings set by vcr_configure()
; this wasn’t happening consistently before. Most default parameter values in insert_cassette/use_cassette
set to NULL
, in which case they inherit from whatever values are set by vcr_configure()
, but can be overriden (#151) (#153)
MINOR IMPROVEMENTS
- define serialize, cassette, and fixture in the README (#138) (#139)
- fix
filter_sensitive_data
parameter description in vcr_configure
docs (#129)
- move higher up in README a brief description of what this package does (#140)
- import
utils::getParseData
so its in namespace (#142)
- better cleanup of some stray test files left on disk (#148)
use_vcr()
no longer uses context()
in example test file (#144)
- improved documentation of functions and environment variables for turning vcr on and off and when to use each of them - documentation mostly in the HTTP Testing book at https://books.ropensci.org/http-testing/lightswitch.html (#131)
- fix a
use_cassette
test (#133)
- Add assertions to
vcr_configure()
when parameters are set by the user to fail early (#156)
BUG FIXES
- fix for handling of http requests that request image data AND do not write that data to disk; in addition, fix usage of
preserve_exact_body_bytes
when image data is in the response body (#128) thanks @Rekyt
- vcr now should handle request bodies correctly on POST requests (#143)
- Request matching was failing for empty bodies when “body” was one of the matchers (#157) (#161)
- fix to
sensitive_remove()
internal function used when the user sets filter_sensitive_data
in vcr_configure()
; when an env var is missing in the filter_sensitive_data
list, sensitive_remove()
was causing C stack errors in some cases (#160) thanks @zachary-foster
- fix for recording JSON-encoded bodies; vcr wasn’t handling HTTP requests when the user set the body to be encoded as JSON (e.g.,
encode="json"
with crul or httr) (#130)
vcr 0.4.0
NEW FEATURES
- vcr now can handle requests from both
crul
and httr
that write to disk; crul
supports this with the disk
parameter and httr
through the write_disk()
function; see the section on mocking writing to disk in the http testing book https://books.ropensci.org/http-testing/vcr-usage.html#vcr-disk; also see ?mocking-disk-writing
within webmockr
for mocking writing to disk without using vcr
, and the section in the http testing book https://books.ropensci.org/http-testing/webmockr-stubs.html#webmockr-disk (#81) (#125)
- vcr gains ability to completely turn off vcr for your test suite even if you’re using
vcr::use_cassette
/vcr::insert_cassette
; this is helpful if you want to run tests both with and without vcr; workflows are supported both for setting env vars on the command line as well as working interactively within R; see ?lightswitch
for details (#37)
- ignoring requests now works, with some caveats: it only works for now with
crul
(not httr
), and works for ignoring specifc hosts, and localhosts, but not for custom callbacks. See the vcr configuration vignette https://docs.ropensci.org/vcr/articles/configuration.html#ignoring-some-requests for discussion and examples (#127)
MINOR IMPROVEMENTS
- documentation for R6 classes should be much better now; roxygen2 now officially supports R6 classes (#123)
- added minimal cassette name checking; no spaces allowed and no file extensions allowed; more checks may be added later (#106)
BUG FIXES
- fix handling of http response bodies that are images; we were converting raw class bodies into character, which was causing images to error, which can’t be converted to character; we now check if a body can be converted to character or not and if not, leave it as is (#112) (#119) thanks @Rekyt for the report
- simple auth with package
httr
wasn’t working (htrr::authenticate()
); we were not capturing use of authenticate
; it’s been solved now (#113)
- we were not properly capturing request bodies with package
httr
requests; that’s been fixed (#122)
- httr adapter was failing on second run, reading a cached response. fixed now (#124)
response_summary()
fixed; this function prints a summary of the http response body; sometimes this function would fail with multibyte string error because the gsub
call would change the encoding, then would fail on the substring
call; we now set useBytes = TRUE
in the gsub
call to avoid this problem (#126)
vcr 0.3.0
NEW FEATURES
- new internal method
up_to_date_interactions
in cassette_class
now allows filtering cassettes by user specified date (#96) (#104)
- re-recording now works - see new
use_casette()
parameters re_record_interval
and clean_outdated_http_interactions
; you can now set a re-record interval (in seconds) so that you can for example always re-record cassettes if you don’t want cassettes to be more than X days old; depends on new internal method up_to_date_interactions
(#104) (#105)
MINOR IMPROVEMENTS
- fix link to HTTP Testing Book: ropensci -> ropenscilabs (#100)
- add new section to HTTP Testing Book on “vcr enabled testing” with sub-sections on check vs. test, your package on CRAN, and your package on continuous integration sites (#102)
BUG FIXES
- fix request body matching - partly through fixes to
webmockr
package (requires v0.4 or greater); more generally, makes single type request matching (e.g., just HTTP method, or just URL) possible, it was not working before, but is now working; added examples of doing single type matching (#70) (#76) (#108)
- fixed type in
cassette_class
where typo lead to not setting headers correctly in the webmockr::wi_th()
call (#107)
vcr 0.2.6
NEW FEATURES
- gains function
use_vcr()
to setup vcr
for your package. This requires 3 pkgs all in Suggests; so are not required if you don’t need to use use_vcr()
(#52) (#95) thanks @maelle for the feedback!
vcr
actually supports all four recording modes: none
, once
, new_episodes
, and all
. once
is what’s used by default. See ?recording
for description of the recording modes. For now the test file test-ause_cassette_record_modes.R gives some examples and what to expect for each record mode; in the future the http testing book will have much more information in the Record modes chapter https://books.ropensci.org/http-testing/record-modes.html (commit)
MINOR IMPROVEMENTS
- lots of tidying for better/consistent style
- fix for a partial argument call in
as.list()
: all
to all.names
(commit)
BUG FIXES
- error thrown with
httr
due to wrong date format. the problem was in the webmockr
package. see ropensci/webmockr#58 (#91) thanks @Bisaloo
- fix for
use_cassette()
when using httr
: we weren’t collecting status_code
and storing it with the cassette (#92) thanks @Bisaloo
- fixes for
use_cassette()
for httr
: was working fine with a single httr request, but not with 2 or more (#93) (#94) thanks @Rekyt
- in error blocks with
use_cassette()
the URL is presented from the request, and if there’s a secret (API key) in the URL as a query parameter (or in any other place in the URL) then that secret is shown to the world (including if the error block happens on CI on the public web). This is fixed now; we use directives from your filter_sensitive_data
call in vcr_configure()
to mask secrets in error messages (#89) (#90)
vcr 0.2.2
MINOR IMPROVEMENTS
- typo fixes (#85) thanks @Rekyt
- added to docs: at least one person has reported different results using
vcr
with devtools::check
vs. devtools::test
(#83)
- changed suggested usage of
vcr
in test suites from use_cassette
block wrapped in test_that
to the other way around; leads to testthat
pointing to the actual test line that failed rather than pointing to the start of the use_cassette
block (#86)
BUG FIXES
- Fix for
%||%
internal function. Was incorrectly doing logical comparison; when headers list was passed one or more of the tests in the if statement had length > 1. Dev R is testing for this (#87)
vcr 0.2.0
NEW FEATURES
- gains support for the
httr
package. vcr
now supports crul
and httr
. Some of the integration for httr
is via webmockr
, while some of the tooling resides here in vcr
(#73) (#79)
BUG FIXES
- fix handling of response bodies when not raw type (#77) (#78)
vcr 0.1.0
NEW FEATURES