dimanche 23 septembre 2018

Login with Devise test just work one time

I'm trying to test some views with devise and rspec. In this test, the first one passes. The second is redirect to sign_in page.

The login_as just working in the first test. Why?

require 'rails_helper'

RSpec.describe StoresController, type: :controller do
    context "with valid params" do
        user = FactoryBot.build(:user)
        before(:all) do
            login_as(user, :scope => :user)
        end

        it "renders the index template" do
            get :index
            expect(response).to render_template("index")
        end

        it "creates a new store" do
            get :new
            expect(response).to render_template("new")
        end

    end
end

Aucun commentaire:

Enregistrer un commentaire