Today I had to add a parameter to a request we were sending to an external API.
My unit test passed ✅ The acceptance specs did not - I had 20 failures. ❌
The failures were super cryptic, something about not being able to merge Nil:NilClass into a hash or something weirdly unrelated. One of my colleagues suspected it was to do with the VCR gem we used to simulate HTTP requests/responses from APIs.
Turns out VCR uses query strings as the key for the cassette (I did not know this). Because I'd added a param to the query string, the existing string (in the cassettes) was broken. Turns out passing different values or params will make new request rather than using the recorded responses and so the request was trying to be sent out rather than using the cassette. So we needed to re-record the cassettes.
I tried to get them to record again a few different ways to no avail. Ended up simply editing the URI string and adding the new param (remember these are included in alphabetical order!). And, low and behold, green tests.