diff --git a/module3/lessons/testing_tools_for_api_consumption.md b/module3/lessons/testing_tools_for_api_consumption.md index d5c60fe5..513684d8 100644 --- a/module3/lessons/testing_tools_for_api_consumption.md +++ b/module3/lessons/testing_tools_for_api_consumption.md @@ -463,6 +463,20 @@ end This example uses a "default cassette options" flag, setting a re-record interval of 7 days for all cassettes. You can still override this on individual tests which use `VCR.use_cassette()`, so you could set a general flag of, say, `30.days` but a particular test could be set to `7.days` instead to expire earlier. +## What if I don't want to stub a request? + +When VCR is installed, it will assume you want to block every network request in all of your tests. Sometimes though, we don't want VCR to interrupt the network call. We can add an additional line of configuration to prevent VCR from throwing an error when we're intentionally trying to make an API call. +```ruby +VCR.configure do |config| + config.cassette_library_dir = 'spec/fixtures/vcr_cassettes' + config.hook_into :webmock + config.filter_sensitive_data('DONT_SHARE_MY_PROPUBLIC_SECRET_KEY') { Rails.application.credentials.propublica[:key] } + config.default_cassette_options = { re_record_interval: 7.days } + config.configure_rspec_metadata! + config.allow_http_connectins_when_no_cassette = true +end +``` + ## Checks for Understanding - What are some reasons we don't want our tests to make real API calls?