I can't record anything with vcr, I have such setup:
spec_helper.rb
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
c.hook_into :webmock
c.configure_rspec_metadata!
c.default_cassette_options = { :record => :new_episodes }
end
And test:
describe SomeClass do
describe '#foo', vcr: true do
it 'should do http request', do
expect(subject.do_request).to be_true
end
end
end
Running that spec results in:
.HTTPI executes HTTP GET using the net_http adapter
SOAP request: (...)
Exactly like without vcr. Unfortunately there's nothing in documentation. I found similar issue reported here, but requiring httpi
doesn't give any effect. What should be done to get this working?
For me to get VCR to record SOAP requests that correctly match took me specifying more matchers for it to use. Since with SOAP the url endpoint is usually the same but the body content/headers is different per request. Notice, :method, :uri, :headers. You can also have it match on body but this was enough for my use case since our headers are pretty detailed per request. I'm using this:
Then I tag the spec with an empty hash in case I want to override the global VCR config, like:
And lastly the more requests you can have VCR/Webmock ignore the easier to debug. So if you have lots of JS calls or similiar add those requests to the 'ignore_hosts' option. My last line in the global config shows how to have VCR log what it's doing, also helpful.