phony 1.7.3 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
data/lib/phony/country_codes.rb
CHANGED
@@ -73,7 +73,9 @@ module Phony
|
|
73
73
|
@international_relative_format % [cc, space, ndc] :
|
74
74
|
@international_relative_format % [cc, nil, nil]
|
75
75
|
when :national
|
76
|
-
|
76
|
+
ndc && !ndc.empty? ?
|
77
|
+
@national_format % [zero, ndc] :
|
78
|
+
@national_format % [zero, nil]
|
77
79
|
when :local
|
78
80
|
EMPTY_STRING
|
79
81
|
end
|
data/lib/phony/validators.rb
CHANGED
@@ -121,7 +121,7 @@ describe 'country descriptions' do
|
|
121
121
|
Phony.split('353801234567').should == ['353', '80', '123', '4567'] # Mobile
|
122
122
|
Phony.split('353761234567').should == ['353', '76', '123', '4567'] # VoIP
|
123
123
|
Phony.split('353800123456').should == ['353', '800', '123456'] # Freefone
|
124
|
-
Phony.split('353000123456').should == ['353',
|
124
|
+
Phony.split('353000123456').should == ['353', '000', '123456'] # Default fixed 3 split for unrecognized
|
125
125
|
end
|
126
126
|
it 'handles italian numbers' do
|
127
127
|
Phony.split('3934869528').should == ['39', '3486', '952', '8'] # Mobile
|
@@ -62,6 +62,14 @@ describe Phony::CountryCodes do
|
|
62
62
|
it 'formats correctly' do
|
63
63
|
@countries.formatted('41443643532', :format => :national, :spaces => :-).should == '044-364-35-32'
|
64
64
|
end
|
65
|
+
context 'specific' do
|
66
|
+
it 'formats ireland correctly' do
|
67
|
+
@countries.formatted("3533451234", :format => :national).should == '0345 1234'
|
68
|
+
end
|
69
|
+
it 'formats ireland correctly' do
|
70
|
+
@countries.formatted("353411231234", :format => :national).should == '041 123 1234'
|
71
|
+
end
|
72
|
+
end
|
65
73
|
context 'default' do
|
66
74
|
it "should format swiss numbers" do
|
67
75
|
@countries.formatted('41443643532').should == '+41 44 364 35 32'
|