Chapter 6. When Things Go Wrong

Unfortunately, neither this book nor a lifetime of practice can cause you to attain Ruby programming perfection. However, a good substitute for never making a mistake is knowing how to fix your problems as they arise. The purpose of this chapter is to provide you with the necessary tools and techniques to prepare you for Ruby search-and-rescue missions.

We will start by walking through a simple but real bug-hunting session to get a basic outline of how to investigate issues in your Ruby projects. We’ll then dive into some more specific tools and techniques for helping refine this process. What may surprise you is that we’ll do all of this without ever talking about using a debugger. This is mainly because most Rubyists can and do get away without the use of a formal debugging tool, via various lightweight techniques that we’ll discuss here.

One skill set you will need in order to make the most out of what we’ll discuss here is a decent understanding of how Ruby’s built-in unit testing framework works. That means if you haven’t yet read Chapter 1, Driving Code Through Tests, you may want to go ahead and do that now.

What you will notice about this chapter is that it is much more about the process of problem solving in the context of Ruby than it is about solving any particular problem. If you keep this goal in mind while reading through the examples, you’ll make the most out of what we’ll discuss here.

Now that you know what to expect, let’s start fixing ...

Get Ruby Best Practices now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.