1

The vcr gem is awesome for speeding up a test suite that calls an external API...

What is the best procedure to check that the test suite would still pass if VCR is not used? Is there any default way to pass an environment variable or flag to skip VCR, using guard-rspec?

Or should I just wrap the VCR init block in a conditional checking an environment variable?

# spec/support/vcr.rb
require 'vcr'

unless ENV['SKIP_VCR'] && ENV['SKIP_VCR'].casecmp('YES') == 0
  puts "Using VCR to speed up test suite!"
  VCR.configure do |c|
    c.cassette_library_dir = 'spec/cassettes'
    c.hook_into :fakeweb
    c.ignore_localhost = true
    c.configure_rspec_metadata!
  end
end
justingordon
  • 12,553
  • 12
  • 72
  • 116

0 Answers0