Sha256: 91a323c0d3e49dfc7fd31752b486e3eab7211462209c27b15ef866e8648aa3cb
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true 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') expect(subject.version).to eq('v2') end end context 'When using custom configuration attributes' do let(:attributes) { { auth_key: 'SAMPLE', host: 'https://api-free.deepl.com', version: 'v1' } } it 'should use custom attributes' do expect(subject.auth_key).to eq(attributes[:auth_key]) expect(subject.host).to eq(attributes[:host]) expect(subject.version).to eq(attributes[:version]) 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
deepl-rb-2.5.0 | spec/api/configuration_spec.rb |
deepl-rb-2.4.0 | spec/api/configuration_spec.rb |
deepl-rb-2.3.1 | spec/api/configuration_spec.rb |
deepl-rb-2.3.0 | spec/api/configuration_spec.rb |