ruby-on-railsrubydevisewarden

How to sign in without warden callback on rspec (request spec)


I'd like to call sign_in(user) on request spec without warden callback.
Does anybody know a workaround?

I want to use something like bypass_sign_in on request spec.

I tried below.

config.include Devise::Test::IntegrationHelpers, type: :feature
RSpec.describe '/ajax/stores', type: :request do
    context 'login as valid user' do
      it do
        sign_in(user)
      end
    end
end
RSpec.describe '/ajax/stores', type: :request do
    context 'login as valid user' do
      it do
        login_as(user, bypass: true)
      end
    end
end

Solution

  • You can pass run_callbacks: false option to Warden's login_as helper:

    login_as(user, run_callbacks: false)