High Five: five tips on testing with Rails

Testing is a very important aspect of Rails programming. The framework makes testing really easy, eliminating some excuses you could have for not testing your applications. Here’s my five tips for testing with Rails:

And that’s it. Five quick and simple tips that I hope will help you. Feel free to share your own tips in the comments. This article is my entry to the Railscasts’ 100th episode contest. Take some time to visit the site, it’s really good.

Contributing: reserved_attributes Rails plugin

Here’s my first contribution to the Rails community: the reserved_attributes plugin.

The plugin is very simple, just adding a rake task to your project. The task scans all your models checking its attributes (columns) and warning you if any of them have a name that are a Ruby/Rails reserved word.

Some time ago I spent about 8 hours of work because my unit tests was breaking with a very strange error (and a gigantic trace). It turns out that I was using an attribute called “notify” and there’s already an internal method with that name, so I was overriding it and breaking everything. I’ve seen many people with the same problem, so here’s a little help. Take a look at the repository main page to see the README file with instructions.

The plugin is hosted at github and you’re free to fork and improve it.