As a part of my rails
application I created a helper under ApplicationHelper
that checks for devise
generated errors and adds them to the flash[:error]
hash.
def devise_flash
if controller.devise_controller? && resource && resource.errors.any?
# modify flash
end
end
This helper gets called in the view layer (e.g. application.html.erb
).
However, I can't really unit test this method because it relies on the controller instance to be a devise controller. I could test it by checking a view using assert_select that uses the helper to show the flash messages, but that feels weird.
Is this a symptom of bad design? Something else? Should I be looking for ways to stub out controller to unit test this function?