ruby-on-rails-3capybaraminitestvcr

How can i match a dynamically changing url in VCR


In my Ruby on Rails application there are 2 Localhost servers running. I am writing test cases for the 1st server and so I have to mock the 2nd server. For this I am using VCR to record the responses I get from the 2nd server and play the recorded cassette while running the tests on the 1st server.

I am stuck at the part where the 1st server makes a request to 2nd server(the session_id in the URL changes each time) and I want the response to be same every time it makes a request.


Solution

  • Using VCR you can match requests on any parameters you wish (method, host, path, etc...) using the match_requests_on cassette option or a fully custom matcher - https://relishapp.com/vcr/vcr/v/3-0-3/docs/request-matching