
1/5/2023
What this post added
This post introduces the VCR gem as a tool for recording and playing back HTTP interactions in Ruby tests. It contrasts VCR with Webmock, highlighting VCR's approach of recording live API responses versus Webmock's manual stubbing. The post details use cases for VCR, such as handling unpredictable API sequences, complex multi-step interactions, and unreliable APIs. It also provides guidance on configuration, including adding VCR to the Gemfile, using `VCR.use_cassette` blocks, and managing sensitive data with `filter_sensitive_data`. Advanced techniques like splitting collaborators into separate cassettes and inspecting YAML files are also discussed.