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

Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.