Sha256: dccd62435b8acca39911a8a34fe41ef4622a0baef8113609ea3fc58b43a3b0a5

Contents?: true

Size: 813 Bytes

Versions: 13

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module G5Authenticatable
  module Test
    # Helper methods for login/logout during request specs
    module RequestHelpers
      include Warden::Test::Helpers

      def login_user(user)
        login_as(user, scope: :user)
      end

      def logout_user
        logout :user
      end
    end
  end
end

RSpec.shared_context 'auth request' do
  include G5Authenticatable::Test::RequestHelpers

  let(:user) { FactoryBot.create(:g5_authenticatable_user) }

  before do
    login_user(user)
    stub_valid_access_token(user.g5_access_token)
  end

  after { logout_user }
end

RSpec.configure do |config|
  config.include G5Authenticatable::Test::RequestHelpers, type: :request
  config.after { Warden.test_reset! }
  config.include_context 'auth request', auth_request: true
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
g5_authenticatable-1.1.4 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.4.rc.3 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.4.rc.2 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.4.rc.1 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.2 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.2.pre.1 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.2.rc.5 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.2.rc.4 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.2.rc.3 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.2.rc.2 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.2.rc.1 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.1 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.1.0 lib/g5_authenticatable/test/request_helpers.rb