Hackday: Effective Testing for Rails

This past Saturday we hosted the second Hackday at the Viget Labs office (photos). For this event, Matt and I focused on the tools and techniques for testing that we often use when developing Rails applications. Since the Hackday format is one of collaborative teaching and discussion, we decided to build a micro-app from scratch during a pair-programming session.


The topic for the day was a logical progression from our previous event on controller refactoring as testing is a critical component of any reliable refactoring activity. We spent some time covering the standard testing facilities in Rails and went on to discuss mocking, stubbing, object factories, and other testing libraries for use in Ruby and Rails projects.

The three-hour timeframe was sufficient to scratch the surface of these topics, but didn't allow us to get too deep in any one area. In order to bridge the gap between what we covered during the day and the final application, we've made the full application code and tests available on GitHub. We've also provided a list of links to some of the tools we discussed during the day.

Thanks to everyone who came out to the event – we hope to see you all at the next Hack Night.

Patrick Reagan

Patrick is development director in Viget's Boulder, CO, office. He writes clean Ruby code and automates system infrastructure for clients such as Shure and Volunteers of America.

More articles by Patrick