Usually, when I want something like this, I just check the expected behavior, not taking into account that this specific behavior can be implemented in the filter, and not in the method itself. So, for the following simple scenario:
class Controller < ApplicationController before_filter :load_resource, :only => [:show, :edit] def show end def edit end def index end ######### protected ######### def load_resource @resource = Model.find(params[:id]) end end
I would try to verify that #show and #edit are set to @resource. This is very convenient for simple scenarios. If the filter is applied to many actions / controllers, you can extract the test code and reuse it among the tests.
source share