0

I have a test that looks like this.

RSpec.describe 'Modify visit summary letters', type: :system do
  scenario 'with one correspondence relationship' do
    VCR.use_cassette 'correspondence/faxes/valid_number' do
      # test steps omitted for brevity
    end
  end
end

This test normally passes just fine. But when I change a certain form from remote: false to remote: true (to be clear, I'm changing this and nothing else) the test stops working.

When I run my test after the remote: true change I get:

 VCR::Errors::UnhandledHTTPRequestError:                                                                                                                                            
                                                                                                                                                                                         
                                                                                                                                                                                         
        ================================================================================                                                                                                 
        An HTTP request has been made that VCR does not know how to handle:                                                                                                              
          POST https://rest.interfax.net/outbound/faxes?faxNumber=%2B15555555555                                                                                                         
                                                                                                                                                                                         
        There is currently no cassette in use.

It says there's no cassette in use even though, obviously, there is.

Why might this be happening and what can I do to fix it?

Edit: Here's my VCR config.

VCR.configure do |c|
  c.cassette_library_dir = 'spec/cassettes'
  c.hook_into :webmock
  c.ignore_localhost = true
  c.ignore_hosts 'chromedriver.storage.googleapis.com'

  c.default_cassette_options = {
    match_requests_on: [
      :method,
      VCR.request_matchers.uri_without_param('faxNumber')
    ]
  }
end
Jason Swett
  • 43,526
  • 67
  • 220
  • 351
  • One cause of that message is when the request URL doesn't match the cassette URL. I can't think of why ``remote: true`` would affect that, but it's at least something to check against what's in the cassette. You can also turn debugging on for VCR by sticking ``c.debug_logger = $stderr`` in the VCR configuration block. That might suss out what's going on. – rmlockerd Sep 02 '20 at 19:37
  • Unfortunately that's not the case. The URL is the same. The debug output also didn't reveal anything that helped my understanding either, unfortunately. – Jason Swett Sep 02 '20 at 19:45
  • Could it have something to do with the request being async and running outside the thread handled by VCR? – max Sep 03 '20 at 08:18
  • @max That thought occurred to me - perhaps so. Not sure where to go from there though. – Jason Swett Sep 03 '20 at 15:17
  • VCR matches cassettes not only by URI, please provide your VCR config. – Greg Sep 07 '20 at 10:55
  • VCR config added. – Jason Swett Sep 07 '20 at 14:05

0 Answers0