Testing Helper Methods

Helper modules are the storage attic of Rails applications. They are designed to contain reusable bits of view logic. This might include view-specific representations of data, or conditional logic that governs how content is displayed. Helper modules tend to get filled with all kinds of clutter that doesn’t seem to belong anywhere else. Because they are a little tricky to set up for testing, helper methods often aren’t tested even when they contain significant amounts of logic.

RSpec helper tests go in spec/helpers. There’s not a whole lot of special magic here—just a helper object that you use to call your helper methods.

Let’s say we want to change our project view so behind-schedule projects show up differently. ...

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.