Sha256: ed01e5e35c5d8920a80a7c16ddc7fe187bdf57fe4ae5a9da3ec20e8dd4d1bd37

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe DeepL::Requests::Glossary::List do
  let(:api) { build_deepl_api }
  let(:options) { {} }
  subject { DeepL::Requests::Glossary::List.new(api, options) }

  describe '#initialize' do
    context 'When building a request' do
      it 'should create a request object' do
        expect(subject).to be_a(described_class)
      end
    end
  end

  describe '#request' do
    around do |example|
      VCR.use_cassette('glossaries') { example.call }
    end

    context 'When requesting a list of all glossaries' do
      it 'should return a glossaries object' do
        glossaries = subject.request
        expect(glossaries).to be_an(Array)
      end
    end

    context 'When performing a bad request' do
      context 'When using an invalid token' do
        let(:api) do
          api = build_deepl_api
          api.configuration.auth_key = 'invalid'
          api
        end

        it 'should raise an unauthorized error' do
          expect { subject.request }.to raise_error(DeepL::Exceptions::AuthorizationFailed)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
deepl-rb-2.5.3 spec/requests/glossary/list_spec.rb
deepl-rb-2.5.2 spec/requests/glossary/list_spec.rb
deepl-rb-2.5.1 spec/requests/glossary/list_spec.rb
deepl-rb-2.5.0 spec/requests/glossary/list_spec.rb