Sha256: 1fdca02b325734b692387c82751795d84eb1345f656e50a6c548c8de1c8ec954

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

require 'spec_helper'

shared_examples_for 'a warden authenticatable api' do
  context 'when user is authenticated' do
    let(:user) { create(:user) }

    before do
      login_as(user, scope: :user)
      subject
    end

    it 'should be successful' do
      expect(response).to be_success
    end
  end

  context 'when user is not authenticated' do
    before do
     logout
     subject
    end

    it 'should be unauthorized' do
      expect(response).to be_http_unauthorized
    end

    it 'should return an authenticate header without details' do
      expect(response.headers).to include('WWW-Authenticate' => 'Bearer')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
g5_authenticatable_api-0.2.0 spec/support/shared_examples/warden_authenticatable_api.rb