Created
May 6, 2015 04:06
-
-
Save sumeet/c3f53cc5798587a3a38d to your computer and use it in GitHub Desktop.
This file contains 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 "json" | |
require "yaml" | |
cassette_files = `git ls-files features/cassettes spec/vcr_cassettes | grep yml$`.split | |
p cassette_files | |
cassette_files.each do |filename| | |
yaml = YAML.load_file filename | |
yaml.fetch("http_interactions").each do |interaction| | |
request = interaction.fetch("request") | |
if request.fetch("method") == "post" && request.fetch("uri").match(/hermes.*messages$/) | |
payload = JSON.parse request.fetch("body").fetch("string") | |
unless payload["type"] | |
request["body"]["string"].insert(-2, ',"type":"text"') | |
File.open filename, 'w' do |file| | |
file.write yaml.to_yaml | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment