title: Why does RSPEC behaves differently between Edit view and New view tests with Rails 5.2?
body: <p>I am developing an application with Rails 5.2, and testing the features using Capybara.</p>
  
  <p>I want to make sure that not connected users cannot view the Playgrounds pages, and that connected ones can. Authentication is based on Devise, so that when you request an unauthorised page, you are routed to the login page. </p>
  
  <p>I wrote this test: <strong>spec/features/playgrounds_spec.rb</strong></p>
  
  <pre><code>require 'rails_helper'
  
  RSpec.describe Playground, type: :request do
    include Warden::Test::Helpers
  
    describe "Playground pages: " do
      let(:pg) {FactoryBot.create(:playground)}
  
      context "when not signed in " do
        it "should propose to log in when requesting index" do
          get playgrounds_path
          follow_redirect!
          expect(response.body).to include('Sign in')
        end
        it "should propose to log in when requesting new" do
          get new_playground_path(pg)
          follow_redirect!
          expect(response.body).to include('Sign in')
        end
        it "should propose to log in when requesting edit" do
          get edit_playground_path(pg)
          follow_redirect!
          expect(response.body).to include('Sign in')
        end
        it "should propose to log in when requesting show" do
          get playground_path(pg)
          follow_redirect!
          expect(response.body).to include('Sign in')
        end
      end
      context "when signed in" do
        before do
          get "/users/sign_in"
          test_user = FactoryBot.create(:user)
          login_as test_user, scope: :user
        end
        it "should display index" do
          get playgrounds_path
          expect(response).to render_template(:index)
        end
        it "should display new view" do
          get new_playground_path(pg)
          expect(response).to render_template(:_form)
        end
        it "should display edit view" do
          get edit_playground_path(pg)
          expect(response).to render_template(:_form)
        end
        it "should display show view" do
          get playground_path(pg)
          expect(response).to render_template(:show)
        end
      end
    end
  end
  </code></pre>
  
  <p>The test should be successful, but fails with the following error:</p>
  
  <pre><code>.F....#&lt;Playground:0x000000000d119470&gt;
  .#&lt;Playground:0x000000000e059700&gt;
  .
  
  Failures:
  
    1) Playground Playground pages:  when not signed in  should propose to log in when requesting new
       Failure/Error: follow_redirect!
  
       RuntimeError:
         not a redirect! 401 Unauthorized
       # ./spec/features/playgrounds_spec.rb:17:in `block (4 levels) in &lt;top (required)&gt;'
  
  Finished in 4.81 seconds (files took 12.28 seconds to load)
  8 examples, 1 failure
  
  Failed examples:
  
  rspec ./spec/features/playgrounds_spec.rb:15 # Playground Playground pages:  when not signed in  should propose to log in when requesting new
  </code></pre>
  
  <p>To solve this, I can simply test the status returned by the request to the New view:</p>
  
  <pre><code>  it "should propose to log in when requesting new" do
      get new_playground_path(pg)
      #follow_redirect!
      expect(response.status).to eq 401
    end
  </code></pre>
  
  <p>But it doesn't tell me if the user really lands on the login page...</p>
  
  <p><strong>One more detail:</strong> when a not connected user tries to reach this New view, he actually lands on the login page!</p>
  
  <p>Can you explain why the behaviour is different for the New view, and how to solve this issue?</p>
  
  <p>Thanks a lot! </p>