Ruby
Article

All I Want for Christmas: Rails 4 Test Prescriptions

By James Hibbard

We asked SitePoint authors what developer toys they would want for Christmas, then managed to source them — without relying on Santa.

When I started with Rails, I was introduced to something called “Test-Driven Development”. The theory is simple: write tests for your code, so that you can make changes to it with confidence.

Why I wanted this book

Initially, that sounded like a no-brainer, but when I tried putting it into practice I was assailed with questions and doubts: What do I test? Which tools should I use? Am I even doing it right?

Fast forward several years and the situation hasn’t become much better. Sure, I write tests for my code, but as my apps get more complex, the questions and doubts remain. That’s why “Rails 4 Test Prescriptions” by Noel Rappin was high on my Christmas wish list.

The experience so far

The book doesn’t disappoint. It starts off slowly by covering the basics of testing each part of a Rails app, as well as using mocks, stubs and helpful gems such as webrat. It then gathers pace, moving on to more advanced topics such as testing the security of an app, testing external services (which always caused me headaches) and testing JavaScript.

In summary, although rather dry in places, this book contains something for every Rails developer. Whether it’s getting up to speed with unfamiliar tools, focusing on what to test, or choosing the right tools for the job, this is a veritable must-have for your coding toolbox.

What would you build with more knowledge of Test Driven Development? Answer in the comments, we’ll pick the best answer and send you a copy of the book!

Comments
swalberg

I would work on improving some software that I've already started that makes heavy use of JavaScript and third party services. While I've gone back and forth on the TDD bandwagon I've always believed that testing code helps improve reliability and leads to a better design.

I've used some of the tools in the book in the past but older versions. So I know I'm missing out on some of the new Rspec3 goodness, and some of the things it always did like custom matchers that I never was able to get working.

billblum

It certainly sounds like a useful reference for bringing TDD into Rails; I've only recently started with Rails, and I think this book would help me now that I've been thrown into the deep end helping a local nonprofit bring their old CGI/Perl site up to modern standards.

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in Ruby, once a week, for free.