Firing A Controller's Action From The Console
Join the DZone community and get the full member experience.Join For Free
It seems like a simple task, but here's how you can simulate the calling of a controller's action:
ruby script/console irb> require 'action_controller/test_process' irb> require 'application' irb> require 'site_controller' irb> request = ActionController::TestRequest.new irb> response = ActionController::TestResponse.new irb> request.env['REQUEST_METHOD'] = 'GET' irb> request.action = "late_employee" irb> InfoController.process(request,response)Basically, it's like getting inside of a TestUnit method, but you have to do the dirty work yourself.
Opinions expressed by DZone contributors are their own.