Sha256: 4d288685a7792709eca8a29eb772576c5ce42878efb128e37cf930f2baade50b

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Helpers::Protocols do
  describe '#extract_mpoa' do
    let(:correct_number) { '+442039605098' }

    context 'the number can be matched' do
      it 'returns the same number received through PSTN' do
        examples = %w[
          +442039605098
          +442039605098
          442039605098
        ]

        examples.each do |eg|
          expect(
            Helpers::Protocols.extract_mpoa(eg)
          ).to eq(correct_number)
        end
      end

      it 'returns a number from SIP address' do
        examples = %w[
          sip:+442039605098@somedomain.com
          sip:+442039605098@mns-interconnect-test.sip.ie1-ix.twilio.com
          sip:442039605098@mns-interconnect-test.sip.ie1-ix.twilio.com
        ]

        examples.each do |eg|
          expect(
            Helpers::Protocols.extract_mpoa(eg)
          ).to eq(correct_number)
        end
      end
    end

    context 'the number cannot be matched' do
      it 'returns the same string' do
        str = 'un_matchable'

        expect(
          Helpers::Protocols.extract_mpoa(str)
        ).to eq(str)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twilio_base-1.11.1101 spec/lib/twilio_base/helpers/protocols_spec.rb
twilio_base-1.11.11 spec/lib/twilio_base/helpers/protocols_spec.rb
twilio_base-1.9.0 spec/lib/twilio_base/helpers/protocols_spec.rb
twilio_base-1.8.0 spec/lib/twilio_base/helpers/protocols_spec.rb