Created
October 15, 2014 23:25
-
-
Save dmitry/f4c7e4dbcf89673f5ede to your computer and use it in GitHub Desktop.
Cleanup VCR Cassettes
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 characters
require 'set' | |
USED_CASSETTES = Set.new | |
module CassetteReporter | |
def insert_cassette(name, options = {}) | |
USED_CASSETTES << VCR::Cassette.new(name, options).file | |
super | |
end | |
end | |
VCR.extend(CassetteReporter) | |
RSpec.configure do |config| | |
config.after(:suite) { | |
files = (Dir['spec/vcr_cassettes/**/*.yml'].map { |d| File.expand_path(d) } - USED_CASSETTES.to_a) | |
unless files.empty? | |
files.each { |v| File.delete(v) } | |
puts files.inspect | |
end | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment