Skip to Content
Ruby on Rails® for Microsoft Developers
book

Ruby on Rails® for Microsoft Developers

by Antonio Cangiano
April 2009
Intermediate to advanced content levelIntermediate to advanced
479 pages
12h 55m
English
Wrox
Content preview from Ruby on Rails® for Microsoft Developers

7.8. Testing Models

Testing is an integral part of developing in Rails. The subject matter is quite large and this book isn't even going to begin to do it enough justice. Nevertheless, it would do you a great disservice to close a chapter on ActiveRecord without at least scratching the bare surface of unit testing.

It is called unit testing, because individual units of code (for example, models) are tested to verify that they work correctly.

The Rails community embraces Test-Driven Development (TDD) and many developers even go as far as to write tests first, so that they act as a well-defined spec, and only then write code to pass those tests (a practice commonly known as Test-First Development).

Lately many developers have been embracing BDD (Behavior-Driven Development), often by employing the excellent RSpec. I recommend that, with the help of Google, you check out this alternative testing framework.

Many people dislike testing because they tend to prefer to spend their time writing "real code." But the reality is that, aside from being a staple of the XP methodology, testing improves the quality of your application. Testing cannot guarantee a complete lack of bugs in your Web application, but with good testing coverage you can ensure that many basic cases/functionalities are properly handled.

More importantly, it gives you confidence when it comes time to make changes and develop the application further, without having to worry that a change may break a related piece of ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Michael Hartl

Publisher Resources

ISBN: 9780470374955Purchase book