Sha256: e2aca8233c2d19b27b4c375433ec351a6cfd0103d8d8ae20854a2e70edcbaec4

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe Passages do
  describe '.username' do
    context 'when the ENV variable is set' do
      let(:username) { 'thisisausername' }
      before do
        allow(ENV).to receive(:[]).with('passages_username') { username }
      end

      it 'uses the ENV var' do
        expect(described_class.username).to eq(username)
      end

      context 'uppercase' do
        let(:upper_username) { 'THISISANUPPERUSERNAME' }
        before do
          allow(ENV).to receive(:[]).with('passages_username') { nil }
          allow(ENV).to receive(:[]).with('PASSAGES_USERNAME') { upper_username }
        end

        it 'uses the ENV var' do
          expect(described_class.username).to eq(upper_username)
        end
      end
    end

    context 'when the ENV variable is not set' do
      it 'uses the default value' do
        expect(described_class.username).to eq('username')
      end
    end
  end

  describe '.password' do
    context 'when the ENV variable is set' do
      let(:password) { 'thisisapassword' }
      before do
        allow(ENV).to receive(:[]).with('passages_password') { password }
      end

      it 'uses the ENV var' do
        expect(described_class.password).to eq(password)
      end

      context 'uppercase' do
        let(:upper_password) { 'THISISANUPPERPASSWORD' }
        before do
          allow(ENV).to receive(:[]).with('passages_password') { nil }
          allow(ENV).to receive(:[]).with('PASSAGES_PASSWORD') { upper_password }
        end

        it 'uses the ENV var' do
          expect(described_class.password).to eq(upper_password)
        end
      end
    end

    context 'when the ENV variable is not set' do
      it 'uses the default value' do
        expect(described_class.password).to eq('password')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
passages-1.2.0 spec/config/initializers/basic_auth_spec.rb
passages-1.1.0 spec/config/initializers/basic_auth_spec.rb