Created
February 18, 2012 18:46
-
-
Save dipth/1860634 to your computer and use it in GitHub Desktop.
Override VCR's :body matcher to ignore order
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
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