我可以记录未处理的VCR请求正文吗?

art*_*pov 2 ruby rspec ruby-on-rails vcr

我正在使用VCR gem来模拟HTTP查询.我录了录音带,但后来我不得不改变一些东西,现在我收到一个错误:

An HTTP request has been made that VCR does not know how to handle:
  POST http://api.endpoint.here/path.json
Run Code Online (Sandbox Code Playgroud)

现在,因为它是一个POST请求,VCR配置为匹配正文和路径上的那些.我可以记录或转储未处理请求的正文,以便我可以相应地调整磁带吗?谢谢.

Eug*_*Zol 7

不会回调实现你所需要的吗?

VCR.configure do |c|
  c.after_http_request do |request, response|
    if request.method == :post
      puts "POST Request:#{request.uri}"
      puts "#{request.to_hash}" # or request.body
    end
  end
  c.allow_http_connections_when_no_cassette = true
end
Run Code Online (Sandbox Code Playgroud)