【问题标题】:Show ruby VCR stats after running tests?运行测试后显示 ruby​​ VCR 统计信息?
【发布时间】:2015-10-08 00:10:27
【问题描述】:

有没有办法知道在您运行测试时发生了多少请求并且可以被 VCR 缓存。

有没有办法知道有多少是从 VCR 缓存中读取的?

谢谢

【问题讨论】:

    标签: ruby vcr


    【解决方案1】:

    看看After Http Request Hook

    VCR.configure do |c|
      c.cassette_library_dir = 'cassettes'
      c.ignore_localhost = true
      c.after_http_request(:ignored?, lambda { |req| req.uri =~ /foo/ }) do |request, response|
        puts "Response for #{request.method} #{request.uri}: #{response.body}"
      end
    end
    

    或者你可以启用debug logging:

    VCR.configure do |c|
      c.hook_into :webmock
      c.cassette_library_dir = 'cassettes'
      c.debug_logger = File.open(ARGV.first, 'w')
    end
    

    【讨论】:

      猜你喜欢
      • 2017-12-23
      • 2017-09-27
      • 2011-09-16
      • 1970-01-01
      • 2018-07-01
      • 2023-03-25
      • 2011-05-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多