Sha256: a6da3dbc439bffcce8aece90ccdea51754e5781d2184d69b876f7f4e052e8a0f

Contents?: true

Size: 1.92 KB

Versions: 39

Compression:

Stored size: 1.92 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

39 entries across 39 versions & 1 rubygems

Version Path
rock_rms-6.2.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.1.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.8 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.7 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.6 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.5 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.4 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.3 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.1 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-6.0.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.18.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.17.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.16.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.15.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.14.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.13.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.12.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.11.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.10.0 spec/rock_rms/resources/phone_number_spec.rb
rock_rms-5.9.2 spec/rock_rms/resources/phone_number_spec.rb