Having trouble using VCR with RSpec - VCR::Errors::UnhandledHTTPRequestError

1,058 views
Skip to first unread message

Vell

unread,
Feb 17, 2016, 7:57:04 PM2/17/16
to VCR Rubygem

Hello all,

 

I am having trouble using the VCR with RSpec. I have used it before with success but I am struggling now to get past this error.


I am attempting to record 2 calls to remote services (twitter, tinyurl). VCR seems to handle things fine when the code makes a call to twitter but throws an error the moment the code tries to make a call to tinyurl. Even after deleting all the cassettes, this error still pops up.


I noticed that the 3rd bullet point said that the current mode is :once so I am not able to add any new request but I did delete my cassettes and the error still pops up.


Any help would be greatly appreciated.


Here is what I have in my spec/rails_helper.rb


VCR.configure do |c|
  c
.cassette_library_dir = 'spec/cassettes'
  c
.hook_into :webmock
  c
.configure_rspec_metadata!
  c
.ignore_localhost = true
end


Here is the error I am getting:


 

 VCR::Errors::UnhandledHTTPRequestError:

       
================================================================================
 
       
An HTTP request has been made that VCR does not know how to handle:

         POST http
://tinyurl.com/api-create.php?url=http://www.mysite.direct/blogs/ut-accusantium-fuga-excepturi-recusandae

       VCR
is currently using the following cassette:
         
- /Users/vmcilwain/rails/vell/spec/cassettes/BlogsController/POST_create/a_successful_creation_posting_to_twitter/sets_flash_success_.yml
           
- :record => :once

           
- :match_requests_on => [:method, :uri]

       
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 2 HTTP interactions that have 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/3-0-1/docs/configuration/debug-logging

       [2] https://www.relishapp.com/vcr/vcr/v/3-0-1/docs/record-modes/new-episodes

       [3] https://www.relishapp.com/vcr/vcr/v/3-0-1/docs/configuration/ignore-request

       [4] https://www.relishapp.com/vcr/vcr/v/3-0-1/docs/record-modes/once

       [5] https://www.relishapp.com/vcr/vcr/v/3-0-1/docs/request-matching

       ================================================================================


Reply all
Reply to author
Forward
0 new messages