2

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 は本文とパスに一致するように構成されます。それに応じてカセットを微調整できるように、未処理のリクエストの本文をログに記録またはダンプできますか? ありがとうございました。

4

1 に答える 1

8

コールバックはあなたが必要とするものを達成しませんか?

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
于 2015-08-18T12:58:04.783 に答える