Sha256: efab0c58abaf47c2cf9815fc3975375769cd5a2d5bfc141b145f304c656b3612

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

RSpec.describe Lokalise do
  specify '.client' do
    expect(test_client).to be_an_instance_of(Lokalise::Client)
    expect(test_client.token).to eq(ENV['LOKALISE_API_TOKEN'])
    expect(test_client.timeout).to be_nil
    expect(test_client.open_timeout).to be_nil
    expect(test_client.enable_compression).to be false
  end

  specify '.reset_client!' do
    expect(test_client).to be_an_instance_of(Lokalise::Client)
    described_class.reset_client!
    current_client = described_class.instance_variable_get '@client'
    expect(current_client).to be_nil
  end

  specify '.oauth_client' do
    expect(test_oauth_client).to be_an_instance_of(Lokalise::OAuthClient)
    expect(test_oauth_client.token).to eq("Bearer #{ENV['LOKALISE_API_TOKEN']}")
    expect(test_oauth_client.timeout).to be_nil
    expect(test_oauth_client.open_timeout).to be_nil
    expect(test_oauth_client.enable_compression).to be false
  end

  specify '.reset_oauth_client!' do
    expect(test_oauth_client).to be_an_instance_of(Lokalise::OAuthClient)
    described_class.reset_oauth_client!
    current_oauth_client = described_class.instance_variable_get '@oauth_client'
    expect(current_oauth_client).to be_nil
  end

  context 'with client params' do
    before { described_class.reset_client! }

    after { described_class.reset_client! }

    it 'is possible to customize timeout' do
      custom_client = described_class.client(ENV['LOKALISE_API_TOKEN'], timeout: 600)
      expect(custom_client.timeout).to eq(600)
    end

    it 'is possible to customize open timeout' do
      custom_client = described_class.client(ENV['LOKALISE_API_TOKEN'], open_timeout: 100)
      expect(custom_client.open_timeout).to eq(100)
    end

    it 'is possible to customize compression' do
      custom_client = described_class.client(ENV['LOKALISE_API_TOKEN'], enable_compression: true)
      expect(custom_client.enable_compression).to be true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-lokalise-api-4.5.0 spec/lib/ruby-lokalise-api_spec.rb
ruby-lokalise-api-4.4.0 spec/lib/ruby-lokalise-api_spec.rb