Created
November 16, 2017 12:43
-
-
Save marshall-lee/96e5beaf0748f3cfef1818719be9c3f8 to your computer and use it in GitHub Desktop.
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
# decompress gzip-ed VCR fixtures | |
require 'zlib' | |
require 'psych' | |
Dir.glob('spec/fixtures/vcr_cassettes/**/*.yml').each do |filename| | |
data = Psych.load_file(filename) | |
changed = false | |
data['http_interactions'].each do |interaction| | |
response = interaction['response'] | |
headers = response['headers'] | |
next unless headers['Content-Encoding'] == ['gzip'] | |
body = response['body'] | |
gz = Zlib::GzipReader.new(StringIO.new(body['string'])) | |
string = gz.read | |
gz.close | |
body['encoding'] = 'UTF-8' | |
body['string'] = string | |
headers.delete 'Content-Encoding' | |
changed = true | |
end | |
if changed | |
puts "writing #{filename}." | |
File.write(filename, Psych.dump(data)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment