Testing Application Helper that Depends on Controller

by Adam Thompson   Last Updated May 01, 2018 16:05 PM

I am working on practicing TDD/BDD/ATDD and I am working on a rails application.

I created a helper method that depends conditionally on the type of controller being tested.

module ApplicationHelper
  def devise_add_flash
    if controller.devise_controller?
      flash.now[:error] = flash[:error] + resource.errors.full_messages

Is unit testing this a bad idea? Should I be testing the "end behaviour" of this method (e.g. checking the flashes appear at the controller/view level) since that is really the "API" I care about maintaining, not the implementation of flash, etc.?

Am I approaching this the correct way?

Related Questions

What does stubbing mean in programming?

Updated March 03, 2017 13:05 PM

Test Internals with TDD?

Updated March 08, 2018 04:05 AM

Testing front-end app that hits a REST service

Updated April 08, 2015 19:02 PM

Are (database) integration tests bad?

Updated April 27, 2016 08:02 AM