Sha256: 7d1af4e7c35d951331e5202d6b5a41119113e4ae60f4580948ccd892f061e1d2

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

describe Stenographer::Authentication, type: :model do
  it 'has a valid blueprint' do
    expect(build(:authentication)).to be_valid
  end

  describe 'Associations' do
    subject { build(:authentication) }

    it { is_expected.to have_many(:outputs).class_name('Stenographer::Output').dependent(:destroy) }
  end

  describe 'Validations' do
    subject { create(:authentication) }

    it { is_expected.to validate_presence_of(:provider) }
    it { is_expected.to validate_presence_of(:uid) }
  end

  describe 'Methods' do
    describe '.providers' do
      it 'returns all the providers available' do
        create(:authentication, provider: 'alpha')
        create(:authentication, provider: 'alpha')
        create(:authentication, provider: 'beta')

        expect(Stenographer::Authentication.providers).to eq(%w[alpha beta])
      end
    end

    describe '#credentials_hash' do
      let!(:authentication) { create(:authentication) }

      describe 'nil' do
        before :each do
          authentication.update(credentials: nil)
        end

        it 'empty hash' do
          expect(authentication.credentials_hash).to eq({})
        end
      end

      describe 'has data' do
        before :each do
          authentication.update(credentials: { country: 'Ibiza' }.to_json)
        end

        it 'hash with values' do
          expect(authentication.credentials_hash[:country]).to eq('Ibiza')
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stenographer-rails-0.6.5 spec/models/stenographer/authentication_spec.rb
stenographer-rails-0.6.4 spec/models/stenographer/authentication_spec.rb
stenographer-rails-0.6.3 spec/models/stenographer/authentication_spec.rb
stenographer-rails-0.6.2 spec/models/stenographer/authentication_spec.rb
stenographer-rails-0.6.1 spec/models/stenographer/authentication_spec.rb
stenographer-rails-0.6.0 spec/models/stenographer/authentication_spec.rb