We had to have make external API calls and we used vcr to record and replay in our integration tests. All was going on well.
Despite this coverage, we saw our code breaking in production due to small chages in request xml body. We wanted our integration spec to cover these too. By default, vcr matches request method and url. We wanted it to match the post body too. Simple match by body does not solve as it does plain string match. It would give false negatives.
So, we decided to match our xml request body. This is what we did.
We added a new matcher called
XmlPostBodyMatcher and it uses
equivalent-xml gem to match if the post body is an xml.
This has helped us to have strict-yet-sensible integration spec and increased our confidence on the test suite.
Hope this is useful for you too.