I'm trying to duplicate an API call in which I upload a file, I am using and Because I do not want to kill the server with every trial, I am trying to VCR for the first time.
I have the following test in my SPECK / Controller folder:
let (: file) {rack :: test :: UploadedFile.new ("video_path", ' Video / mp4 ')} Description "GET #INDEX" provides "all videos as @videos" VCR.use_cassette "wistia / upload" video = video. Create! ADI ([video]) End End End
Termination
The API call has started inside the model callback which looks like this:
class video & lt; ActiveRecord :: Base after_save: move_video def move_video uri = URI ('https://upload.wistia.com/') http = Net :: HTTP.new (uri.host, uri.port) http.use_ssl = true # build request. Request = net :: HTTP :: Post :: Multipart.new uri.request_uri, {'api_password' = & gt; '', 'Project_id' = & gt; '' 'File' = & gt; My_video_file} # Do it! Feedback = http.request (requested) Return response and end
I have debug this method in the call, and it is being said properly, but when I run my test, I The following error:
1) video controller GET # Indix @ Video Failure / Error: Assigns all video in the form of video = video. Create! Valid_attributes VCR :: Errors :: UnhandledHTTPRequestError: ================================================= ============================================== An HTTP request made To know how to handle VCRs: Post https://upload.wistia.com/ VCR is currently using the following cassette: - / Users / urielhernandez / Documents / pf / spec / vcr / wistia / Upload.yml -: record = & gt; : Once -: match_requests_on = & gt; [: Method: Yuri] Under the current configuration, appropriate HTTP interaction can not be found to run the VCR again, and new requests can be stopped from recording. There are a few ways to deal with this: * If you are surprised that the VCR is pushing this error and how VCR has tried to handle the request, then you will have more information [1] to debug logon configuration options You can use. * You can use this: New episode record mode to allow VCR to record this new request for existing cassette [2]. * If you want VCR to ignore this request (and like others), then you can set a `ignore_request` callback [3]. * The current record mode (: Once) does not allow the recording of new requests in the already recorded cassette. You can remove the cassette file and allow the recording of the cassette with this request to run your tests again [4] * The cassette has an HTTP interaction that matches this request, but it Only played back. If you want to allow multiple HTTP interactions to be played back many times, set the `: allow_playback_repeats` cassette option [5]. [1] 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 mode / new-episode [3] https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/ignore-request [4] Http://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-match / playback- repeat ===================================== ===========================================
The cassette was made but I was getting the error mentioned. How did I remove the cassette to see it, after which it did not come back again, and the VCR is not handling the request.
Creating on cassette code> / Users / urielhernandez / Documents / pf / spec / vcr /wistia/upload.yml is described in the error message.
Try VCR.use_cassette ("wistia / upload" ,: record =>: new_episodes)
; That it will record in the same cassette as a new request. See more about VCR record mode at
No comments:
Post a Comment