department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
283 stars 205 forks source link

Documentation Support: Update "VCR Debugging" Page #77027

Closed AdamKing0126 closed 2 months ago

AdamKing0126 commented 8 months ago

Issue Description

SME:


Tasks

Acceptance Criteria

CONTENT TEAM - DISREGARD DETAILS BELOW THIS LINE


Request type

Number of docs

one, https://depo-platform-documentation.scrollhelp.site/developer-docs/vcr-debugging

Subject matter expert

@adamking0126

Approvals

No response

Embedded media

Audience

Anything else?

The VCR Debugging page should offer more information about testing with VCR. There's no platform documentation explicitly about this. What I'd like to change, is to modify the introductory paragraph, and break it into two, while also adding a bit more basic info. Currently:

VCR debugging
[VCR](https://github.com/vcr/vcr) can be a great way to record HTTP interactions in a controlled environment and
replay those interactions during tests. We don’t want to make actual HTTP requests during a test scenario, so VCR
helps us get around that. Sometimes VCR seems to work out of the box, but sometimes it takes trial and error to get a
test to recognize cassettes. Below are some errors and possible resolutions.

Proposed Change:

VCR in Unit Testing
[VCR](https://github.com/vcr/vcr) can be a great way to record HTTP interactions in a controlled environment and
replay those interactions during tests. We don’t want to make actual HTTP requests during a test scenario, so VCR
helps us get around that.

To record a VCR cassette, you must make a successful network request.  First, obtain the proper credentials to make
the request.  For example, to obtain credentials for the lighthouse sandbox api, fill out [this form
(https://developer.va.gov/support/contact-us).  

Modify `settings/test.yml` to include the necessary credentials.  To avoid the potential of committing sensitive
information into version control, use an environment variable, eg `<%= ENV['CLIENT_ID'] %>`.  Wrap your test's
network request in a call to use_cassette, e.g., `VCR.use_cassette("path/to/cassette/to/record/200_response.yml`.  

When you run your unit test, the network call will execute and the response will be recorded.  The next time you run the
test, it will run the recorded response instead of making the external call.  Note that if you follow TDD, you'll need to
remember to delete that recorded response after each failure (else the failure will simply be replayed, no matter what
changes you make to your code).

VCR debugging
Sometimes VCR seems to work out of the box, but sometimes it takes trial and error to get a test to recognize
cassettes. Below are some errors and possible resolutions.
... rest of the document
jknipes commented 8 months ago

Hi @AdamKing0126 , thanks for your content suggestions. The Platform Content team will review your request and put it in our backlog to refine for next steps.

jknipes commented 4 months ago

This ticket is being handled by the Platform Content Team, related to ticket 83889

rmtolmach commented 4 months ago

Hi @AdamKing0126! Thank you for your suggestions!! We have come to realize there are many ways to record VCR cassettes around the VA. It almost seems like every team does it a little differently 😳. @ryan-mcneil made some updates to the page recently and he's planning on making more later this summer. He will include your suggestions as part of a bigger overhaul.

You can see some of the documents that some teams have created on how they record VCRs in this section of our VCR doc.

jknipes commented 4 months ago

Platform Product Team will not be working on this update. Currently, ticket 83889 has been labeled for Platform Reliability Team. We have paused this update. See conversation in Slack for more details.

jknipes commented 4 months ago

Moving to Backlog pending availability from Reliability Team SME cc: @ryan-mcneil

jknipes commented 3 months ago

ZenHub automatically added this ticket to the 2 most recent sprints, but the work is still on hold pending availability of the SME

ryan-mcneil commented 2 months ago

@AdamKing0126 Apologies, we forgot to update this ticket as well. Updates to VCR docs were pushed last week. I included some of your recommendations, including sections elaborating on some of the other techniques used by other teams. Sorry it took awhile for us to get around to it!