exvcr icon indicating copy to clipboard operation
exvcr copied to clipboard

Cassette is not ejected after the test

Open gmile opened this issue 9 years ago • 2 comments

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

gmile avatar Aug 18 '16 08:08 gmile

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

bravely avatar Sep 08 '17 16:09 bravely

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

wstucco avatar Oct 24 '17 14:10 wstucco