title: How do I test helpers in Rails 4?
body: <p>With this <code>ApplicationHelper</code>:</p>
  
  <pre><code>class ApplicationHelper 
    def my_method
      link_to 'foo', 'bar'
    end  
  end
  </code></pre>
  
  <p>and this <code>application_helper_spec</code>:</p>
  
  <pre><code>require 'rails_helper'
  
  describe ApplicationHelper do
    describe 'links' do 
      it 'should call a helper method' do
        expect(helper.my_method).to eq("&lt;a href='bar'&gt;foo&lt;/a&gt;")
      end
    end
  end
  </code></pre>
  
  <p>I'm having trouble getting things to work as as I expected from the <a href="https://www.relishapp.com/rspec/rspec-rails/v/3-4/docs/helper-specs/helper-spec" rel="nofollow">latest documentation I can find on Rails helper specs</a>. (The docs are for Ruby 3 and I'm using 4.) There doesn't appear to be a <code>helper</code> object:</p>
  
  <pre><code>undefined local variable or method `helper' for #&lt;RSpec::ExampleGroups::ApplicationHelper::Links:0x007fda1895c2f8&gt;
  </code></pre>
  
  <p>If instead I do this:</p>
  
  <pre><code>require 'rails_helper'
  include ApplicationHelper
  
  describe ApplicationHelper do
    describe 'links' do 
      it 'should call a helper method' do
        expect(my_method).to eq("&lt;a href='bar'&gt;foo&lt;/a&gt;")
      end
    end
  end
  </code></pre>
  
  <p>now <code>my_method</code> is called correctly but <code>link_to</code> is not defined:</p>
  
  <pre><code>undefined method `link_to' for #&lt;RSpec::ExampleGroups::ApplicationHelper::Links:0x007fda1c4c3e90&gt;
  </code></pre>
  
  <p>(This latter case is the same as if I define <code>config.include ApplicationHelper</code> in <code>rails_helper</code>.)</p>
  
  <p>Obviously the spec environment does not include all the standard Rails helpers. What am I doing wrong here? </p>