I was having trouble getting VCR to re-record cassettes, so I tried deleting the cassette altogether, and was shocked to find my test suite continued passing. How is this possible? My understanding is that the cassettes are the fixtures used to simulate external API calls. Without them, it should actually hit the API and save a new cassette. Here's my vcr.rb
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/fixtures/vcr'
c.hook_into :webmock
c.default_cassette_options = { serialize_with: :json, record: :once }
c.debug_logger = File.open(Rails.root.join('log', 'vcr.log'), 'a')
c.filter_sensitive_data('---WUNDERGROUND_KEY---') { ENV['WUNDERGROUND_KEY'] }
end
Here's one of the mysteriously passing tests:
require 'spec_helper'
describe WeatherMan do
describe ".current_outdoor_temp" do
it "returns current outdoor temperature from Wunderground API" do
VCR.use_cassette('wunderground') do
temperature = WeatherMan.current_outdoor_temp(10004, 0)
expect(temperature).to be_a Numeric
end
end
end
end