Open maelle opened 4 years ago
i know less than nothing about knitr engines, so can't help there, but i don't see why one couldn't use vcr for vignettes. i guess there's caching in vignettes already, so would the use case be that a person would want the code in the vignette to run rather than being fully cached except wanting the HTTP requests/responses to be cached so those don't fail?
right not sure how much it brings compared to knitr caching :thinking:
it's probably a good thing to have all non http request code run each time as long as it isn't super long time in case any dependencies/pkg code changes?
see also #20
it's probably a good thing to have all non http request code run each time as long as it isn't super long time in case any dependencies/pkg code changes?
Right.
A downside I was thinking about is the size of cassettes but maybe one could re-use some of the test cassettes to have less cassettes overall. :thinking:
maybe one could re-use some of the test cassettes
could definitely try this. though what if a test cassette is quite old, and the package maintainer doesn't realise this?
then they should use re-record :wink: but yeah you're right.
true
What httptest supports https://enpiar.com/r/httptest/articles/vignettes.html
with vcr I suppose it'd mean running inject_cassette()
at the beginning of the vignette and eject_cassette()
at the end.
yeah, that would work
Can I ask if there's been progress on this front?
I've been using vcr for testing my package, and it's been pretty easy, so thanks so much for a wonderful package!
I do think it would be helpful to add automated stubbing for vignettes without a need for too much extra code! inject
/eject
logic sounds good to (naive) me.
Thanks for the bump @dtm2451 And thx for using the pkg.
In the latest version on cran, now the insert_cassette()
/eject_cassette()
workflow works, so you can start using vcr in your vignette by running insert_cassette()
and then stop using it somewhere else with eject_cassette()
- you could hide those in the output of the vignette so reader doesn't know its happening
And for location of files, set up with vcr_configure()
https://docs.ropensci.org/vcr/reference/vcr_configure.html
Let us know if it works!
Worked! Simple to set up based off of the vcr_configure()
code I already had for testing, & I was able to knit my vignette with my internet connection turned off after running it once with my internet on. Entire R CMD Check process worked with internet off =).
Would you mind sharing a link to your package?
Great, glad it works!
And if so how could the setup work? Could there be a vcr knitr engine, so one would write