Sha256: b5e0d536d70b8a8fb6dee5d7a795d2c5b44cd63d15264d757e09a5f50c3ecca5

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

RSpec.describe RubyLokaliseApi do
  specify '.client' do
    expect(test_client).to be_an_instance_of(RubyLokaliseApi::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
  end

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

  specify '.oauth2_client' do
    expect(test_oauth2_client).to be_an_instance_of(RubyLokaliseApi::OAuth2Client)
    expect(test_oauth2_client.token).to eq("Bearer #{ENV['OAUTH2_TOKEN']}")
    expect(test_oauth2_client.timeout).to be_nil
    expect(test_oauth2_client.open_timeout).to be_nil
  end

  specify '.reset_oauth2_client!' do
    expect(test_oauth2_client).to be_an_instance_of(RubyLokaliseApi::OAuth2Client)
    described_class.reset_oauth2_client!
    current_oauth_client = described_class.instance_variable_get :@oauth2_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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-lokalise-api-6.0.0 spec/lib/ruby_lokalise_api_spec.rb