Sha256: 56392782bb7eaba3deca3e75a1eecc9b2e1a8be67c082436b2f6542f68e80c78

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

describe Onfido do
  subject(:onfido) { described_class }

  context 'configuration' do
    before { onfido.reset }

    describe "default values" do
      describe ".api_key" do
        subject { onfido.api_key }
        it { is_expected.to be_nil }
      end

      describe ".endpoint" do
        subject { onfido.endpoint }
        it { is_expected.to eq('https://api.onfido.com/v1/') }
      end

      describe ".logger" do
        subject { onfido.logger }
        it { is_expected.to be_an_instance_of(Onfido::NullLogger) }
      end
    end

    describe "setting an API key" do
      it 'changes the configuration to the new value' do
        onfido.api_key = 'some_key'
        expect(onfido.api_key).to eq('some_key')
      end
    end

    describe '.logger' do
      context 'when an option is passed' do
        context 'when the option passed behaves like a logger' do
          let(:logger_like) { double('LoggerLike', :<< => nil) }

          it 'returns the option' do
            onfido.logger = logger_like
            expect(onfido.logger).to eq(logger_like)
          end
        end

        context 'when the option passed does not behave like a logger' do
          let(:non_logger) { double('NotLogger') }

          it 'raises an error' do
            expect { onfido.logger = non_logger }.
              to raise_error(
                "#{non_logger.class} doesn't seem to behave like a logger!"
              )
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
onfido-0.3.0 spec/onfido_spec.rb
onfido-0.2.0 spec/onfido_spec.rb
onfido-0.1.0 spec/onfido_spec.rb