Skip to content

Instantly share code, notes, and snippets.

@zdennis
Created July 7, 2009 13:23
Show Gist options
  • Save zdennis/142075 to your computer and use it in GitHub Desktop.
Save zdennis/142075 to your computer and use it in GitHub Desktop.
def stub_filters_of_type(type, options)
controller.class.send("#{type}_filters").each do |filter_name|
next if options[:except].respond_to?(:include?) && options[:except].include?(filter_name)
next if options[:except] == filter_name
next if filter_name.is_a?(Proc)
controller.stub!(filter_name).and_return(true)
end
end
def stub_before_filters!(options = {})
stub_filters_of_type(:before, options)
end
def stub_after_filters!(options = {})
stub_filters_of_type(:after, options)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment