Skip to content

Conversation

@maelle
Copy link
Member

@maelle maelle commented Aug 26, 2025

cc @drmowinckels

This is not tested and not enough.

When I try to run examples that use vcr when VCR is off, I get the error:

Error in `cassette$file()`:
! attempt to apply non-function

from https://github.com/ropensci/vcr/blob/42fad406bf43519ffa535ee2316082339fc3bbf8/R/examples.R#L61C3-L61C26

So some earlier escaping is needed.

But a remaining problem is that if no cassette is inserted, vcr::eject_cassette() errors.

In local_cassette(), the ejecting function is called conditionally.

if (!is.null(cassette)) {

Maybe vcr::eject_cassette() should also have an early return() when vcr is off? Thoughts?

@sckott
Copy link
Collaborator

sckott commented Sep 9, 2025

thanks @maelle

@maelle
Copy link
Member Author

maelle commented Oct 2, 2025

@sckott do you think this is a correct fix?

@sckott
Copy link
Collaborator

sckott commented Oct 2, 2025

Sorry for delay @maelle - I was trying to figure it out locally for a while, then got busy with work and life. I'll look again ASAP

@maelle
Copy link
Member Author

maelle commented Oct 13, 2025

Friendly reminder, but no pressure 😸

Copy link
Collaborator

@sckott sckott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @maelle can you review now? Added the eject_cassette early return, and added a test. What do you think?

Copy link
Member Author

@maelle maelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!!

@@ -0,0 +1,22 @@
test_that("insert_example_cassette works as expected", {
withr::with_envvar(new = c("VCR_TURN_OFF" = "true"), {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be skipped if offline

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, or maybe we use webfakes to ping a local server, ill try both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants