Looking at Ryan B's CanCan for inspiration require 'rspec' require 'rspec/autorun' require 'active_support' require 'active_record' require 'action_controller' require 'action_view' require 'rails3_plugin_toolbox'
RSpec.configure do |config| config.mock_with :rr end --- require "spec_helper" describe CanCan::ControllerAdditions do before(:each) do @controller_class = Class.new @controller = @controller_class.new stub(@controller).params { {} } stub(@controller).current_user { :current_user } mock(@controller_class).helper_method(:can?, :cannot?) @controller_class.send(:include, CanCan::ControllerAdditions) end So here he uses a stub and mock approach... I would like to use the approach described on Rails Dispatch: http://www.railsdispatch.com/ module MyAddition def hello puts "Hello from MyAddition" end end ActiveSupport.on_load(:action_view) do include MyAddition end ActiveSupport.on_load(:action_controller) do include MyAddition end Could I then spec sth. like this? ActionController.methods.grep(/hello/).should_not be_empty ActionView.methods.grep(/hello/).should_not be_empty or how would I go about it? _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users