Sha256: edccc04caafb2ffbe51ae8e662b5a72c30451faa41b3dd02a87074fd3bcd20f7

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

RSpec.describe RockRMS::Client::Person, type: :model do
  include_context 'resource specs'

  describe '#find_person_by_name(full_name)' do
    it 'returns a array of hashes' do
      resource = client.find_person_by_name('Some Name')
      expect(resource).to be_a(Array)
      expect(resource.first).to be_a(Hash)
    end

    it 'queries people by name' do
      expect(client).to receive(:get)
        .with('People/Search', hash_including(name: 'Some Name'))
        .and_call_original
      client.find_person_by_name('Some Name')
    end

    it 'includes default options' do
      expect(client).to receive(:get)
        .with(
          'People/Search',
          hash_including(**described_class::NAME_SEARCH_DEFAULTS)
        ).and_call_original
      client.find_person_by_name('Some Name')
    end

    it 'passes options' do
      expect(client).to receive(:get)
        .with('People/Search', hash_including(option1: '1'))
        .and_call_original
      client.find_person_by_name('Some Name', option1: '1')
    end

    it 'overrides default options' do
      expect(client).to receive(:get)
        .with('People/Search', hash_including(includeHtml: true))
        .and_call_original
      client.find_person_by_name('Some Name', includeHtml: true)
    end

    it 'formats with Person' do
      response = double
      expect(RockRMS::Responses::Person).to receive(:format).with(response)
      allow(client).to receive(:get).and_return(response)
      client.find_person_by_name('Some Name')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rock_rms-2.0.0 spec/rock_rms/resources/person_spec.rb
rock_rms-1.3.0 spec/rock_rms/resources/person_spec.rb
rock_rms-1.2.0 spec/rock_rms/resources/person_spec.rb
rock_rms-1.1.0 spec/rock_rms/resources/person_spec.rb