Sha256: 1723e10e341479d4d40408576b04e203efba6f356ac935fb01eea782c12036fe

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe LsOmniauth::Config do
  let(:client_id)     { "client_id" }
  let(:client_secret) { "client_secret" }
  let(:dev_mode)      { true }
  let(:environment)   { double('Environment', production?: false)}
  subject { LsOmniauth::Config.new({'client_id' => client_id, :client_secret => client_secret, :foo => "bar", :dev_mode => dev_mode, :environment => environment}) }

  it "acts like a HWIA" do
    expect(subject[:client_id]).to eq(client_id)
    expect(subject['client_secret']).to eq(client_secret)
    expect(subject[:foo]).to eq("bar")
  end

  describe '#valid?' do
    context 'when  client_id is nil' do
      let(:client_id) { nil }

      it 'returns false' do
        expect(subject.valid?).to eq(false)
      end
    end

    context 'when  client_secret is nil' do
      let(:client_secret) { nil }

      it 'returns false' do
        expect(subject.valid?).to eq(false)
      end
    end

    context 'when client_secret and client_id are present' do
      it 'returns true' do
        expect(subject.valid?).to eq(true)
      end
    end
  end

  describe '#running_in_dev_mode?' do
    context 'when dev_mode key is not true' do
      let(:dev_mode) { false }

      it 'returns false' do
        expect(subject.running_in_dev_mode?).to eq(false)
      end
    end

    context 'when dev_mode key is true' do
      let(:dev_mode)      { true }

      context 'and Rails is in production mode' do
        before(:each) { expect(LS_OMNIAUTH).to receive(:environment).and_return(double('Environment', production?: true) ) }

        it 'returns false' do
          expect(subject.running_in_dev_mode?).to eq(false)
        end
      end

      context 'and Rails is not in production mode' do
        before(:each) { expect(LS_OMNIAUTH).to receive(:environment).and_return(double('Environment', production?: false) ) }

        it 'returns false' do
          expect(subject.running_in_dev_mode?).to eq(true)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ls-omniauth-3.0.3 spec/models/ls_omniauth/config_spec.rb