Smoke Tests and VCR Options
Explore how to use VCR options such as re_record_interval and record modes to manage external service API testing. Understand setting up smoke tests to verify integrations, ignore specific hosts, match dynamic requests, and protect sensitive data with dummy values. This lesson enables robust testing of third-party APIs using RSpec and VCR.
Smoke tests
So far, we’ve used VCR to record an interaction once and preserve it for all time. VCR provides other options. These options are passed as key-value arguments to VCR.use_cassette(re_record_interval: 7.days) or, if we’re using RSpec metadata, as the value part of the metadata, as in vcr: {re_record_interval: 7.days}.
The re_record_interval method
That re_record_interval we just used as an example allows us to use the same VCR test as both an integration and a smoke test. The re_record_interval is an amount of time. If the associated cassette requests are older than the interval, then VCR will attempt to reconnect to the HTTP server and re-record the cassette. If the server is unavailable, VCR will use the existing cassette.
This allows us to protect our ...