O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

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

Recommendations for Faster Tests

The topic of Rails code structure and the attendant ability to write tests always winds up in a mixture of things everyone should try once, things I do regularly, things I wish I could do regularly, things I don’t do but generally regret not doing, and so on.

In that spirit, a few recommendations:

  • My current practice is to move complex transaction logic out of controllers into action objects, complex creation logic out of models and into factory objects, and view logic into presenters—all of those are plain, non-Rails Ruby objects. David Heinemeier Hansson thinks all of these lead to overly complicated code. That has not been my experience. You should try for yourself.

  • I like to use SimpleDelegator to create ...

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