Sha256: ca25fdf557b02be6210d07d978b405b7de97435e878788ccccb52c938f0fc30f

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'
require 'adhearsion/voip/constants'
require 'adhearsion/voip/dsl/numerical_string'


# Use cases...
# case extension
#   when US_NUMBER
#   when (100..200)
#   when _('12Z')
#   when 123
#   when "123"
# end

def should_be_nil_or_false(arg)
  [nil, false].include?(arg).should == true
end

def should_not_be_nil_or_false(arg)
  [nil, false].include?(arg).should == false
end

describe "A PhoneNumber" do

  it "should have an ISN pattern-matching method" do
    should_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("0115544332211").isn?
    should_not_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("1*548").isn?
  end

  it "should have a US local number pattern-matching method" do
    should_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("18887776665555").us_local_number?
    should_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("18887776665555").us_national_number?

    should_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("8887776665555").us_local_number?
    should_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("8887776665555").us_national_number?

    should_not_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("4445555").us_local_number?
    should_be_nil_or_false Adhearsion::VoIP::DSL::PhoneNumber.new("4445555").us_national_number?
  end

  it "should convert from vanity numbers properly" do
    Adhearsion::VoIP::DSL::PhoneNumber.from_vanity("1-800-FUDGEME").should == "18003834363"
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
adhearsion-1.2.6 spec/adhearsion/voip/phone_number_spec.rb
adhearsion-1.2.5 spec/adhearsion/voip/phone_number_spec.rb
adhearsion-1.2.4 spec/adhearsion/voip/phone_number_spec.rb
adhearsion-1.2.3 spec/adhearsion/voip/phone_number_spec.rb
adhearsion-1.2.1 spec/adhearsion/voip/phone_number_spec.rb
adhearsion-1.2.0 spec/adhearsion/voip/phone_number_spec.rb
adhearsion-1.1.1 spec/voip/phone_number_spec.rb
adhearsion-1.1.0 spec/voip/phone_number_spec.rb
adhearsion-1.0.3 spec/voip/phone_number_spec.rb
adhearsion-1.0.2 spec/voip/phone_number_spec.rb