Unable to stub helper method with rspec
问题 I am trying to stub a method on a helper that is defined in my controller. For example: class ApplicationController < ActionController::Base def current_user @current_user ||= authenticated_user_method end helper_method :current_user end module SomeHelper def do_something current_user.call_a_method end end In my Rspec: describe SomeHelper it "why cant i stub a helper method?!" do helper.stub!(:current_user).and_return(@user) helper.respond_to?(:current_user).should be_true # Fails helper.do