O'Reilly logo

Ajax on Rails by Scott Raymond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Testing and Debugging

If you are skimming this book, you might be tempted to skip over this chapter. After all, why read about testing until you have an application to test? And why worry about debugging techniques until something goes wrong? The answer is simple: testing and debugging are activities that should be happening at every stage of development—possibly even before development. Why? Several reasons. It’s not surprising that thoroughly tested code will be more reliable, but what might be surprising is that writing tests can actually speed up development. It’s counterintuitive, but true because testing acts like a climbing harness: with a reduced penalty for making mistakes, you are freer to make bold, quick moves.

Automated testing is done in every language and platform. But not every technology community places equal weight on the importance of testing—a prime example being JavaScript, which is very often written with no tests at all. Fortunately, the Ruby and Rails communities both have a strong culture of testing. A large percentage of Ruby projects include a test suite, and Rails itself has a very thorough one. Rails also encourages developers to test their own applications. Ever notice how script/generate adds little test stubs for every model and controller you generate? That’s Rails’ way of reminding you to test your code early and often.

Ajax adds a new twist to testing and debugging, and it can often be a major source of frustration. In this chapter, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required