lundi 24 septembre 2018

Rspec test with login devise just working 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. If I add 3 tests the last fails and the first 2 passes. If I change :all to :each the first one fails and the second passes

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