title: RSpec & Rails: Stub request.path for helper spec
body: <p>I have this method in <code>ApplicationHelper</code>:</p>
  
  <pre><code>def home_link_class
    classes = ['navbar-brand']
    classes &lt;&lt; 'active' if request.path == root_path
    classes
  end
  </code></pre>
  
  <p>I want to test it like this:</p>
  
  <pre><code>describe '#home_link_class' do
    before  { allow(helper.request).to receive(:path).and_return '/some-path' }
    subject { home_link_class }
  
    it { should eq ['navbar-brand'] }
  end
  </code></pre>
  
  <p>Sadly the stubbing doesn't seem to work, the <code>request</code> object in the helper itself is set to <code>nil</code>, even though in the spec it seems to be an <code>ActionController::TestRequest</code> object.</p>
  
  <p>How do I make sure that <code>request</code> is available in the spec?</p>