Created
August 31, 2021 20:44
-
-
Save mmirus/acfb378356ede49da38bc53c75883323 to your computer and use it in GitHub Desktop.
Revisions
-
mmirus created this gist
Aug 31, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ # # Find and delete unused cassettes # Save in spec/support/ # # Modified from examples found at https://github.com/vcr/vcr/issues/283 # module UsedCassetteReporter USED_CASSETTES = Set.new def insert_cassette(name, options = {}) USED_CASSETTES << VCR::Cassette.new(name, options).file super end end RSpec.configure do |config| config.after(:suite) do all_cassettes = Dir[File.join(VCR::Cassette::Persisters::FileSystem.storage_location, '**', '*.yml')].map do |d| File.expand_path(d) end unused_cassettes = all_cassettes - UsedCassetteReporter::USED_CASSETTES.to_a unless unused_cassettes.empty? puts "\nUnused cassettes to delete:" puts unused_cassettes unused_cassettes.each { |v| File.delete(v) } end end end