VCR not using cassette in rails system test

In the following test:

require "application_system_test_case"

class ImportTest < ApplicationSystemTestCase
  test "importing vacancy succeeds" do
    VCR.use_cassette("import_success", record: :all) do
      user = users(:role)

      visit new_externals_path

      within "form.form" do
        fill_in "External ID", with: "57524"

        click_on "Import Vacancy"

      # TODO: Check that the imported vacancy is displayed

If I turn on debug logging VCR outputs the following:

[Cassette: 'import_success'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 0 interaction(s): {  }
[webmock] Identified request type (recordable) for [post]
[webmock] Handling request: [post] (disabled: false)
[webmock] Identified request type (unhandled) for [post]

Rails don’t find a cassette and ask me to provide one which I simply cannot understand.

Crossposted from StackOverflow: ruby - VCR not using cassette in rails system test - Stack Overflow

The solution is to use a setup/teardown I have no idea why that is required but I guess it VCR needs to be registered before puma starts up or something.

setup do
  VCR.insert_cassette("path/#{@NAME}", record: :new_episodes)

 teardown do

Good you solved it yourself. Btw: nice haircut :wink:

Mr. Finger!! Long time no see! My hair is longer than how long it was since I saw you last.

It has been a little complicated getting haircuts during the lockdown :joy:

How are you sir?

Doing ok, suffering through the German winter (we were crazy enough to move to Köln last year) and the whole pandemic. And yeah, I also haven’t been at a hairdresser between Dezember 2019 and August 2021 :see_no_evil:

Where are you living now: Sweden or Berlin?