VCR does not record tapes

I have a very simple module I am testing Ruby with a VCR.

I configured the VCR according to the documentation, but it seems I can’t get the tape for recording in the tape catalog. I even changed the permissions for the cassette catalog to 777 just in case. Truly strange, I completely deleted the cassette catalog, launched the specifications, and then created a new cassette catalog.

I am using Typhoeus 0.4.2 with Hydra . I cannot update Typhoeus at the moment.

Relevant Code:

 require 'rspec' require 'vcr' require_relative File.join("..", "crawl_handler") VCR.configure do |c| c.cassette_library_dir = "spec/vcr_cassettes" c.hook_into :fakeweb c.allow_http_connections_when_no_cassette = false end ... # => other describe statements describe "#handle_http_response" do before(:each) do get_some_response = lambda { # NOTE: typhoeus v. 0.5 is MUCH less setup :) VCR.use_cassette("bme") do request = Typhoeus::Request.new("www.bing.com") hydra = Typhoeus::Hydra.new hydra.queue(request) hydra.run response = request.response end } @message = @subject.handle_http_response("www.bing.com", get_some_response.call) end it "returns a message hash" do @message.should be_kind_of Hash end ... 

I have no idea why the tapes are not being recorded.

+8
ruby vcr
source share
1 answer

The problem is that you are using Typhoeus as your HTTP client, but connecting to FakeWeb , which only supports Net::HTTP . The VCR can connect directly to Typhoeus (since it provides good public APIs for this) if you configure it:

 VCR.configure do |vcr| vcr.hook_into :typhoeus end 

The hook_into docs lists all the parameters and which interceptors work with HTTP clients. If you have any suggestions for improving the documentation so that other people do not have such confusion, let me know.

+9
source share

All Articles