Debug Logging
Use the debug_logger option to set an IO-like object that VCR will log debug output to. This is a useful way to troubleshoot what VCR is doing.
The debug logger must respond to #puts.
Use the debug logger for troubleshooting
Given a file named "debug_logger.rb" with:
if ARGV.include?('--with-server')
$server = start_sinatra_app do
get('/') { "Hello World" }
end
end
require 'vcr'
VCR.configure do |c|
c.hook_into :webmock
c.cassette_library_dir = 'cassettes'
c.debug_logger = File.open(ARGV.first, 'w')
c.default_cassette_options = {
:match_requests_on => [:method, :host, :path]
}
end
VCR.use_cassette('example') do
port = $server ? $server.port : 7777
Net::HTTP.get_response(URI("http://localhost:#{port}/"))
endWhen I run ruby debug_logger.rb record.log --with-server
Given that port numbers in "record.log" are normalized to "7777"
Then the file "record.log" should contain exactly:
When I run ruby debug_logger.rb playback.log
Given that port numbers in "playback.log" are normalized to "7777"
Then the file "playback.log" should contain exactly:
Last updated
Was this helpful?