phoney 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENCE +20 -0
- data/README.rdoc +85 -0
- data/Rakefile +37 -0
- data/lib/data/regions.yml +4179 -0
- data/lib/phoney.rb +5 -0
- data/lib/phoney/base.rb +100 -0
- data/lib/phoney/parser.rb +216 -0
- data/lib/phoney/region.rb +60 -0
- data/lib/phoney/utils.rb +52 -0
- data/lib/phoney/version.rb +11 -0
- data/phoney.gemspec +61 -0
- data/spec/parser/br_spec.rb +62 -0
- data/spec/parser/de_spec.rb +73 -0
- data/spec/parser/us_spec.rb +49 -0
- data/spec/phone_number_spec.rb +221 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +6 -0
- metadata +76 -0
data/phoney.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{phoney}
|
8
|
+
s.version = "0.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jan Habermann"]
|
12
|
+
s.date = %q{2010-02-14}
|
13
|
+
s.description = %q{Ruby library that parses a phone number and automatically formats it correctly, depending on the country/locale you set.}
|
14
|
+
s.email = %q{jan@habermann24.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"LICENCE",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"lib/data/regions.yml",
|
24
|
+
"lib/phoney.rb",
|
25
|
+
"lib/phoney/base.rb",
|
26
|
+
"lib/phoney/parser.rb",
|
27
|
+
"lib/phoney/region.rb",
|
28
|
+
"lib/phoney/utils.rb",
|
29
|
+
"lib/phoney/version.rb",
|
30
|
+
"phoney.gemspec",
|
31
|
+
"spec/parser/br_spec.rb",
|
32
|
+
"spec/parser/de_spec.rb",
|
33
|
+
"spec/parser/us_spec.rb",
|
34
|
+
"spec/phone_number_spec.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/habermann24/phoney}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.5}
|
42
|
+
s.summary = %q{Ruby library that formats phone numbers.}
|
43
|
+
s.test_files = [
|
44
|
+
"spec/parser/br_spec.rb",
|
45
|
+
"spec/parser/de_spec.rb",
|
46
|
+
"spec/parser/us_spec.rb",
|
47
|
+
"spec/phone_number_spec.rb",
|
48
|
+
"spec/spec_helper.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
+
s.specification_version = 3
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
+
else
|
57
|
+
end
|
58
|
+
else
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe PhoneNumber::Parser do
|
4
|
+
|
5
|
+
describe "with region set to [:br]" do
|
6
|
+
before(:each) do
|
7
|
+
PhoneNumber.default_region = :br
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should format a [:br] (Brazil) phone number" do
|
11
|
+
PhoneNumber::Parser.parse("123").should == "123"
|
12
|
+
PhoneNumber::Parser.parse("1234").should == "123-4"
|
13
|
+
PhoneNumber::Parser.parse("12345").should == "123-45"
|
14
|
+
PhoneNumber::Parser.parse("123456").should == "123-456"
|
15
|
+
PhoneNumber::Parser.parse("1234567").should == "123-4567"
|
16
|
+
PhoneNumber::Parser.parse("12345678").should == "1234-5678"
|
17
|
+
PhoneNumber::Parser.parse("123456789").should == "(12) 3456-789"
|
18
|
+
PhoneNumber::Parser.parse("1234567891").should == "(12) 3456-7891"
|
19
|
+
PhoneNumber::Parser.parse("12345678910").should == "123 4567-8910"
|
20
|
+
PhoneNumber::Parser.parse("123456789100").should == "(12 34) 5678-9100"
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "dialing with international prefix" do
|
24
|
+
it "should dial out with an international_prefix" do
|
25
|
+
PhoneNumber::Parser.parse("+4940123456").should == "+49 40 123456"
|
26
|
+
PhoneNumber::Parser.parse("+004940123456").should == "+00 49 40 123456"
|
27
|
+
PhoneNumber::Parser.parse("00004940123456").should == "00 00 49 40 123456"
|
28
|
+
PhoneNumber::Parser.parse("00014940123456").should == "00 01 49 40 123456"
|
29
|
+
PhoneNumber::Parser.parse("00024940123456").should == "00 02 49 40 123456"
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "given an any phone number" do
|
33
|
+
it "should ignore non-number pad characters" do
|
34
|
+
PhoneNumber::Parser.parse("!!+ 1 7--12@ 34 5.6").should == "+1 (712) 345-6"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should guess the current formatting correctly" do
|
38
|
+
PhoneNumber::Parser.parse("+17").should == "+1 (7"
|
39
|
+
PhoneNumber::Parser.parse("+171").should == "+1 (71"
|
40
|
+
PhoneNumber::Parser.parse("+1712").should == "+1 (712"
|
41
|
+
PhoneNumber::Parser.parse("+171234").should == "+1 (712) 34"
|
42
|
+
PhoneNumber::Parser.parse("+1712345").should == "+1 (712) 345"
|
43
|
+
PhoneNumber::Parser.parse("+17123456").should == "+1 (712) 345-6"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "given an invalid phone number" do
|
48
|
+
it "should use a reasonable default format" do
|
49
|
+
# the number is too long for [:br]
|
50
|
+
PhoneNumber::Parser.parse("1234567891001").should == "1234567891001"
|
51
|
+
|
52
|
+
PhoneNumber::Parser.parse("+++494070123").should == "+++494070123"
|
53
|
+
PhoneNumber::Parser.parse("++494070123").should == "++494070123"
|
54
|
+
PhoneNumber::Parser.parse("+01494070123").should == "+01494070123"
|
55
|
+
PhoneNumber::Parser.parse("+00000000").should == "+00 000000"
|
56
|
+
PhoneNumber::Parser.parse("0000000000").should == "00 00 000000"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe PhoneNumber::Parser do
|
4
|
+
|
5
|
+
describe "with region set to [:de] (Germany)" do
|
6
|
+
before(:each) do
|
7
|
+
PhoneNumber.default_region = :de
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "given a valid phone number" do
|
11
|
+
it "should output the correct format" do
|
12
|
+
# with national prefix '0'
|
13
|
+
PhoneNumber::Parser.parse("040789554488").should == "040 789554488"
|
14
|
+
# without national prefix '0'
|
15
|
+
PhoneNumber::Parser.parse("40789554488").should == "40 789554488"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "without international prefix" do
|
20
|
+
describe "given an any phone number" do
|
21
|
+
it "should guess the current formatting correctly" do
|
22
|
+
PhoneNumber::Parser.parse("04").should == "04"
|
23
|
+
PhoneNumber::Parser.parse("040").should == "040"
|
24
|
+
PhoneNumber::Parser.parse("0407").should == "040 7"
|
25
|
+
|
26
|
+
PhoneNumber::Parser.parse("4").should == "4"
|
27
|
+
PhoneNumber::Parser.parse("40").should == "40"
|
28
|
+
PhoneNumber::Parser.parse("407").should == "40 7"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "with internatoinal prefix" do
|
34
|
+
describe "given an any phone number" do
|
35
|
+
it "should guess the current formatting correctly" do
|
36
|
+
PhoneNumber::Parser.parse("+494").should == "+49 4"
|
37
|
+
PhoneNumber::Parser.parse("+4940").should == "+49 40"
|
38
|
+
PhoneNumber::Parser.parse("+49407").should == "+49 40 7"
|
39
|
+
PhoneNumber::Parser.parse("+494070").should == "+49 40 70"
|
40
|
+
PhoneNumber::Parser.parse("+4940705").should == "+49 40 705"
|
41
|
+
PhoneNumber::Parser.parse("+49407055").should == "+49 40 7055"
|
42
|
+
PhoneNumber::Parser.parse("+494070558").should == "+49 40 70558"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "with country specific internatoinal prefix" do
|
48
|
+
describe "given an any phone number" do
|
49
|
+
it "should guess the current formatting correctly" do
|
50
|
+
PhoneNumber::Parser.parse("00494").should == "00 49 4"
|
51
|
+
PhoneNumber::Parser.parse("004940").should == "00 49 40"
|
52
|
+
PhoneNumber::Parser.parse("0049407").should == "00 49 40 7"
|
53
|
+
PhoneNumber::Parser.parse("00494070").should == "00 49 40 70"
|
54
|
+
PhoneNumber::Parser.parse("004940705").should == "00 49 40 705"
|
55
|
+
PhoneNumber::Parser.parse("0049407055").should == "00 49 40 7055"
|
56
|
+
PhoneNumber::Parser.parse("00494070558").should == "00 49 40 70558"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "given an invalid phone number" do
|
62
|
+
it "should use a reasonable default format" do
|
63
|
+
# the number is too long for [:de]
|
64
|
+
PhoneNumber::Parser.parse("040123456789123456789").should == "040123456789123456789"
|
65
|
+
|
66
|
+
PhoneNumber::Parser.parse("+++494070123").should == "+++494070123"
|
67
|
+
PhoneNumber::Parser.parse("++494070123").should == "++494070123"
|
68
|
+
PhoneNumber::Parser.parse("+01494070123").should == "+01494070123"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe PhoneNumber::Parser do
|
4
|
+
|
5
|
+
describe "with region set to [:us]" do
|
6
|
+
before(:each) do
|
7
|
+
PhoneNumber.default_region = :us
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should format a [:us] (USA) phone number" do
|
11
|
+
PhoneNumber::Parser.parse("5689780").should == "568-9780"
|
12
|
+
PhoneNumber::Parser.parse("7045689780").should == "(704) 568-9780"
|
13
|
+
PhoneNumber::Parser.parse("17045689780").should == "1 (704) 568-9780"
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "dialing with international prefix" do
|
17
|
+
it "should not dialout without the prefix" do
|
18
|
+
PhoneNumber::Parser.parse("4940123456").should == "(494) 012-3456"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should dial out with an international_prefix" do
|
22
|
+
PhoneNumber::Parser.parse("0114940123456").should == "011 49 40 123456"
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "given an any phone number" do
|
26
|
+
it "should ignore non-number pad characters" do
|
27
|
+
PhoneNumber::Parser.parse("!!+ 1 7--12@ 34 5.6").should == "+1 (712) 345-6"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should guess the current formatting correctly" do
|
31
|
+
PhoneNumber::Parser.parse("+17").should == "+1 (7"
|
32
|
+
PhoneNumber::Parser.parse("+171").should == "+1 (71"
|
33
|
+
PhoneNumber::Parser.parse("+1712").should == "+1 (712"
|
34
|
+
PhoneNumber::Parser.parse("+171234").should == "+1 (712) 34"
|
35
|
+
PhoneNumber::Parser.parse("+1712345").should == "+1 (712) 345"
|
36
|
+
PhoneNumber::Parser.parse("+17123456").should == "+1 (712) 345-6"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "given an invalid phone number" do
|
41
|
+
it "should use a reasonable default format" do
|
42
|
+
# the number is too long for [:us]
|
43
|
+
PhoneNumber::Parser.parse("+1704123456789").should == "+1 704123456789"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe PhoneNumber do
|
4
|
+
|
5
|
+
describe "with region set to [:us]" do
|
6
|
+
before(:each) do
|
7
|
+
PhoneNumber.default_region = :us
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should format a valid number according to [:us] formatting" do
|
11
|
+
pn = PhoneNumber.new '7041234567'
|
12
|
+
pn.to_s.should == "+1 (704) 123-4567"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# def test_number_without_country_code_initialize
|
21
|
+
# PhoneNumber.default_country_code = nil
|
22
|
+
#
|
23
|
+
# assert_raise RuntimeError do
|
24
|
+
# pn = PhoneNumber.new '5125486', '91'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# def test_number_without_country_and_area_code_initialize
|
29
|
+
# PhoneNumber.default_country_code = nil
|
30
|
+
# PhoneNumber.default_area_code = nil
|
31
|
+
#
|
32
|
+
# assert_raise RuntimeError do
|
33
|
+
# pn = PhoneNumber.new '451588'
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# def test_number_with_default_area_code_initialize
|
38
|
+
# PhoneNumber.default_country_code = '385'
|
39
|
+
# PhoneNumber.default_area_code = '47'
|
40
|
+
#
|
41
|
+
# pn = PhoneNumber.new '451588'
|
42
|
+
# assert pn.number == '451588'
|
43
|
+
# assert pn.area_code == '47'
|
44
|
+
# assert pn.country_code == '385'
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# def test_number_with_default_country_code_initialize
|
48
|
+
# PhoneNumber.default_country_code = '386'
|
49
|
+
#
|
50
|
+
# pn = PhoneNumber.new '5125486', '91'
|
51
|
+
# assert pn.number == '5125486'
|
52
|
+
# assert pn.area_code == '91'
|
53
|
+
# assert pn.country_code == '386'
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# def test_number_with_country_code_initialize
|
57
|
+
# PhoneNumber.default_country_code = '387'
|
58
|
+
#
|
59
|
+
# pn = PhoneNumber.new '5125486', '91', '385'
|
60
|
+
# assert pn.number == '5125486'
|
61
|
+
# assert pn.area_code == '91'
|
62
|
+
# assert pn.country_code == '385'
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# def test_parse_empty
|
66
|
+
# assert_equal PhoneNumber.parse(''), nil
|
67
|
+
# assert_equal PhoneNumber.parse(nil), nil
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# def test_parse_long_without_special_characters
|
71
|
+
# pn = PhoneNumber.parse "+385915125486"
|
72
|
+
#
|
73
|
+
# assert_equal pn.number, '5125486'
|
74
|
+
# assert_equal pn.area_code, '91'
|
75
|
+
# assert_equal pn.country_code, '385'
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# def test_parse_zagreb_long_without_special_characters
|
79
|
+
# pn = PhoneNumber.parse "+38513668734"
|
80
|
+
#
|
81
|
+
# assert_equal pn.number, '3668734'
|
82
|
+
# assert_equal pn.area_code, '1'
|
83
|
+
# assert_equal pn.country_code, '385'
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# def test_parse_long_with_special_characters
|
87
|
+
# pn = PhoneNumber.parse "+ 385 (91) 512 / 5486 "
|
88
|
+
#
|
89
|
+
# assert pn.number == '5125486'
|
90
|
+
# assert pn.area_code == '91'
|
91
|
+
# assert pn.country_code == '385'
|
92
|
+
# end
|
93
|
+
#
|
94
|
+
# def test_parse_long_with_leading_zeros
|
95
|
+
# pn = PhoneNumber.parse "00385915125486"
|
96
|
+
#
|
97
|
+
# assert pn.number == '5125486'
|
98
|
+
# assert pn.area_code == '91'
|
99
|
+
# assert pn.country_code == '385'
|
100
|
+
# end
|
101
|
+
#
|
102
|
+
# def test_parse_zagreb_long_with_leading_zeros
|
103
|
+
# pn = PhoneNumber.parse "0038513668734"
|
104
|
+
#
|
105
|
+
# assert pn.number == '3668734'
|
106
|
+
# assert pn.area_code == '1'
|
107
|
+
# assert pn.country_code == '385'
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# def test_parse_short_without_special_characters_without_country
|
111
|
+
# PhoneNumber.default_country_code = nil
|
112
|
+
#
|
113
|
+
# assert_raise RuntimeError do
|
114
|
+
# pn = PhoneNumber.parse "0915125486"
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# def test_parse_short_without_special_characters_with_country
|
119
|
+
# PhoneNumber.default_country_code = '385'
|
120
|
+
#
|
121
|
+
# pn = PhoneNumber.parse "044885047"
|
122
|
+
#
|
123
|
+
# assert_equal pn.number, '885047'
|
124
|
+
# assert_equal pn.area_code, '44'
|
125
|
+
# assert pn.country_code == '385'
|
126
|
+
# end
|
127
|
+
#
|
128
|
+
# def test_parse_zagreb_short_without_special_characters_with_country
|
129
|
+
# PhoneNumber.default_country_code = '385'
|
130
|
+
#
|
131
|
+
# pn = PhoneNumber.parse "013668734"
|
132
|
+
#
|
133
|
+
# assert_equal pn.number, '3668734'
|
134
|
+
# assert_equal pn.area_code, '1'
|
135
|
+
# assert_equal pn.country_code, '385'
|
136
|
+
# end
|
137
|
+
#
|
138
|
+
# def test_parse_short_with_special_characters_without_country
|
139
|
+
# PhoneNumber.default_country_code = nil
|
140
|
+
#
|
141
|
+
# assert_raise RuntimeError do
|
142
|
+
# pn = PhoneNumber.parse "091/512-5486"
|
143
|
+
# end
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# def test_parse_long_with_zero_in_brackets
|
147
|
+
# PhoneNumber.default_country_code = nil
|
148
|
+
#
|
149
|
+
# pn = PhoneNumber.parse '+385 (0)1 366 8111'
|
150
|
+
# assert_equal pn.country_code, '385'
|
151
|
+
# assert_equal pn.area_code, '1'
|
152
|
+
# assert_equal pn.number, '3668111'
|
153
|
+
# end
|
154
|
+
#
|
155
|
+
#
|
156
|
+
#
|
157
|
+
# def test_to_s
|
158
|
+
# PhoneNumber.default_country_code = nil
|
159
|
+
# pn = PhoneNumber.new '5125486', '91', '385'
|
160
|
+
# assert pn.to_s == '+385915125486'
|
161
|
+
# end
|
162
|
+
#
|
163
|
+
# def test_to_s_without_country_code
|
164
|
+
# PhoneNumber.default_country_code = '385'
|
165
|
+
# pn = PhoneNumber.new '5125486', '91'
|
166
|
+
# assert pn.format("0%a%n") == '0915125486'
|
167
|
+
# end
|
168
|
+
#
|
169
|
+
# def test_format_special_with_country_code
|
170
|
+
# PhoneNumber.default_country_code = nil
|
171
|
+
# pn = PhoneNumber.new '5125486', '91', '385'
|
172
|
+
# assert pn.format("+ %c (%a) %n") == '+ 385 (91) 5125486'
|
173
|
+
# end
|
174
|
+
#
|
175
|
+
# def test_format_special_without_country_code
|
176
|
+
# PhoneNumber.default_country_code = '385'
|
177
|
+
# pn = PhoneNumber.new '5125486', '91'
|
178
|
+
# assert_equal pn.format("%A/%f-%l"), '091/512-5486'
|
179
|
+
# end
|
180
|
+
#
|
181
|
+
# def test_format_with_symbol_specifier
|
182
|
+
# PhoneNumber.default_country_code = nil
|
183
|
+
# pn = PhoneNumber.new '5125486', '91', '385'
|
184
|
+
# assert_equal pn.format(:europe), '+385 (0) 91 512 5486'
|
185
|
+
# end
|
186
|
+
#
|
187
|
+
# def test_doesnt_validate
|
188
|
+
# assert_equal PhoneNumber.valid?('asdas'), false
|
189
|
+
# assert_equal PhoneNumber.valid?('385915125486'), false
|
190
|
+
# end
|
191
|
+
#
|
192
|
+
# def test_validates
|
193
|
+
# PhoneNumber.default_country_code = nil
|
194
|
+
# assert_equal PhoneNumber.valid?('00385915125486'), true
|
195
|
+
# assert_equal PhoneNumber.valid?('+385915125486'), true
|
196
|
+
# assert_equal PhoneNumber.valid?('+385 (91) 512 5486'), true
|
197
|
+
# assert_equal PhoneNumber.valid?('+38547451588'), true
|
198
|
+
#
|
199
|
+
# PhoneNumber.default_country_code = '385'
|
200
|
+
# assert_equal PhoneNumber.valid?('0915125486'), true
|
201
|
+
# assert_equal PhoneNumber.valid?('091/512-5486'), true
|
202
|
+
# assert_equal PhoneNumber.valid?('091/512-5486'), true
|
203
|
+
# assert_equal PhoneNumber.valid?('091 512 54 86'), true
|
204
|
+
# assert_equal PhoneNumber.valid?('091-512-54-86'), true
|
205
|
+
# assert_equal PhoneNumber.valid?('047/451-588'), true
|
206
|
+
# end
|
207
|
+
#
|
208
|
+
# def test_has_default_country_code
|
209
|
+
# PhoneNumber.default_country_code = '385'
|
210
|
+
#
|
211
|
+
# assert_equal PhoneNumber.parse('+38547451588').has_default_country_code?, true
|
212
|
+
# assert_equal PhoneNumber.parse('+38647451588').has_default_country_code?, false
|
213
|
+
# end
|
214
|
+
#
|
215
|
+
# def test_has_default_area_code
|
216
|
+
# PhoneNumber.default_country_code = '385'
|
217
|
+
# PhoneNumber.default_area_code = '47'
|
218
|
+
#
|
219
|
+
# assert_equal PhoneNumber.parse('047/451-588').has_default_area_code?, true
|
220
|
+
# assert_equal PhoneNumber.parse('032/336-1456').has_default_area_code?, false
|
221
|
+
# end
|