phony 2.15.25 → 2.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.textile +35 -7
- data/lib/phony/config.rb +91 -0
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +32 -24
- data/lib/phony/countries/bangladesh.rb +2 -0
- data/lib/phony/countries/belarus.rb +2 -0
- data/lib/phony/countries/brazil.rb +6 -4
- data/lib/phony/countries/cambodia.rb +6 -4
- data/lib/phony/countries/china.rb +7 -2
- data/lib/phony/countries/croatia.rb +13 -16
- data/lib/phony/countries/georgia.rb +6 -4
- data/lib/phony/countries/germany.rb +5 -2
- data/lib/phony/countries/guinea.rb +8 -5
- data/lib/phony/countries/india.rb +2 -0
- data/lib/phony/countries/indonesia.rb +7 -2
- data/lib/phony/countries/ireland.rb +27 -23
- data/lib/phony/countries/italy.rb +30 -17
- data/lib/phony/countries/japan.rb +61 -8
- data/lib/phony/countries/kyrgyzstan.rb +2 -0
- data/lib/phony/countries/latvia.rb +2 -0
- data/lib/phony/countries/libya.rb +3 -1
- data/lib/phony/countries/malaysia.rb +22 -2
- data/lib/phony/countries/moldova.rb +2 -0
- data/lib/phony/countries/montenegro.rb +2 -0
- data/lib/phony/countries/myanmar.rb +2 -0
- data/lib/phony/countries/namibia.rb +2 -0
- data/lib/phony/countries/nepal.rb +2 -0
- data/lib/phony/countries/netherlands.rb +2 -0
- data/lib/phony/countries/pakistan.rb +2 -0
- data/lib/phony/countries/paraguay.rb +2 -0
- data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +24 -14
- data/lib/phony/countries/saudi_arabia.rb +3 -0
- data/lib/phony/countries/serbia.rb +7 -1
- data/lib/phony/countries/somalia.rb +5 -1
- data/lib/phony/countries/south_korea.rb +16 -9
- data/lib/phony/countries/sweden.rb +29 -17
- data/lib/phony/countries/taiwan.rb +22 -46
- data/lib/phony/countries/tajikistan.rb +2 -0
- data/lib/phony/countries/turkmenistan.rb +2 -0
- data/lib/phony/countries/ukraine.rb +3 -0
- data/lib/phony/countries/united_kingdom.rb +5 -2
- data/lib/phony/countries/uruguay.rb +2 -0
- data/lib/phony/countries/vietnam.rb +94 -92
- data/lib/phony/countries/zimbabwe.rb +2 -0
- data/lib/phony/countries.rb +181 -78
- data/lib/phony/country.rb +15 -3
- data/lib/phony/country_codes.rb +17 -4
- data/lib/phony/dsl.rb +5 -3
- data/lib/phony/local_splitters/fixed.rb +2 -0
- data/lib/phony/national_code.rb +1 -1
- data/lib/phony/national_splitters/none.rb +1 -3
- data/lib/phony/trunk_code.rb +5 -4
- data/lib/phony/vanity.rb +1 -1
- data/lib/phony.rb +94 -60
- data/spec/functional/config_spec.rb +44 -0
- data/spec/functional/plausibility_spec.rb +364 -32
- data/spec/lib/phony/countries_spec.rb +245 -52
- data/spec/lib/phony/country_codes_spec.rb +106 -33
- data/spec/lib/phony/country_spec.rb +54 -15
- data/spec/lib/phony/dsl_spec.rb +2 -2
- data/spec/lib/phony/local_splitters/regex_spec.rb +12 -5
- data/spec/lib/phony/national_splitters/default_spec.rb +1 -1
- data/spec/lib/phony/trunk_code_spec.rb +85 -0
- data/spec/lib/phony/vanity_spec.rb +30 -0
- data/spec/lib/phony_spec.rb +70 -0
- metadata +26 -18
@@ -25,11 +25,11 @@ describe 'plausibility' do
|
|
25
25
|
incorrect = [shortest.sub(/\d\s*\z/, '')] # , longest + '0']
|
26
26
|
|
27
27
|
correct.each do |value|
|
28
|
-
Phony.plausible?(value).should
|
28
|
+
Phony.plausible?(value).should be_truthy,
|
29
29
|
"It should validate #{value}, but does not."
|
30
30
|
end
|
31
31
|
incorrect.each do |value|
|
32
|
-
Phony.plausible?(value).should
|
32
|
+
Phony.plausible?(value).should be_falsey,
|
33
33
|
"It should not validate #{value}, but does."
|
34
34
|
end
|
35
35
|
end
|
@@ -38,7 +38,7 @@ describe 'plausibility' do
|
|
38
38
|
invalid = [*sample]
|
39
39
|
|
40
40
|
invalid.each do |value|
|
41
|
-
Phony.plausible?(value).should
|
41
|
+
Phony.plausible?(value).should be_falsey,
|
42
42
|
"It should not validate #{value}, but does."
|
43
43
|
end
|
44
44
|
end
|
@@ -46,15 +46,191 @@ describe 'plausibility' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'specific countries' do
|
49
|
+
it_is_correct_for 'Austria', :samples => ['+43 720 116987', # VoIP
|
50
|
+
'+43 463 12345'] # Klagenfurt
|
51
|
+
it_is_correct_for 'Bosnia and Herzegovina', :samples => ['+387 66 666 666',
|
52
|
+
'+387 37 123 456',
|
53
|
+
'+387 33 222 111']
|
54
|
+
it 'is correct for Bulgaria' do
|
55
|
+
Phony.plausible?('+359 2 1234567').should be_truthy
|
56
|
+
Phony.plausible?('+359 30 12345').should be_truthy
|
57
|
+
Phony.plausible?('+359 30 123456').should be_truthy
|
58
|
+
Phony.plausible?('+359 31 12345').should be_truthy
|
59
|
+
Phony.plausible?('+359 31 123456').should be_truthy
|
60
|
+
Phony.plausible?('+359 32 123456').should be_truthy
|
61
|
+
Phony.plausible?('+359 33 12345').should be_truthy
|
62
|
+
Phony.plausible?('+359 33 123456').should be_truthy
|
63
|
+
Phony.plausible?('+359 34 123456').should be_truthy
|
64
|
+
Phony.plausible?('+359 35 123456').should be_truthy
|
65
|
+
Phony.plausible?('+359 36 12345').should be_truthy
|
66
|
+
Phony.plausible?('+359 36 123456').should be_truthy
|
67
|
+
Phony.plausible?('+359 37 12345').should be_truthy
|
68
|
+
Phony.plausible?('+359 37 123456').should be_truthy
|
69
|
+
Phony.plausible?('+359 38 123456').should be_truthy
|
70
|
+
Phony.plausible?('+359 39 12345').should be_truthy
|
71
|
+
Phony.plausible?('+359 39 123456').should be_truthy
|
72
|
+
Phony.plausible?('+359 41 12345').should be_truthy
|
73
|
+
Phony.plausible?('+359 41 123456').should be_truthy
|
74
|
+
Phony.plausible?('+359 42 123456').should be_truthy
|
75
|
+
Phony.plausible?('+359 430 12345').should be_truthy
|
76
|
+
Phony.plausible?('+359 431 12345').should be_truthy
|
77
|
+
Phony.plausible?('+359 432 12345').should be_truthy
|
78
|
+
Phony.plausible?('+359 433 12345').should be_truthy
|
79
|
+
Phony.plausible?('+359 434 12345').should be_truthy
|
80
|
+
Phony.plausible?('+359 435 12345').should be_truthy
|
81
|
+
Phony.plausible?('+359 436 12345').should be_truthy
|
82
|
+
Phony.plausible?('+359 437 12345').should be_truthy
|
83
|
+
Phony.plausible?('+359 438 12345').should be_truthy
|
84
|
+
Phony.plausible?('+359 439 12345').should be_truthy
|
85
|
+
Phony.plausible?('+359 44 123456').should be_truthy
|
86
|
+
Phony.plausible?('+359 45 12345').should be_truthy
|
87
|
+
Phony.plausible?('+359 45 123456').should be_truthy
|
88
|
+
Phony.plausible?('+359 46 123456').should be_truthy
|
89
|
+
Phony.plausible?('+359 47 12345').should be_truthy
|
90
|
+
Phony.plausible?('+359 47 123456').should be_truthy
|
91
|
+
Phony.plausible?('+359 47 12345').should be_truthy
|
92
|
+
Phony.plausible?('+359 47 123456').should be_truthy
|
93
|
+
Phony.plausible?('+359 51 12345').should be_truthy
|
94
|
+
Phony.plausible?('+359 51 123456').should be_truthy
|
95
|
+
Phony.plausible?('+359 52 123456').should be_truthy
|
96
|
+
Phony.plausible?('+359 53 12345').should be_truthy
|
97
|
+
Phony.plausible?('+359 53 123456').should be_truthy
|
98
|
+
Phony.plausible?('+359 54 123456').should be_truthy
|
99
|
+
Phony.plausible?('+359 55 12345').should be_truthy
|
100
|
+
Phony.plausible?('+359 55 123456').should be_truthy
|
101
|
+
Phony.plausible?('+359 56 123456').should be_truthy
|
102
|
+
Phony.plausible?('+359 57 12345').should be_truthy
|
103
|
+
Phony.plausible?('+359 57 123456').should be_truthy
|
104
|
+
Phony.plausible?('+359 58 123456').should be_truthy
|
105
|
+
Phony.plausible?('+359 59 12345').should be_truthy
|
106
|
+
Phony.plausible?('+359 59 123456').should be_truthy
|
107
|
+
Phony.plausible?('+359 60 12345').should be_truthy
|
108
|
+
Phony.plausible?('+359 60 123456').should be_truthy
|
109
|
+
Phony.plausible?('+359 61 12345').should be_truthy
|
110
|
+
Phony.plausible?('+359 61 123456').should be_truthy
|
111
|
+
Phony.plausible?('+359 62 123456').should be_truthy
|
112
|
+
Phony.plausible?('+359 63 12345').should be_truthy
|
113
|
+
Phony.plausible?('+359 63 123456').should be_truthy
|
114
|
+
Phony.plausible?('+359 64 123456').should be_truthy
|
115
|
+
Phony.plausible?('+359 65 12345').should be_truthy
|
116
|
+
Phony.plausible?('+359 65 123456').should be_truthy
|
117
|
+
Phony.plausible?('+359 66 12345').should be_truthy
|
118
|
+
Phony.plausible?('+359 66 123456').should be_truthy
|
119
|
+
Phony.plausible?('+359 68 123456').should be_truthy
|
120
|
+
Phony.plausible?('+359 69 12345').should be_truthy
|
121
|
+
Phony.plausible?('+359 69 123456').should be_truthy
|
122
|
+
Phony.plausible?('+359 700 12345').should be_truthy
|
123
|
+
Phony.plausible?('+359 701 1234').should be_truthy
|
124
|
+
Phony.plausible?('+359 701 12345').should be_truthy
|
125
|
+
Phony.plausible?('+359 71 12345').should be_truthy
|
126
|
+
Phony.plausible?('+359 71 123456').should be_truthy
|
127
|
+
Phony.plausible?('+359 72 12345').should be_truthy
|
128
|
+
Phony.plausible?('+359 72 123456').should be_truthy
|
129
|
+
Phony.plausible?('+359 73 123456').should be_truthy
|
130
|
+
Phony.plausible?('+359 74 12345').should be_truthy
|
131
|
+
Phony.plausible?('+359 74 123456').should be_truthy
|
132
|
+
Phony.plausible?('+359 75 12345').should be_truthy
|
133
|
+
Phony.plausible?('+359 75 123456').should be_truthy
|
134
|
+
Phony.plausible?('+359 76 123456').should be_truthy
|
135
|
+
Phony.plausible?('+359 77 12345').should be_truthy
|
136
|
+
Phony.plausible?('+359 77 123456').should be_truthy
|
137
|
+
Phony.plausible?('+359 78 123456').should be_truthy
|
138
|
+
Phony.plausible?('+359 79 123456').should be_truthy
|
139
|
+
Phony.plausible?('+359 800 12345').should be_truthy
|
140
|
+
Phony.plausible?('+359 81 12345').should be_truthy
|
141
|
+
Phony.plausible?('+359 81 123456').should be_truthy
|
142
|
+
Phony.plausible?('+359 82 123456').should be_truthy
|
143
|
+
Phony.plausible?('+359 82 123456').should be_truthy
|
144
|
+
Phony.plausible?('+359 84 123456').should be_truthy
|
145
|
+
Phony.plausible?('+359 86 123456').should be_truthy
|
146
|
+
Phony.plausible?('+359 87 1234567').should be_truthy
|
147
|
+
Phony.plausible?('+359 88 1234567').should be_truthy
|
148
|
+
Phony.plausible?('+359 89 1234567').should be_truthy
|
149
|
+
Phony.plausible?('+359 90 123456').should be_truthy
|
150
|
+
Phony.plausible?('+359 91 12345').should be_truthy
|
151
|
+
Phony.plausible?('+359 91 123456').should be_truthy
|
152
|
+
Phony.plausible?('+359 92 123456').should be_truthy
|
153
|
+
Phony.plausible?('+359 93 12345').should be_truthy
|
154
|
+
Phony.plausible?('+359 93 123456').should be_truthy
|
155
|
+
Phony.plausible?('+359 94 123456').should be_truthy
|
156
|
+
Phony.plausible?('+359 95 12345').should be_truthy
|
157
|
+
Phony.plausible?('+359 95 123456').should be_truthy
|
158
|
+
Phony.plausible?('+359 96 123456').should be_truthy
|
159
|
+
Phony.plausible?('+359 97 12345').should be_truthy
|
160
|
+
Phony.plausible?('+359 97 123456').should be_truthy
|
161
|
+
Phony.plausible?('+359 980 123456').should be_truthy
|
162
|
+
Phony.plausible?('+359 981 123456').should be_truthy
|
163
|
+
Phony.plausible?('+359 982 123456').should be_truthy
|
164
|
+
Phony.plausible?('+359 983 123456').should be_truthy
|
165
|
+
Phony.plausible?('+359 984 123456').should be_truthy
|
166
|
+
Phony.plausible?('+359 985 123456').should be_truthy
|
167
|
+
Phony.plausible?('+359 986 123456').should be_truthy
|
168
|
+
Phony.plausible?('+359 987 123456').should be_truthy
|
169
|
+
Phony.plausible?('+359 988 123456').should be_truthy
|
170
|
+
Phony.plausible?('+359 989 123456').should be_truthy
|
171
|
+
Phony.plausible?('+359 990 123456').should be_truthy
|
172
|
+
Phony.plausible?('+359 991 123456').should be_truthy
|
173
|
+
Phony.plausible?('+359 992 123456').should be_truthy
|
174
|
+
Phony.plausible?('+359 993 123456').should be_truthy
|
175
|
+
Phony.plausible?('+359 994 123456').should be_truthy
|
176
|
+
Phony.plausible?('+359 995 123456').should be_truthy
|
177
|
+
Phony.plausible?('+359 996 123456').should be_truthy
|
178
|
+
Phony.plausible?('+359 997 123456').should be_truthy
|
179
|
+
Phony.plausible?('+359 998 123456').should be_truthy
|
180
|
+
Phony.plausible?('+359 999 123456').should be_truthy
|
181
|
+
end
|
182
|
+
it_is_correct_for 'Colombia', :samples => ['+57 601 411 1899',
|
183
|
+
'+57 602 111 2222',
|
184
|
+
'+57 603 111 2222',
|
185
|
+
'+57 604 111 2222',
|
186
|
+
'+57 605 111 2222',
|
187
|
+
'+57 606 111 2222',
|
188
|
+
'+57 607 111 2222',
|
189
|
+
'+57 608 111 2222']
|
49
190
|
it_is_correct_for 'Congo', :samples => '+242 1234 56789'
|
50
191
|
it_is_correct_for 'Cook Islands', :samples => '+682 71928'
|
51
192
|
it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
|
52
|
-
|
193
|
+
it 'is correct for Croatia' do
|
194
|
+
Phony.plausible?('+385 21 695 900').should be_truthy # Landline
|
195
|
+
Phony.plausible?('+385 1 4566 666').should be_truthy # Landline (Zagreb)
|
196
|
+
Phony.plausible?('+385 99 444 999').should be_truthy # Mobile
|
197
|
+
Phony.plausible?('+385 91 896 7509').should be_truthy # Mobile
|
198
|
+
Phony.plausible?('+385 800 1234').should be_truthy # Toll free
|
199
|
+
Phony.plausible?('+385 800 123 456').should be_truthy # Toll free
|
200
|
+
Phony.plausible?('+385 60 12 345').should be_truthy # Premium rate
|
201
|
+
Phony.plausible?('+385 62 123 456').should be_truthy # Premium, personal and UAN
|
202
|
+
end
|
203
|
+
it_is_correct_for "Côte d'Ivoire", :samples => '+225 01 9358 8764'
|
53
204
|
it_is_correct_for 'Democratic Republic of Timor-Leste', :samples => ['+670 465 7886', '+670 7465 7886']
|
54
205
|
it_is_correct_for 'Democratic Republic of the Congo', :samples => '+243 80 864 9794'
|
55
206
|
it_is_correct_for 'Diego Garcia', :samples => '+246 123 7686'
|
56
207
|
it_is_correct_for 'Djibouti', :samples => '+253 3671 1431'
|
57
|
-
|
208
|
+
it 'is correct for Ecuador' do
|
209
|
+
Phony.plausible?('+593 22 000 0000').should be_truthy
|
210
|
+
Phony.plausible?('+593 23 000 0000').should be_truthy
|
211
|
+
Phony.plausible?('+593 26 000 0000').should be_truthy
|
212
|
+
Phony.plausible?('+593 27 000 0000').should be_truthy
|
213
|
+
Phony.plausible?('+593 44 000 0000').should be_truthy
|
214
|
+
Phony.plausible?('+593 45 000 0000').should be_truthy
|
215
|
+
Phony.plausible?('+593 47 000 0000').should be_truthy
|
216
|
+
Phony.plausible?('+593 2 200 0000').should be_truthy
|
217
|
+
Phony.plausible?('+593 2 300 0000').should be_truthy
|
218
|
+
Phony.plausible?('+593 2 400 0000').should be_truthy
|
219
|
+
Phony.plausible?('+593 2 500 0000').should be_truthy
|
220
|
+
Phony.plausible?('+593 2 700 0000').should be_truthy
|
221
|
+
Phony.plausible?('+593 3 000 0000').should be_truthy
|
222
|
+
Phony.plausible?('+593 4 000 0000').should be_truthy
|
223
|
+
Phony.plausible?('+593 4 500 0000').should be_truthy
|
224
|
+
Phony.plausible?('+593 4 600 0000').should be_truthy
|
225
|
+
Phony.plausible?('+593 5 200 0000').should be_truthy
|
226
|
+
Phony.plausible?('+593 5 300 0000').should be_truthy
|
227
|
+
Phony.plausible?('+593 6 200 0000').should be_truthy
|
228
|
+
Phony.plausible?('+593 7 200 0000').should be_truthy
|
229
|
+
Phony.plausible?('+593 7 300 0000').should be_truthy
|
230
|
+
Phony.plausible?('+593 7 400 0000').should be_truthy
|
231
|
+
Phony.plausible?('+593 7 600 0000').should be_truthy
|
232
|
+
Phony.plausible?('+593 9 0000 0000').should be_truthy # mobile
|
233
|
+
end
|
58
234
|
it_is_correct_for 'Equatorial Guinea', :samples => ['+240 222 201 123',
|
59
235
|
'+240 335 201 123']
|
60
236
|
it_is_correct_for 'Eritrea', :samples => '+291 6 334 475'
|
@@ -63,20 +239,36 @@ describe 'plausibility' do
|
|
63
239
|
it_is_correct_for 'Faroe Islands', :samples => '+298 969 597'
|
64
240
|
it_is_correct_for 'Fiji (Republic of)', :samples => '+679 998 2441'
|
65
241
|
it 'is correct for Finland' do
|
66
|
-
Phony.plausible?('+358 50 123
|
67
|
-
Phony.plausible?('+358 50 123 45
|
68
|
-
Phony.plausible?('+358 50 123 45
|
69
|
-
Phony.plausible?('+358
|
70
|
-
Phony.plausible?('+358
|
71
|
-
Phony.plausible?('+358
|
72
|
-
Phony.plausible?('+358
|
242
|
+
Phony.plausible?('+358 50 123 4').should be_truthy
|
243
|
+
Phony.plausible?('+358 50 123 45').should be_truthy
|
244
|
+
Phony.plausible?('+358 50 123 45 6').should be_truthy
|
245
|
+
Phony.plausible?('+358 50 123 45 67').should be_truthy
|
246
|
+
Phony.plausible?('+358 50 123 45 678').should be_truthy
|
247
|
+
Phony.plausible?('+358 49 123 456 789').should be_truthy
|
248
|
+
Phony.plausible?('+358 18 1234').should be_truthy
|
249
|
+
Phony.plausible?('+358 9 1234').should be_truthy
|
250
|
+
Phony.plausible?('+358 9 123 45').should be_truthy
|
251
|
+
Phony.plausible?('+358 9 123 456').should be_truthy
|
252
|
+
Phony.plausible?('+358 9 123 4567').should be_truthy
|
253
|
+
Phony.plausible?('+358 20 1470 740').should be_truthy
|
254
|
+
Phony.plausible?('+358 29 123 4567').should be_truthy
|
255
|
+
Phony.plausible?('+358 75323 1234').should be_truthy
|
256
|
+
Phony.plausible?('+358 50 123 456 789').should be_falsey
|
73
257
|
end
|
74
258
|
it_is_correct_for 'French Guiana (French Department of)', :samples => '+594 594 123 456'
|
75
259
|
it_is_correct_for "French Polynesia (Territoire français d'outre-mer)", :samples => '+689 87 27 84 00'
|
76
|
-
|
260
|
+
it 'is correct for Gabon' do
|
261
|
+
Phony.plausible?('+241 1 627 739').should be_truthy
|
262
|
+
Phony.plausible?('+241 12 34 56 78').should be_truthy
|
263
|
+
end
|
264
|
+
# it_is_correct_for 'Gabonese Republic', :samples => [
|
265
|
+
# '+241 1 627 739',
|
266
|
+
# '+241 12 34 56 78',
|
267
|
+
# ]
|
77
268
|
it_is_correct_for 'Gambia', :samples => '+220 989 5148'
|
78
269
|
it_is_correct_for 'Germany', :samples => [
|
79
|
-
'+49
|
270
|
+
'+49 69 155 1',
|
271
|
+
'+49 1577 536 8701'
|
80
272
|
]
|
81
273
|
it_is_correct_for 'Georgia', :samples => ['+995 220 123 45',
|
82
274
|
'+995 32 123 4567',
|
@@ -130,16 +322,29 @@ describe 'plausibility' do
|
|
130
322
|
'+961 81 123 456']
|
131
323
|
it_is_correct_for 'Lesotho', :samples => '+266 7612 6866'
|
132
324
|
it 'is correct for Liberia' do
|
133
|
-
Phony.plausible?('+231 2 123 4567').should
|
134
|
-
Phony.plausible?('+231 4 123 456').should
|
135
|
-
Phony.plausible?('+231 77 123 4567').should
|
325
|
+
Phony.plausible?('+231 2 123 4567').should be_truthy
|
326
|
+
Phony.plausible?('+231 4 123 456').should be_truthy
|
327
|
+
Phony.plausible?('+231 77 123 4567').should be_truthy
|
136
328
|
end
|
329
|
+
it_is_correct_for 'Macao', :samples => ['+853 28 12 3456',
|
330
|
+
'+853 8 123 4567',
|
331
|
+
'+853 6 123 4567',]
|
137
332
|
it_is_correct_for 'Macedonia', :samples => ['+389 2 123 4567',
|
138
333
|
'+389 7 124 3456',
|
139
334
|
'+389 7 234 5678']
|
140
|
-
it_is_correct_for 'Madagascar', :samples => ['+261 20
|
141
|
-
'+261
|
142
|
-
'+261
|
335
|
+
it_is_correct_for 'Madagascar', :samples => ['+261 20 23 456 78',
|
336
|
+
'+261 32 34 546 78',
|
337
|
+
'+261 33 34 546 78',
|
338
|
+
'+261 34 34 546 78',
|
339
|
+
'+261 38 34 546 78']
|
340
|
+
it 'is incorrect for Madagascar' do
|
341
|
+
Phony.plausible?('+261 20 012 345 678').should be_falsey
|
342
|
+
Phony.plausible?('+261 20 12 434 569').should be_falsey
|
343
|
+
Phony.plausible?('+261 51 23 4567 8').should be_falsey
|
344
|
+
Phony.plausible?('+261 34 345 46789').should be_falsey
|
345
|
+
Phony.plausible?('+261 34 345 467').should be_falsey
|
346
|
+
end
|
347
|
+
|
143
348
|
it_is_correct_for 'Malawi', :samples => ['+265 1725 123',
|
144
349
|
'+265 213 456 789',
|
145
350
|
'+265 9123 456',
|
@@ -168,16 +373,55 @@ describe 'plausibility' do
|
|
168
373
|
'+977 10 123 456',
|
169
374
|
'+977 98 1234 5678']
|
170
375
|
it_is_correct_for "New Caledonia (Territoire français d'outre-mer)", :samples => '+687 546 835'
|
376
|
+
it 'is correct for New Zealand' do
|
377
|
+
Phony.plausible?('+64800123123').should be_truthy # Free phone
|
378
|
+
Phony.plausible?('+648001231234').should be_truthy # Free phone
|
379
|
+
end
|
171
380
|
it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
|
172
381
|
it_is_correct_for 'Niger', :samples => '+227 1234 5678'
|
382
|
+
it_is_correct_for 'Nigeria', :samples => ['+234 807 059 1111',
|
383
|
+
'+234 811 234 5678',
|
384
|
+
'+234 64 830 00',
|
385
|
+
'+234 1 280 444',
|
386
|
+
'+234 85 123 456']
|
173
387
|
it_is_correct_for 'Niue', :samples => '+683 3791'
|
174
388
|
it_is_correct_for 'Oman', :samples => ['+968 24 423 123',
|
175
389
|
'+968 25 423 123']
|
176
390
|
it_is_correct_for 'Palau (Republic of)', :samples => '+680 483 7871'
|
391
|
+
|
392
|
+
it_is_correct_for 'Papua New Guinea', :samples => ['+675 180 1234',
|
393
|
+
'+675 170 12',
|
394
|
+
'+675 189 1',
|
395
|
+
'+675 184 1234 5678',
|
396
|
+
'+675 185 1234',
|
397
|
+
'+675 275 1234',
|
398
|
+
'+675 278 12',
|
399
|
+
'+675 115 1234 5678',
|
400
|
+
'+675 28 123 45',
|
401
|
+
'+675 16 123 12',
|
402
|
+
'+675 711 23 456',
|
403
|
+
'+675 731 23 456',
|
404
|
+
'+675 741 23 456',
|
405
|
+
'+675 770 12 345',
|
406
|
+
'+675 771 12 345',
|
407
|
+
'+675 772 12 345',
|
408
|
+
'+675 773 01 234',
|
409
|
+
'+675 774 12 345',
|
410
|
+
'+675 775 12 345',
|
411
|
+
'+675 80 123 456',
|
412
|
+
'+675 90 123 456',
|
413
|
+
'+675 3 123 456']
|
414
|
+
|
177
415
|
it_is_correct_for 'Panama (Republic of)', :samples => ['+507 800 1234',
|
178
416
|
'+507 6 123 4567',
|
179
417
|
'+507 2 123 456']
|
180
418
|
it_is_correct_for 'Reunion / Mayotte (new)', :samples => '+262 295 276 964'
|
419
|
+
it_is_correct_for 'Rwanda', :samples => ['+250 72 1234567',
|
420
|
+
'+250 73 1234567',
|
421
|
+
'+250 78 1234567',
|
422
|
+
'+250 79 1234567',
|
423
|
+
'+250 25 1234567',
|
424
|
+
'+250 06 123456']
|
181
425
|
it_is_correct_for 'Saint Helena', :samples => '+290 5134'
|
182
426
|
it_is_correct_for 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)', :samples => '+508 474 714'
|
183
427
|
it_is_correct_for 'Salvador (El)', :samples => [
|
@@ -206,8 +450,10 @@ describe 'plausibility' do
|
|
206
450
|
['+381 11 123 456', '+381 11 123 4567'],
|
207
451
|
'+381 72 123 456',
|
208
452
|
'+381 60 123',
|
209
|
-
'+381 60 123 4567',
|
453
|
+
['+381 60 123 4567', '+381 69 123 456'],
|
210
454
|
'+381 42 123 456',
|
455
|
+
'+381 677 123 456',
|
456
|
+
'+381 678 123 456',
|
211
457
|
'+381 9 123 4567',
|
212
458
|
'+381 60 123',
|
213
459
|
'+381 60 123 456 7890',
|
@@ -218,30 +464,39 @@ describe 'plausibility' do
|
|
218
464
|
['+381 62 12 34567', '+381 62 12 3456'],
|
219
465
|
['+381 65 12 34567', '+381 65 12 3456']]
|
220
466
|
it_is_correct_for 'Sierra Leone', :samples => '+232 42 393 972'
|
467
|
+
it_is_correct_for 'Singapore', :samples => ['+65 6123 1234',
|
468
|
+
'+65 800 852 1234']
|
221
469
|
it_is_correct_for 'Solomon Islands', :samples => '+677 97851'
|
222
470
|
it_is_correct_for 'Somali Democratic Republic', :samples => ['+252 1034 123 45',
|
223
471
|
'+252 1313 123',
|
224
472
|
'+252 160 12 34',
|
225
473
|
'+252 500 123 45',
|
226
474
|
'+252 67 1234 567']
|
475
|
+
|
476
|
+
it 'is correct for South Korea' do
|
477
|
+
Phony.plausible?('+82 2 1234 5678').should be_truthy
|
478
|
+
Phony.plausible?('+82 2 711 2222').should be_truthy
|
479
|
+
Phony.plausible?('+82 51 1234 5678').should be_truthy
|
480
|
+
Phony.plausible?('+82 51 123 5678').should be_truthy
|
481
|
+
Phony.plausible?('+82 10 2797 5588').should be_truthy
|
482
|
+
Phony.plausible?('+82 10 8797 1234').should be_truthy
|
483
|
+
end
|
484
|
+
|
227
485
|
it_is_correct_for 'South Sudan', :samples => ['+211 123 212 345',
|
228
486
|
'+211 973 212 345']
|
229
487
|
it_is_correct_for 'Suriname (Republic of)', :samples => ['+597 212 345', '+597 612 3456']
|
230
488
|
it_is_correct_for 'Swaziland', :samples => ['+268 2207 1234', '+268 550 1234']
|
231
|
-
it_is_correct_for 'Sweden', :samples => ['+46 42 123 45', ['+46 417 123 45', '+46 522 636 365']]
|
489
|
+
it_is_correct_for 'Sweden', :samples => ['+46 42 123 45', ['+46 417 123 45', '+46 522 636 365', '+46 513 12 34 56']]
|
232
490
|
it_is_correct_for 'Syrian Arab Republic', :samples => ['+963 11 123 4567',
|
233
491
|
'+963 31 123 4567',
|
234
492
|
'+963 15 731 234',
|
235
493
|
'+963 9 1234 5678']
|
236
|
-
it_is_correct_for 'Taiwan', :samples => ['+886
|
237
|
-
'+886 612 123 4567',
|
238
|
-
'+886 2 1234 5678',
|
494
|
+
it_is_correct_for 'Taiwan', :samples => ['+886 6 123 4567',
|
239
495
|
'+886 3 123 4567',
|
240
496
|
'+886 33 123 456',
|
241
497
|
'+886 827 123 45',
|
242
|
-
'+886
|
243
|
-
|
244
|
-
'+886 94 991 345']
|
498
|
+
'+886 4 123 1234',
|
499
|
+
'+886 9 1234 5678']
|
245
500
|
it_is_correct_for 'Tajikistan', :samples => ['+992 3130 123 45',
|
246
501
|
'+992 331700 123',
|
247
502
|
'+992 372 123 345',
|
@@ -269,7 +524,10 @@ describe 'plausibility' do
|
|
269
524
|
it_is_correct_for 'Lybia', :samples => ['+218 205 123 45',
|
270
525
|
'+218 22 123 456',
|
271
526
|
'+218 21 1234 456',
|
272
|
-
'+218 91 1234 456'
|
527
|
+
'+218 91 1234 456',
|
528
|
+
'+218 92 1234 456',
|
529
|
+
'+218 94 1234 456',
|
530
|
+
'+218 95 1234 456']
|
273
531
|
it_is_correct_for 'Mongolia', :samples => ['+976 11 123 45',
|
274
532
|
['+976 121 12 34', '+976 121 12 345'],
|
275
533
|
'+976 70 123 456',
|
@@ -303,11 +561,14 @@ describe 'plausibility' do
|
|
303
561
|
]
|
304
562
|
it_is_correct_for 'United Arab Emirates', :samples => ['+971 800 12',
|
305
563
|
'+971 800 12 345 6789',
|
564
|
+
'+971 800 12 345 67',
|
306
565
|
'+971 2 123 4567',
|
307
566
|
'+971 50 641 2345',
|
308
567
|
'+971 600 641 234',
|
309
568
|
'+971 500 641 234',
|
310
|
-
'+971 200 641 234'
|
569
|
+
'+971 200 641 234',
|
570
|
+
'+971 54 999 9999',
|
571
|
+
'+971 58 999 9999']
|
311
572
|
|
312
573
|
it_is_correct_for 'United Kingdom', :samples => ['+44 1827 50111'], :invalid_samples => ['+44 0000 123456']
|
313
574
|
|
@@ -318,19 +579,90 @@ describe 'plausibility' do
|
|
318
579
|
'+598 93 123 456',
|
319
580
|
'+598 908 123 45',
|
320
581
|
'+598 805 123 45']
|
582
|
+
it_is_correct_for 'Vietnam', :samples => ['+84 24 41234567',
|
583
|
+
'+84 28 41234567',
|
584
|
+
'+84 23 61234567']
|
321
585
|
it_is_correct_for 'Yemen', :samples => [['+967 1 234 567', '+967 1 234 5678'],
|
322
586
|
'+967 7 234 567',
|
323
587
|
'+967 77 123 4567',
|
324
588
|
'+967 58 1234']
|
325
589
|
it 'is correct for Zambia' do
|
326
|
-
Phony.plausible?('+260
|
327
|
-
Phony.plausible?('+260
|
590
|
+
Phony.plausible?('+260 211 123456').should be_truthy # Fixed
|
591
|
+
Phony.plausible?('+260 96 512 4567').should be_truthy # MTN Mobile
|
592
|
+
Phony.plausible?('+260 97 712 3456').should be_truthy # Airtel Mobile
|
593
|
+
Phony.plausible?('+260 95 512 4567').should be_truthy # Zamtel Mobile
|
594
|
+
Phony.plausible?('+260 96 512 456').should be_falsy # MTN Mobile (Too short)
|
595
|
+
Phony.plausible?('+260 97 812 345').should be_falsy # Airtel Mobile (Too short)
|
596
|
+
Phony.plausible?('+260 95 512 345').should be_falsy # Zamtel Mobile (Too short)
|
597
|
+
Phony.plausible?('+260 800 123 456').should be_truthy # Toll free
|
328
598
|
end
|
329
599
|
it_is_correct_for 'Zimbabwe', :samples => [['+263 2582 123 456', '+263 2582 123'],
|
330
600
|
['+263 147 123 456', '+263 147 123'],
|
331
601
|
['+263 270 123 456', '+263 270 123 45'],
|
332
602
|
'+263 86 1235 4567']
|
333
603
|
|
604
|
+
it 'is correct for Indonesia' do
|
605
|
+
Phony.plausible?('+62 22 000 0').should be_falsey
|
606
|
+
Phony.plausible?('+62 22 000 00').should be_truthy
|
607
|
+
Phony.plausible?('+62 22 000 0000').should be_truthy
|
608
|
+
Phony.plausible?('+62 22 0000 0000').should be_truthy
|
609
|
+
Phony.plausible?('+62 22 000 000 000').should be_truthy
|
610
|
+
end
|
611
|
+
|
612
|
+
it 'is correct for Italy' do
|
613
|
+
Phony.plausible?('+39 0574 123').should be_falsy
|
614
|
+
Phony.plausible?('+39 0574 1234').should be_truthy
|
615
|
+
Phony.plausible?('+39 0574 12345').should be_falsy
|
616
|
+
|
617
|
+
Phony.plausible?('+39 085 541').should be_falsy
|
618
|
+
Phony.plausible?('+39 085 5410').should be_truthy
|
619
|
+
Phony.plausible?('+39 085 54105').should be_truthy
|
620
|
+
|
621
|
+
Phony.plausible?('+39 06 4991').should be_falsy
|
622
|
+
Phony.plausible?('+39 06 49911').should be_truthy
|
623
|
+
Phony.plausible?('+39 06 499112').should be_truthy
|
624
|
+
end
|
625
|
+
|
626
|
+
it 'is correct for Russia' do
|
627
|
+
Phony.plausible?('+7 3522 000 000').should be_truthy
|
628
|
+
end
|
629
|
+
|
630
|
+
it 'is correct for Peru' do
|
631
|
+
Phony.plausible?('+51 1 123 1234').should be_truthy # Lima
|
632
|
+
Phony.plausible?('+51 9 1234 1234').should be_truthy # mobile
|
633
|
+
Phony.plausible?('+51 84 123 123').should be_truthy # Cuzco, best effort
|
634
|
+
end
|
635
|
+
|
636
|
+
it 'is correct for Kosovo' do
|
637
|
+
Phony.plausible?('+383 29 000 000').should be_truthy # Landline
|
638
|
+
Phony.plausible?('+383 44 000 000').should be_truthy # Mobile
|
639
|
+
end
|
640
|
+
|
641
|
+
it 'is correct for Bulgaria' do
|
642
|
+
Phony.plausible?('+359 2 123 123').should be_truthy # Landline Sofia
|
643
|
+
Phony.plausible?('+359 2 123 1234').should be_truthy # Landline Sofia
|
644
|
+
Phony.plausible?('+359 30 123 12').should be_truthy # Landline
|
645
|
+
Phony.plausible?('+359 30 123 123').should be_truthy # Landline
|
646
|
+
Phony.plausible?('+359 89 123 1234').should be_truthy # Mobile
|
647
|
+
end
|
648
|
+
|
649
|
+
it 'is correct for Malaysia' do
|
650
|
+
Phony.plausible?('+60 5 123 1234').should be_truthy # Non Selangor Landline
|
651
|
+
Phony.plausible?('+60 3 1234 1234').should be_truthy # Selangor Landline
|
652
|
+
Phony.plausible?('+60 88 123 123').should be_truthy # Landline Sabah – Kota Kinabalu and Kudat
|
653
|
+
end
|
654
|
+
|
655
|
+
it 'is correct for Japan' do
|
656
|
+
Phony.plausible?('+81 90 1234 1234').should be_truthy
|
657
|
+
Phony.plausible?('+81 120 123 123').should be_truthy
|
658
|
+
Phony.plausible?('+81 800 123 1234').should be_truthy
|
659
|
+
end
|
660
|
+
|
661
|
+
it 'is correct for Philippine' do
|
662
|
+
Phony.plausible?('+63 2 89889999').should be_truthy
|
663
|
+
Phony.plausible?('+63 976 1234567').should be_truthy # mobile phone with area code 9
|
664
|
+
Phony.plausible?('+63 876 1234567').should be_truthy # mobile phone with area code 8
|
665
|
+
end
|
334
666
|
end
|
335
667
|
end
|
336
668
|
end
|