parroty / exvcr

HTTP request/response recording library for elixir, inspired by VCR.
MIT License
727 stars 132 forks source link

ExVCR.RequestNotMatchError - Ignore / bypass the request not matching recorded cassette #101

Open manjufy opened 7 years ago

manjufy commented 7 years ago

This happens when we have multiple requests in the test suite

  ** (EXIT from #PID<0.3049.0>) an exception was raised:
         ** (ExVCR.RequestNotMatchError) Request did not match with any one in the current cassette: test/fixture/vcr_cassettes/response.json.
     Delete the current cassette with [mix vcr.delete] and re-record.

     Request: [:get, "https://example.com", [], "", []]

Its clear from the above exception that, there are two requests. My test suite suppose to catch the second request and match the cassette response.

Would it be possible to do following

Ignore the request response if it does not match the cassette name use_cassette "contentful-cache"

In my case, its clear that the first response would not match the my cassette response at all.... in this case, if I could do bypass the request until I find the request that matches my recorded response then we would not have inconsistent behaviour with cassettes..

I have seen multiple issues raised here

https://github.com/parroty/exvcr/issues/96 https://github.com/parroty/exvcr/issues/81 https://github.com/parroty/exvcr/issues/53

When we run the tests independently, they work fine. Ex: mix test test/model_test.exs

However, when we run the entire test suite Ex: mix test

we would have this issue with multiple requests not matching the cassettes.

parroty commented 7 years ago

Thanks for the comment. Having the bypass option suggested for #96 satisfies your expectation?

I couldn't clearly understand this part. Some more description or example helps too.

Would it be possible to do following Ignore the request response if it does not match the cassette name use_cassette "contentful-cache"