VCR 在 rails 系统测试中未使用磁带

VCR not using cassette in rails system 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)
      sign_in(user)

      visit new_externals_path

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

        click_on "Import Vacancy"
      end

      # TODO: Check that the imported vacancy is displayed
    end
  end
end

如果我打开调试日志记录 VCR 输出以下内容:

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

Rails找不到卡带要我提供一个我根本看不懂

似乎唯一的方法是添加以下内容:

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

teardown do
  VCR.eject_cassette
end