title: RSpec + Capybara: redirect_to external page sends me back to root_path
body: <p>I'm trying to write a feature test to check whether going to a certain path would redirect the user to an external website.</p>
  
  <p>To disallow external connections in my tests, I have the following in my <strong>spec_helper.rb</strong>:</p>
  
  <pre><code>require 'webmock/rspec'
  WebMock.disable_net_connect!(allow_localhost: true)
  </code></pre>
  
  <p>my spec does something like:</p>
  
  <pre><code>it 'redirects safely' do
    visit "/some/route"
  
    expect(page).not_to have_content 'MyWebsite'
  end
  </code></pre>
  
  <p>In my ApplicationController I have a <code>before_action</code> that should redirect externally based on a condition:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    before_action :redirect_to_external_website, if: :unsupported_path
  
    private
  
    def redirect_to_external_website
      redirect_to 'https://some.other.website'
    end
  
    def unsupported_path
      # Some conditions
    end 
  end
  </code></pre>
  
  <p>The redirect works as expected in development.</p>
  
  <p>When I run the spec, however, I can see there are two redirects occurring (the <code>redirect_to_external_website</code> method gets hit twice I think) and then it goes back to my root path.</p>
  
  <p>Any idea what I may be doing incorrectly?</p>
  
  <p>Thanks in advance!</p>