7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/vcr/task_runner.rb', line 7
def migrate_cassettes(dir)
with_recorded_response_defined do
FileUtils.cp_r(dir, "#{dir}-backup")
Dir.glob(dir + '/**/*.yml').each do |cassette_file|
recorded_responses = YAML.load(File.read(cassette_file))
next unless recorded_responses.is_a?(Enumerable) && recorded_responses.all? { |rr| rr.is_a?(VCR::RecordedResponse) }
interactions = recorded_responses.map do |recorded_response|
http_interaction(recorded_response)
end
File.open(cassette_file, 'w') { |f| f.write(interactions.to_yaml) }
end
end
end
|