VCR is a tool that I've been using quite often now to mock test requests. But was a bit tricky to find out how it works, so I want to share the knowledge I've been gathering in the past months to explain a bit about VCR.
version of an external or internal service that can stand in for the real one, helping your tests run more quickly and more reliably. When your implementation interacts with an object’s properties, rather than its function or behavior, a mock can be used.”
that requires an external request, you use .use_cassette method to state that you want VCR to deal with that with a “cassette ﬁle” • If there is no ﬁxture yet, VCR is conﬁgured by default to create one (this time making a real request) so it can be used for future references. HOW TO USE VCR?
available to ﬁlter sensitive data, preventing it from being written to the cassette ﬁle. • If you wish to continue making real requests while testing, VCR also provide other 4 record modes (besides once): new_episodes, none, all and record_on_error