Created
July 10, 2013 11:31
-
-
Save danlucraft/5965531 to your computer and use it in GitHub Desktop.
How to make VCR not fail to match the request body because the JSON hashes have been serialised in a different order
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
VCR.configure do |v| | |
v.register_request_matcher :json_aware_body do |r1, r2| | |
r1.body == r2.body || ( | |
r1.headers["Content-Type"].inspect =~ /json/ and JSON.parse(r1.body) == JSON.parse(r2.body)) | |
end | |
end | |
VCR.use_cassette('example', :match_requests_on => [:json_aware_body]) do | |
#... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment