4

I'm attempting to do RSpec feature tests on an external API.

My VCR config is as follows:

VCR.configure do |config|
  config.cassette_library_dir = 'spec/vcr'
  config.hook_into :webmock
  config.ignore_localhost = true
end

My test looks like this:

feature 'Visitor' do

  scenario 'performs an archival', :clean => false, :js => true do 
    mock_login
    visit '/dashboard'
    click_link 'Test Company'
    VCR.use_cassette('feature/archive') do
      within '.nav-app' do 
        click_button 'Quicksave' 
      end
    end
  end

  scenario 'performs a restore', :js => true do
    mock_login
    visit '/dashboard'
    click_link 'Test Company'
    VCR.use_cassette('feature/restore') do
      within '.nav-app' do 
        click_button 'Quickload' 
      end
    end
  end

end

The archive cassette is created just fine, however the restore cassette throws an error:

An HTTP request has been made that VCR does not know how to handle:

GET http://SomeApiUrl/...

There is currently no cassette in use.

I've obviously told VCR to create and use another cassette with:

VCR.use_cassette('feature/restore')

So what gives?

It's also worth mentioning that I still receive this error even when I clean out my cassette folder and start fresh.

Tristan
  • 43
  • 4

2 Answers2

0

Try passing , :record => :new_episodes as an argument to use_cassete. If you don’t use the record new episodes. It thinks they are the same request.

Noah
  • 550
  • 2
  • 8
  • Appreciate the suggestion, but I've tried that to no avail. Same exact error message occurs regardless. – Tristan Jan 31 '19 at 07:02
  • @Tristan maybe you are calling an api outside of those VCR wrapping. Try wrapping the whole tests with use_cassette. Also, does the error have a line number? – Noah Jan 31 '19 at 07:10
0

Turns out I'm dumb. The issue seemed to be that I was using the filename vcr.rb to configure VCR; I figured it wouldn't matter being that it was in my spec/support folder, but that was not the case.

A simple rename to vcr_config.rb fixed the problem right up...

Tristan
  • 43
  • 4