0

I want to record the API response once and use is forever but it seems like VCR wants to re-record after sometime is elapsed.

I tried to google how to disable it. Found re_record_interval but it seems like not working.

My current VCS setup is spec/support/vcr_setup.rb

# frozen_string_literal: true

VCR.configure do |c|
  c.cassette_library_dir = 'spec/vcr'
  c.hook_into :webmock
  c.configure_rspec_metadata!
  c.allow_http_connections_when_no_cassette = false
  c.default_cassette_options = {
    record: :none,
    re_record_interval: nil,
    match_requests_on: %i[method uri],
    allow_playback_repeats: true
  }
  c.debug_logger = $stdout
end

This is the debug log from VCR

[Cassette: 'some-name./1:1:6:2:1:1'] Initialized with options: {:record=>:none, :record_on_error=>true, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:yaml, :persist_with=>:file_system, :re_record_interval=>nil, :allow_playback_repeats=>true}
Scraping url: some-url
[webmock] Handling request: [get some-url] (disabled: false)
  [Cassette: 'some-name/1:1:6:2:1:1'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 0 interaction(s): {  }
[webmock] Identified request type (unhandled) for [get some-url]

Note: There's a recorded file for which was getting an hour before but now VCR is trying to a new HTTP request and create a new record file.

Kshitij
  • 353
  • 3
  • 10

1 Answers1

0

After some debugging figured out that vcr file name was actually rpsec scope id. You can check the rspec metadata here for what scope id looks like. https://www.tutorialspoint.com/rspec/rspec_metadata.htm

scope_id is something like "1:1:6:2:1:1" which means 1st block > 1st block > 6th block and so on. You got the idea.

It means if you change the order of blocks in the spec file it would change the recorded file also.

Kshitij
  • 353
  • 3
  • 10