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
281 stars 197 forks source link

Update Page: VCR-Debugging (Footer Ticket 77027) #83889

Open jknipes opened 3 months ago

jknipes commented 3 months ago

Issue Description

This page on VCR Debugging requires an update per Footer Ticket 77027. Suggested changes are detailed below. We need to connect with the Platform Product Team to create approved language to update this page.

SME:


Tasks

Acceptance Criteria

Suggested Changes:

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 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 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 3 months ago

Waiting to see if this needs to be scheduled into a future sprint with Product Team

jknipes commented 1 month ago

This ticket is being handled by Platform Product Team, related to ticket 77027

jknipes commented 3 weeks 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 days ago

Didn't quite finish the docs, but I'll knock them out first thing in the next sprint. In progress doc here

ryan-mcneil commented 1 day ago

@laucon alright, I've submitted a solid overhaul of the page in question. Let me know if (when) something needs to be fixed! Thanks!

jknipes commented 6 hours ago

Hey @ryan-mcneil , @laucon has checked the document, It has no launch blocking issues. It will be deployed on Tuesday 9/3. Thank you for working on this!