I’m a little unsure as to how to write a test for a helper method which has output that is based on the given controller and action that are requested.
Given the following helper method in my application helper…
module ApplicationHelper
def body_id
[ controller.controller_name, controller.action_name ].join("_")
end
end
… how would you write an application_helper_spec that tests this method?
Assign or mock the controller object. That will give you something to test against. (RSpec includes a very good mocking/stubbing library.)