Speed Up Your Tests Using VCR Gem in Ruby

01-Mar-2024 643
Since there is a ton of data manipulation involved, I am writing a ton of tests. This is first project in very long time where I am following test-driven development (and I have to say, I'm really enjoying it!). Having a solid backup of tests really gives you the confidence to do a lot of sharp refactorings without constantly worrying if they broke something in some unrelated part of the codebase.However, writing tests with each invocation making an API call can be really slow. To fix this, I started using the stub method in Minitest to fake the API calls. However, that meant creating lots and lots of dummy data manually that's in the same format as returned from the external API.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle