title: rspec helper user_signed_in?
body: <p>I have a helper method that returns one link <code>if user_signed_in?</code>. I'm using Devise 2.2.8, Rails 3.2.2 and Rspec 3.4.0.</p>
  
  <p><strong>application_helper.rb</strong>
  </p>
  
  <pre><code>def session_button
    if user_signed_in?
      link_to "Restricted Area", user_index_path
    else
      link_to "Login", new_user_session_path
    end
  end
  </code></pre>
  
  <p>And my test:</p>
  
  <p><strong>application_helper_spec.rb</strong></p>
  
  <pre><code>describe "#session_button" do
    context "user signed in" do
      login_user
  
      it "returns a link to Restricted Area" do
        expect(session_button).to include "Área Restrita"
        expect(session_button).to include user_index_path
      end
    end
  
    context "user not signed in" do
      it "returns a link to New Session" do
        expect(session_button).to include "Login"
        expect(session_button).to include new_user_session_path
      end
    end
  end
  </code></pre>
  
  <p><code>login_user</code> is a macro included in my tests. I also loaded <code>TestHelpers</code>.</p>
  
  <pre><code>RSpec.configure do |config|
    config.include Devise::TestHelpers, type: :helper
    config.extend ControllerMacros, :type =&gt; :helper
  end
  </code></pre>
  
  <p>The problem: I'm getting this error:</p>
  
  <pre><code>1) ApplicationHelper#session_button user signed in returns a link to Restricted Area
     Failure/Error: if user_signed_in?
  
     NoMethodError:
       undefined method `user_signed_in?' for #&lt;RSpec::ExampleGroups::ApplicationHelper::SessionButton::UserSignedIn:0x0000000795a608&gt;
  </code></pre>
  
  <p>I also tried to stub the method</p>
  
  <pre><code>allow(helper).to receive(:user_signed_in?).and_return(true)
  </code></pre>
  
  <p>but I get the same error.</p>
  
  <p>How do I stub this devise helper?</p>