Sha256: 326f2b4432daa271fb8e682ac19297cd42bf6dba93fc77468d213bfd0a451220

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'phone_number.rb')
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'constants.rb')

context "A NumericalString" do
  specify "should be accessable as a Fixnum to a case statement" do
    (123 === NumericalString.new("123")).should == true
    (987 === NumericalString.new("0987")).should == true
  end
  specify "should be accessable as a String to a case statement" do
    ("123" === NumericalString.new("123")).should == true
    ("0987" === NumericalString.new("0987")).should == true
  end
  
  specify "should satisfy Ranges" do
    (100..200).should === NumericalString.new("150")
    (100..200).should === NumericalString.new("0150")
    ((100..200) === NumericalString.new("1000000")).should === false
  end
  
  specify "should satify regular expressions" do
    /^\d+$/.should === NumericalString.new("027316287")
  end
end
# 
# case extension
#   when US_NUMBER
#   when (100..200)
#   when _('12Z')
#   when 123
#   when "123"
# end

context "A PhoneNumber" do
  specify "should have an ISN pattern-matching method" do
    !! PhoneNumber.new("0115544332211").isn?.should == false
    !! PhoneNumber.new("1*548").isn?.should === false
  end
  
  specify "should have a US local number pattern-matching method" do
    !! PhoneNumber.new("18887776665555").local_number?.should == false
    !! PhoneNumber.new("18887776665555").national_number?.should == true
    
    !! PhoneNumber.new("8887776665555").local_number?.should == false
    !! PhoneNumber.new("8887776665555").national_number?.should == true
     
    !! PhoneNumber.new("4445555").local_number?.should == true
    !! PhoneNumber.new("4445555").national_number?.should == false
  end
  
  specify "should convert from vanity numbers properly" do
    PhoneNumber.from_vanity("1-800-FUDGEME").should == "18003834363"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adhearsion-0.7.7 test/specs/numerical_string_spec.rb