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, here are a few recommendations:

  • My current practice is to move complex transaction logic out of controllers into workflow objects, complex creation logic out of models and into factory or workflow objects, and (somewhat less often) view logic into presenters—all of those are plain, non-Rails Ruby objects. David Heinemeier Hansson might say all of these lead to overly complicated code. That hasn’t been my experience. You should try for yourself. ...

Get Rails 5 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.