Não é possível stub o método auxiliar com rspec

Eu estou tentando stub um método em um auxiliar que é definido no meu controlador. Por exemplo:

<code>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
</code>

Na minha Rspec:

<code>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_something # Fails 'no method current_user'
  end
end
</code>

Emspec/support/authentication.rb

<code>module RspecAuthentication
  def sign_in(user)
    controller.stub!(:current_user).and_return(user)
    controller.stub!(:authenticate!).and_return(true)

    helper.stub(:current_user).and_return(user) if respond_to?(:helper)
  end
end

RSpec.configure do |config|
  config.include RspecAuthentication, :type => :controller
  config.include RspecAuthentication, :type => :view
  config.include RspecAuthentication, :type => :helper
end
</code>

Eu fiz uma pergunta semelhanteAqui, mas resolvido em um trabalho ao redor. Esse comportamento estranho subiu novamente e eu gostaria de entenderporque isso não funciona.

ATUALIZAR: Eu descobri que chamarcontroller.stub!(:current_user).and_return(@user) anteshelper.stub!(...) é o que está causando esse comportamento. Isso é fácil o suficiente para corrigirspec/support/authentication.rb, mas isso é um bug no Rspec? Eu não vejo porque seria de esperar que não seria capaz de stub um método em um auxiliar se já foi stubbed em um controlador.

questionAnswers(5)

yourAnswerToTheQuestion