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.
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, ...