Small helper to conditionally re-record VCR cassettes

Posted . Visible to the public.

I find it annoying to iterate on a spec that relies on a recorded VCR casette Show archive.org snapshot . You constantly have to remove the same YAMLs file before you can re-run that still-red test.

With this little helper, you (or your coding agent) can do the same with RE_RECORD_VCR=true bundle exec rspec spec/path/to/recorded_spec.rb:

# spec/support/vcr.rb
RSpec.configure do |config|
  config.around(:each, :vcr) do |example|
    options[:record] = :all if %w[true 1].include?(ENV['RE_RECORD_VCR'])
  end
end
Profile picture of Michael Leimstädtner
Michael Leimstädtner
Last edit
Michael Leimstädtner
License
Source code in this card is licensed under the MIT License.
Posted by Michael Leimstädtner to makandra dev (2026-04-13 09:48)