Sha256: 299e9cc5b02dadecc4eb3409927e632818aecc53fe0a4f8c043781701405ac26

Contents?: true

Size: 870 Bytes

Versions: 7

Compression:

Stored size: 870 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Macros::Auth::SignOut do
  include Warden::Test::Mock

  subject(:sign_out_step) { described_class.new }

  let(:user) { mock_model('User') }
  let(:scope) { :user }
  let(:ctx) { { warden: warden } }

  before do
    fake_class = Class.new
    dm = stub_const('Devise::Mapping', fake_class, transfer_nested_constants: true)
    allow(dm).to receive(:find_scope!).with(scope).and_return(scope)
  end

  context 'user signed in' do
    before do
      warden.set_user(user, scope: scope)
    end

    it 'expects to sign out user' do
      sign_out_step.call(ctx, warden: warden)

      expect(ctx[:current_user]).to be nil
    end
  end

  context 'user not signed in' do
    it 'expects to keep user signed out' do
      sign_out_step.call(ctx, warden: warden)

      expect(ctx[:current_user]).to be nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ff-tbl-macros-2.0.2 spec/lib/auth/sign_out_spec.rb
ff-tbl-macros-2.0.1 spec/lib/auth/sign_out_spec.rb
ff-tbl-macros-2.0.0 spec/lib/auth/sign_out_spec.rb
ff-tbl-macros-1.0.2 spec/lib/auth/sign_out_spec.rb
ff-tbl-macros-1.0.1 spec/lib/auth/sign_out_spec.rb
ff-tbl-macros-1.0.0 spec/lib/auth/sign_out_spec.rb
ff-tbl-macros-0.1.8 spec/lib/auth/sign_out_spec.rb