I have a controller, and in my tests I want to do this:
%i(index show new create edit update destroy publish suspend).each do |action|
# code
end
But it's verbose, and I need to do it in a number of tests. I know I can do the following:
ProjectsController.instance_methods.take(8).each do |action|
# code
end
But it's brittle, especially if we remove the :suspend action. Is there a rails way of getting all the methods defined in a controller file, and no more.