VCR and RSpec
Learn about different VCR options and how to use them with RSpec.
VCR and RSpec
We can use RSpec metadata to specify that any RSpec it
or describe
block uses a VCR cassette. The configuration goes into another RSpec support file:
Press + to interact
VCR.configure do |c|c.cassette_library_dir = "spec/cassettes"c.hook_into :webmockc.configure_rspec_metadata!c.ignore_localhost = trueend
VCR options
Here, four options are specified:
First option
First, the directory where VCR is going to place its cassette files (which can be anything we want, but something like spec/cassettes
is customary).
Second option
The second option involves the HTTP stub library. VCR handles the creation and use of the cassette files, but it subcontracts the actual stubbing of HTTP calls to another ...