Speed up network bound specs with vcr

Fast tests feedback is crucial for productivity (don’t wait for your tests on TDD), commit time (continuous integration), deploy time (continuous deployment)

VCR is a great tool for speeding up network bound tests. It uses an underlying layer to imitate web requests by dumping the first request into yml file and using the dumped response to stub future requests with the same headers.

Setup is super easy:

1) Gemfile

2) spec_helper

3) go over all failing tests and add :vcr to the group:

Each example group will be represented by a yml file in the spec/cassettes directory. The file will include all the requests and responses for the example group

4) update .gitignore to ignore cassettes

Run your specs and enjoy the velocity (on the second run ;-))

  1. Leave a comment

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 )

Google+ photo

You are commenting using your Google+ 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

%d bloggers like this: