Skip to content

Instantly share code, notes, and snippets.

@dipth
Created February 18, 2012 18:46
Show Gist options
  • Save dipth/1860634 to your computer and use it in GitHub Desktop.
Save dipth/1860634 to your computer and use it in GitHub Desktop.
Override VCR's :body matcher to ignore order
VCR.configure do |c|
# Since HTTParty takes a Hash of body data, we can never be sure that it is
# sent in the same order. This can cause VCR to not recognize the request and
# therefore not use a previously recorded response.
# This overrides VCR's built-in :body matcher to ignore the order of the data
c.register_request_matcher :body do |request1, request2|
body1 = request1.body.split('&')
body2 = request2.body.split('&')
(body1 - body2).empty?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment