Sha256: 0bfcff8a8eac4e1337470614eb1da3339a77846ec2c9285102f1fb985696d84b

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe DeepL::Requests::Glossary::Destroy do
  let(:api) { build_deepl_api }
  let(:id) { '367eef44-b533-4d95-be19-74950c7760e9' }
  subject { DeepL::Requests::Glossary::Destroy.new(api, id) }

  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 performing a valid request' do
      let(:new_glossary) do
        DeepL::Requests::Glossary::Create.new(api, 'fixture', 'EN', 'ES', [%w[Hello Hola]]).request
      end
      subject { DeepL::Requests::Glossary::Destroy.new(api, new_glossary.id) }
      it 'should return an empty object' do
        response = subject.request
        expect(response).to eq(new_glossary.id)
      end
    end

    context 'When deleting a non existing glossary with a valid id' do
      let(:id) { '00000000-0000-0000-0000-000000000000' }
      subject { DeepL::Requests::Glossary::Destroy.new(api, id) }
      it 'should raise a not found error' do
        expect { subject.request }.to raise_error(DeepL::Exceptions::NotFound)
      end
    end

    context 'When deleting a non existing glossary with an invalid id' do
      let(:id) { 'invalid-uuid' }
      subject { DeepL::Requests::Glossary::Destroy.new(api, id) }
      it 'should raise a bad request error' do
        expect { subject.request }.to raise_error(DeepL::Exceptions::BadRequest)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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