Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could one use vcr for vignettes? #150

Open
maelle opened this issue Feb 11, 2020 · 16 comments
Open

Could one use vcr for vignettes? #150

maelle opened this issue Feb 11, 2020 · 16 comments
Labels

Comments

@maelle
Copy link
Member

maelle commented Feb 11, 2020

And if so how could the setup work? Could there be a vcr knitr engine, so one would write

```vcr
my code with http requests
```

and fixtures would be saved somewhere?

@sckott
Copy link
Collaborator

sckott commented Feb 11, 2020

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?

@maelle
Copy link
Member Author

maelle commented Feb 11, 2020

right not sure how much it brings compared to knitr caching 🤔

@sckott
Copy link
Collaborator

sckott commented Feb 11, 2020

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?

@sckott
Copy link
Collaborator

sckott commented Feb 13, 2020

see also #20

@maelle
Copy link
Member Author

maelle commented Mar 24, 2020

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. 🤔

@sckott
Copy link
Collaborator

sckott commented Mar 24, 2020

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?

@maelle
Copy link
Member Author

maelle commented Mar 24, 2020

then they should use re-record 😉 but yeah you're right.

@sckott
Copy link
Collaborator

sckott commented Mar 24, 2020

true

@maelle
Copy link
Member Author

maelle commented Nov 16, 2020

What httptest supports https://enpiar.com/r/httptest/articles/vignettes.html

@maelle
Copy link
Member Author

maelle commented Nov 22, 2020

with vcr I suppose it'd mean running inject_cassette() at the beginning of the vignette and eject_cassette() at the end.

@sckott
Copy link
Collaborator

sckott commented Nov 24, 2020

yeah, that would work

@dtm2451
Copy link

dtm2451 commented Dec 14, 2020

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.

@sckott
Copy link
Collaborator

sckott commented Dec 15, 2020

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!

@dtm2451
Copy link

dtm2451 commented Dec 15, 2020

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 =).

@maelle
Copy link
Member Author

maelle commented Dec 15, 2020

Would you mind sharing a link to your package?

@sckott
Copy link
Collaborator

sckott commented Dec 15, 2020

Great, glad it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants