I'm always writing tests to check my controller restricts people from certain actions depending on their status i.e. logged in, admin? etc Regardless of whether its a get to :index or a puts to :create the code is always the same. I'm trying to refactor this so that i have one method such as
should_redirect_unauthenticated_to_login_action(request, action)
and call it like so
should_redirect_unauthenticated_to_login_action(:get, :index) => get :index
But not sure how to dynamically call the various response methods rails provides for functional tests which seem to live in the module ActionController
I mucked around with
module = Kernel.const_get("ActionController")
module::TestProcess.get
NoMethodError: undefined method `get' for ActionController::TestProcess:Module
can anyone help (im very new to dynamic calling in ruby)