Tag Archives: Testing

How To Use The VCR Gem With Rails And Rspec

21 Oct

So yesterday I spent way too much time trying to make this really cool VCR gem work with my rspec tests. The problem was that most of the tutorials out there were pretty outdated, and things have changed a bit.

The VCR gem is really useful if you have methods that need to make an api request. You don’t want to make api requests during tests, especially if the api has some kind of rate limit (I’m looking at you Twitter!).

So what you could do is create a text file mocking the response you get from the web service you’re making the api to and do the tests that way, or you can use the VCR gem! The VCR gem makes an api request once, and records the response to a cassette, which it then uses in future tests. Clever, no?

Here’s how you set up the VCR gem in your Rails App with Rspec:
Continue reading


My Rails New Workflow With Testing

21 Sep

After playing around with Django a few weekends ago, I decided to stick to Rails for my personal projects. This Quora answer sums up pretty well why I’m choosing Rails.

Another reason I love Rails is because I love test driven development, and Rails has testing at it’s core. I started a new project this morning, and wanted to share my workflow for starting a Rails app with all the Testing gems and configurations set up properly:

Continue reading

Here Are A Few Of My Favorite Gems (For Testing ;)

11 Aug

I absolutely LOVE the idea of Test Driven Development (TDD). Write a test, see it turn RED, write the code to make the test pass GREEN, REFACTOR your code, and keep doing it over and over again!

However, if you’ve tried writing tests, especially for Rails, you know how tedious the process could be to set up. I use Rspec for unit tests, Capybara for integration tests, Guard to keep re-running the tests every time I make changes to any files, and Spork  to have the tests run faster. And here are a few of my favorite gems that make developing and testing even more pleasant:
Continue reading