Closed maelle closed 3 years ago
vcr has something that may address this already, see e.g., in the Ruby vcr docs https://relishapp.com/vcr/vcr/v/5-1-0/docs/request-matching/playback-repeats
and we have that arg in this pkg https://docs.ropensci.org/vcr/reference/use_cassette.html - I've not used it yet, so can't be 100% certain it works as intended, so would be good to try
Oh actually the default behavior is the right one, awesome.
See the test of gh_organizations()
in https://github.com/maelle/exemplighratia/pull/8, I think it fails once and then succeeds.
So I'm a bit undecided regarding what to encourage folks to use
Maybe the book should just mention both. webmockr allows more flexibility in how you define a sequence, but it's a new thing to learn after making the effort to understand vcr and cassettes. :thinking:
Oh actually the default behavior is the right one
of? do you mean the default value for allow_playback_repeats
parameter?
Yes, I didn't have to change anything
I think this can be closed, it works and it's documented in https://docs.ropensci.org/vcr/articles/cassette-manual-editing.html#example-2-test-using-an-edited-cassette-with-a-503-then-a-200-1
Context: At the moment for faking some behavior of the server (e.g. an error, or simpler responses to decrease the fixture size) one needs to use webmockr. This is not ideal as it's quite different from vcr.
One alternative is
It's quite handy IMHO.
Now, one thing that this workflow can't handle is testing retries. So I wonder whether there'd be a way to add a field "count" to the fixture and e.g. have
and vcr would loop through the responses?