Sha256: 14c0310eb4ec87a0a0ec561d4650943d3dc909a74770505637030b2f5d4dcdbc
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' describe DeepL::Configuration do let(:attributes) { {} } subject { DeepL::Configuration.new(attributes) } describe '#initialize' do context 'When using default configuration attributes' do it 'should use default attributes' do expect(subject.auth_key).to eq(ENV['DEEPL_AUTH_KEY']) expect(subject.host).to eq('https://api.deepl.com') end end context 'When using custom configuration attributes' do let(:attributes) { { auth_key: 'SAMPLE', host: 'http://www.example.org' } } it 'should use custom attributes' do expect(subject.auth_key).to eq(attributes[:auth_key]) expect(subject.host).to eq(attributes[:host]) end end end describe '#validate!' do let(:auth_message) { 'auth_key not provided' } context 'When providing a valid auth key' do let(:attributes) { { auth_key: '' } } it 'should raise an error' do expect { subject.validate! }.to raise_error(DeepL::Exceptions::Error, auth_message) end end context 'When providing an invalid auth key' do let(:attributes) { { auth_key: 'not-empty' } } it 'should not raise an error' do expect { subject.validate! }.not_to raise_error end end end end
Version data entries
6 entries across 6 versions & 1 rubygems