Archive | Ruby RSS feed for this section

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


Amazing Rails Console / IRB Trick

18 Oct

When you’re playing around in IRB or Rails Console, you might come up with an output that you wanted to save as a variable, but didn’t (you’re playing around after all!). Now you have to retype your long statement all over again and this time save it to a variable.

Continue reading

RubyMine Review: 5 Features That’ll Get You Hooked

17 Oct

Ever since I first learned Rails, I’ve used TextMate and then Sublime Text as my text editors of choice. They worked fine until I started using RubyMine, a Ruby on Rails IDE, a few weeks ago.  There is no going back. Here are just some of the features I can no longer live without:

Continue reading

When Making A Mess Is Ok

14 Oct

Starting a project is super fun, especially with Rails. Your code is clean, you’re adding tests, and you’re refactoring. But there is no running away from the reality. As you add more features and debug and change things, your code will become a big spaghetti mess in a matter of only a few days. So how do you deal with this?

Check out this great talk by Sandi Metz: Go Ahead, Make a Mess

Continue reading

When To Optimize For Pleasure

1 Oct

This weekend, I finally got to watch DHH (the guy who started Rails) talk about Rails and Backbone.js in a recent meetup at Manilla that I missed. The talk was almost two hours, but I highly recommend watching all of it. Here it is in case you missed it:

Here are a few takeaways that I absolutely loved:

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