Sha256: 7f5f76b53206935709d9faec9c6b5a88cf7dfd4d0878dd38543789f85bb0ad2a

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

RSpec.describe ::Pipedrive::Person do
  subject { described_class.new('token') }
  context '#entity_name' do
    subject { super().entity_name }
    it { is_expected.to eq('persons') }
  end

  context '#find_by_name' do
    it 'should call #make_api_call with term' do
      expect(subject).to receive(:make_api_call).with(:get, 'find', {term: 'term', search_by_email: 0, start: 0})
      expect { |b| subject.find_by_name('term', &b)}.to yield_successive_args
    end
    it 'should call #make_api_call with term and search_by_email' do
      expect(subject).to receive(:make_api_call).with(:get, 'find', {term: 'term', search_by_email: 1, start: 0})
      expect { |b| subject.find_by_name('term', true, &b)}.to yield_successive_args
    end
    it 'should yield results' do
      expect(subject).to receive(:make_api_call).with(:get, 'find', {term: 'term', search_by_email: 0, start: 0}).and_return(::Hashie::Mash.new(data: [1,2], success: true))
      expect { |b| subject.find_by_name('term', &b)}.to yield_successive_args(1,2)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pipedrive.rb-0.2.0 spec/lib/pipedrive/person_spec.rb
pipedrive.rb-0.1.0 spec/lib/pipedrive/person_spec.rb