Testing http requests with VCR

Ruby Gem: VCR

VCR on Github

When working on Discuss-it the team found that testing our API http requests slowed down our testing in a big way and sometimes returned inconsistent results.  Since we didn’t want to test the reliability of our external dependencies VCR was the perfect tool to step in between our http request and our test.

What it does is create a ‘cassette’ file in your spec folder which records the first response to your http request and then on ‘replay’ when you rerun your tests it uses the cassette data instead.  If your tests are http request heavy you’ll be able to test how the requests are handled much more consistently with VCR.

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s