parroty / exvcr

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

Cassette is not ejected after the test #72

Open gmile opened 8 years ago

gmile commented 8 years ago

Right now this happens:

  1. I have a file with multiple test cases,
  2. each case is wrapped into with use_cassette/2 macro,
  3. bottom-most test case is called X,
  4. I add a new test case Y that performs HTTP request, but I forget to wrap it into a use_cassette/2 macro,
  5. I run the tests,
  6. test case Y fails with a message: "cassette from test case X doesn't contain a response matching a request from Y".

This can be seen in this PR: https://github.com/robconery/stripity-stripe/pull/80 Here's a failing travis build: https://travis-ci.org/robconery/stripity-stripe/builds/153164601

bravely commented 7 years ago

I'm having this issue as well. Got an entire other spec failing because a separate file did not eject.

wstucco commented 6 years ago

One solution that seem to work is to add options: [clear_mock: true] at the end of the import

For example

use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney

becomes

use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney, options: [clear_mock: true]

You have to add it everytime you use ExVCR or some cassette keeps lying around

As I've said, I'm not sure this is the solution, it's just working for me ATM