Sha256: e1b73b16f73a04d28d0a21f3d91a44e0c5bda22e3bac9d0dd701bb2bc15bc441

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ::Pipedrive::Person do
  subject { described_class.new('token') }

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

    it { is_expected.to eq('persons') }
  end

  describe '#search' do
    it 'calls #make_api_call with term' do
      expect(subject).to receive(:make_api_call).with(:get, 'search', { term: 'term', fields: nil})
      expect { |b| subject.search('term', &b) }.to yield_successive_args
    end

    it 'calls #make_api_call with term and search_by_email' do
      expect(subject).to receive(:make_api_call).with(:get, 'search', { term: 'term', fields: "email" })
      expect { |b| subject.search('term', "email", &b) }.to yield_successive_args
    end

    it 'yields results' do
      expect(subject).to receive(:make_api_call).with(:get, 'search', { term: 'term', fields: nil, start: 0 }).
        and_return(::Hashie::Mash.new(data: [1, 2], success: true))
      expect { |b| subject.search('term', &b) }.to yield_successive_args(1, 2)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pipedrive_api_rb-1.0.2 spec/lib/pipedrive/person_spec.rb
pipedrive_api_rb-1.0.1 spec/lib/pipedrive/person_spec.rb