Testing Views and View Markup

We’ve tested a helper for project status, but when we go to the browser the new status DOM elements don’t show up. This is because we haven’t placed our new helper in the view template itself. Naturally, we would like our dazzling two-line helper to be incorporated into the view.

From a TDD perspective, we have a few options:

  • Write no further tests, and just insert the helper into the view template. Technically we’re not adding logic, so we can kind of squeak by with this one. I don’t mean to be glib here—having no extra test may be the right choice when the test is a) expensive, b) trivial in the larger scheme of things, and c) easy to visually inspect.

  • Write an integration test using Capybara, as we ...

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.