Question: I have a helper method that is dependent upon `controller_name`, and I want to write tests for it.

```
module NavigationHelper
  def show_navigation?
    !sessions_controller? && !registrations_controller?
  end

  private
    def sessions_controller?
      controller_name.eql?('sessions')
    end

    def registrations_controller?
      controller_name.eql?('registrations')
    end
end

```

These are the test setup steps i have tried:

```
RSpec.describe NavigationHelper, type: :helper do
  describe '#show_navigation?' do
    it 'is false for pages served by the sessions controller' do
      # controller.params[:controller] = 'sessions'
      # assign(:controller, 'sessions')
      # controller = SessionsController
      # helper.stub(:controller_name).and_return('sessions')
      # allow(helper).to receive(:controller_name) { 'sessions' }
      expect(show_navigation?).to eq(false)
    end
  end
end

```

How can I appropriately stub the call to `controller_name`?

Answer: 
the answer from Richard did not work for me.

I had to change from

```
let(:controller_name) { 'sessions' }

```

to 

```
before do
  allow(helper).to receive(:controller_name).and_return 'sessions'
end

```

Now I can verify as usual in my helpers.
Here's a working solution:

```
require 'rails_helper'

RSpec.describe NavigationHelper, type: :helper do
  describe '#show_navigation?' do
    context 'SessionsController' do
      let(:controller_name) { 'sessions' }
      it { expect(show_navigation?).to eq(false) }
    end

    context 'RegistrationsController' do
      let(:controller_name) { 'registrations' }
      it { expect(show_navigation?).to eq(false) }
    end

    context 'other controllers' do
      it { expect(show_navigation?).to eq(true) }
    end
  end
end

```

How else might this problem be solved?