Sha256: 49bd15cf881be00a49925b6147ce4043775f4ceafdabd551c6babf7216da7da3

Contents?: true

Size: 814 Bytes

Versions: 5

Compression:

Stored size: 814 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) { FactoryGirl.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

5 entries across 5 versions & 1 rubygems

Version Path
g5_authenticatable-1.0.0 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.0.0.pre.4 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.0.0.pre.3 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.0.0.pre.2 lib/g5_authenticatable/test/request_helpers.rb
g5_authenticatable-1.0.0.pre.1 lib/g5_authenticatable/test/request_helpers.rb