VCR gemのカセットを再作成する
Date:2016-12-02 11:56:43 +0900
Categories: ETC
Categories: ETC
VCR について
VCRはrubyのgemで、APIリクエストなどをカセットとして保存し一度読み込んだら次からはそちらを参照してくれるものです。
都度リクエストを投げなくなるので、テストの速度改善に役立ちます。
今回
faradayのアップデートを行った際にリクエストでエラーが出たことが、VCRを知るきっかけでした。
出たエラー
F Failures: 1) XXXX in instance variable VCR::Errors::UnhandledHTTPRequestError: ================================================================================ An HTTP request has been made that VCR does not know how to handle: POST[https://XXXXXX/XXXXX](https://XXXXXX/XXXXX) VCR is currently using the following cassette: Under the current configuration VCR can not find a suitable HTTP interaction to replay and is prevented from recording new requests. There are a few ways you can deal with this: * If you're surprised VCR is raising this error and want insight about how VCR attempted to handle the request, you can use the debug_logger configuration option to log more details [1]. * You can use the :new_episodes record mode to allow VCR to record this new request to the existing cassette [2]. * If you want VCR to ignore this request (and others like it), you can set an `ignore_request` callback [3]. * The current record mode (:once) does not allow new requests to be recorded to a previously recorded cassette. You can delete the cassette file and re-run your tests to allow the cassette to be recorded with this request [4]. * The cassette contains 1 HTTP interaction that has not been played back. If your request is non-deterministic, you may need to change your :match_requests_on cassette option to be more lenient or use a custom request matcher to allow it to match [5]. [1][https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/debug-logging](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/debug-logging) [2][https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/record-modes/new-episodes](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/record-modes/new-episodes) [3][https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/ignore-request](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/ignore-request) [4][https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/record-modes/once](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/record-modes/once) [5][https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/request-matching](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/request-matching) ※一部記載削除 VCRという物を知らなかったので、調べるところからで時間がかかってしまいましたが。 解決 カセットの作成設定に :once が入っていたので、もともと入っていたカセットファイル(yml)を削除して、再度テスト実行をし直したら新しいカセットが作成されました。以降テストも問題ありませんでした。Tweet