vcr / vcr

Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.

Home Page:https://benoittgt.github.io/vcr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improviments on documentation integrated

AlexcastroDev opened this issue · comments

Is your feature request related to a problem? Please describe.
Hello, I would like to thank you first for your time and support. I've come across many issues regarding the implementation of RSpec, such as this one, for example: #620. I have a similar problem, and even after re-reading the documentation several times, I still don't understand how the integration with RSpec works.

I have a basic implementation of this integration: https://github.com/AlexcastroDev/i18n-admin/pull/1/files

Even when using configure_rspec_metadata and WebMock, my VCRs are not being generated after running the tests.

Describe the solution you'd like
I can help improving the doc, but i want to understand how to solve this problem.

Describe alternatives you've considered
nothing

Additional context

Repository

image

@AlexcastroDev VCR records remote HTTP calls, like the Net::HTTP.get_response in your commented-out example. When your app makes a HTTP call to an external URL, like api.github.com or rnter-staging.herokuapp.com, VCR intercepts them to record and play them back.

You highlighted the line body = JSON.parse(response.body), but this does not seem to be a remote HTTP call, so it makes sense to me that nothing would be recorded. I see what looks to be a request spec, which means you are using RSpec to exercise a route (/api/versions) of your Rails app. Request specs run entirely local within the Ruby process, meaning no remote HTTP calls take place, and thus nothing for VCR to record. The only VCR recording that would take place here is if the controller for the /api/versions route is itself making a remote HTTP call via e.g. Net::HTTP.get_response or similar.

Now it makes more sense to me, I misunderstood. Thank you for the response. I will close the issue.