我正在使用 VCR gem 来模拟 HTTP 查询。我已经录制了磁带,但后来我不得不改变一些东西,现在我遇到了一个错误:
An HTTP request has been made that VCR does not know how to handle:
POST http://api.endpoint.here/path.json
现在,因为它是一个 POST 请求,VCR 被配置为匹配正文和路径上的请求。我可以记录或转储未处理请求的主体,以便我可以相应地调整磁带吗?谢谢。
最佳答案
回调不会实现你所需要的吗?
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
关于ruby-on-rails - 我可以记录未处理的 VCR 请求正文吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30934276/