Sha256: d4eb24957fda95d41dfb8482cf3a0d9eb02af6cc7090558ab42c4c5bd0bbd3a0

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ::Pipedrive do
  subject { described_class }

  before do
    described_class.reset!
  end

  describe '#reset!' do
    describe '#user_agent' do
      subject { super().user_agent }

      it { is_expected.to eq("Pipedrive Ruby Client v#{::Pipedrive::VERSION}") }
    end

    describe '#api_token' do
      subject { super().api_token }

      it { is_expected.to be_nil }
    end

    describe '#logger' do
      subject { super().logger }

      it { is_expected.to be_kind_of(::Logger) }
    end
  end

  describe '#setup' do
    context 'single call' do
      let(:client) { described_class }

      it 'sets user_agent' do
        client.setup do |c|
          c.user_agent = 'Test1245'
        end
        expect(client.user_agent).to eq('Test1245')
      end

      it 'sets logger' do
        newlogger = ::Logger.new($stderr)
        client.setup do |c|
          c.logger = newlogger
        end
        expect(client.logger).to eq(newlogger)
      end

      it 'sets api_token' do
        client.setup do |c|
          c.api_token = 'test-api-key'
        end
        expect(client.api_token).to eq('test-api-key')
      end
    end

    context 'with double call' do
      let(:client) { described_class }

      it 'does not accept running setup more then once' do
        client.setup do |c|
          c.api_token = 'test-api-key'
        end
        client.setup do |c|
          c.api_token = 'test-api-key2'
        end
        expect(client.api_token).to eq('test-api-key')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
pipedrive_api_rb-1.0.2 spec/lib/pipedrive_spec.rb
pipedrive_api_rb-1.0.1 spec/lib/pipedrive_spec.rb
pipedrive_api_rb-1.0.0 spec/lib/pipedrive_spec.rb
pipedrive.rb-0.3.0 spec/lib/pipedrive_spec.rb