Sha256: d9a6034f8e4e8bbdd59d397916a8147b50cf1e7e29746ed8aef262245f521163

Contents?: true

Size: 1.96 KB

Versions: 51

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

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

  describe '#create_phone_number' do
    context 'arguments' do
      subject { client.create_phone_number }

      it 'requires `number_type_value_id`' do
        expect { subject }.to raise_error(ArgumentError, /number_type_value_id/)
      end

      it 'requires `number`' do
        expect { subject }.to raise_error(ArgumentError, /number/)
      end

      it 'requires `person_id`' do
        expect { subject }.to raise_error(ArgumentError, /person_id/)
      end
    end

    subject(:resource) do
      client.create_phone_number(
        number_type_value_id: 13,
        number: '5555555555',
        person_id: 1
      )
    end

    it 'returns an integer' do
      expect(resource).to be_a(Integer)
    end

    it 'passes options' do
      expect(client).to receive(:post)
        .with(
          'PhoneNumbers',
          {
            'IsSystem' => true,
            'IsMessagingEnabled' => false,
            'NumberTypeValueId' => 13,
            'Number' => '5555555555',
            'PersonId' => 1
          }
        ).and_call_original
      resource
    end
  end

  describe '#list_phone_numbers(options = {})' do
    subject(:resource) { client.list_phone_numbers }

    it 'returns a array of hashes' do
      expect(resource).to be_a(Array)
      expect(resource.first).to be_a(Hash)
    end

    it 'queries phone numbers' do
      expect(client).to receive(:get).with('PhoneNumbers', {}).and_call_original
      resource
    end

    it 'passes options' do
      expect(client).to receive(:get)
        .with('PhoneNumbers', { option1: '1' })
        .and_return([])
      client.list_phone_numbers(option1: '1')
    end

    it 'formats with PhoneNumber' do
      response = double
      expect(RockRMS::Response::PhoneNumber).to receive(:format).with(response)
      allow(client).to receive(:get).and_return(response)
      resource
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
rock_rms-9.13.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.12.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.11.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.10.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.9.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.8.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.7.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.6.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.5.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.4.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.3.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.2.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.1.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-9.0.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-8.23.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-8.22.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-8.21.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-8.20.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-8.19.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-8.18.0 spec/rock_rms/resources/phone_number_spec.rb