phony 1.9.0 → 2.19.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.textile +64 -112
- data/lib/phony/config.rb +91 -0
- data/lib/phony/countries/argentina.rb +355 -0
- data/lib/phony/countries/austria.rb +56 -22
- data/lib/phony/countries/bangladesh.rb +57 -0
- data/lib/phony/countries/belarus.rb +133 -0
- data/lib/phony/countries/brazil.rb +101 -95
- data/lib/phony/countries/cambodia.rb +131 -0
- data/lib/phony/countries/china.rb +13 -6
- data/lib/phony/countries/croatia.rb +23 -0
- data/lib/phony/countries/georgia.rb +94 -0
- data/lib/phony/countries/germany.rb +66 -42
- data/lib/phony/countries/guinea.rb +46 -0
- data/lib/phony/countries/india.rb +50 -0
- data/lib/phony/countries/indonesia.rb +55 -0
- data/lib/phony/countries/ireland.rb +35 -28
- data/lib/phony/countries/italy.rb +272 -166
- data/lib/phony/countries/japan.rb +468 -0
- data/lib/phony/countries/kyrgyzstan.rb +120 -0
- data/lib/phony/countries/latvia.rb +43 -0
- data/lib/phony/countries/libya.rb +116 -0
- data/lib/phony/countries/malaysia.rb +31 -7
- data/lib/phony/countries/moldova.rb +53 -0
- data/lib/phony/countries/montenegro.rb +30 -0
- data/lib/phony/countries/myanmar.rb +55 -0
- data/lib/phony/countries/namibia.rb +37 -0
- data/lib/phony/countries/nepal.rb +73 -0
- data/lib/phony/countries/netherlands.rb +17 -5
- data/lib/phony/countries/pakistan.rb +121 -0
- data/lib/phony/countries/paraguay.rb +147 -0
- data/lib/phony/countries/{russia_kazakhstan_abhasia_south_osetia.rb → russia_kazakhstan_abkhasia_south_ossetia.rb} +35 -24
- data/lib/phony/countries/saudi_arabia.rb +40 -0
- data/lib/phony/countries/serbia.rb +47 -0
- data/lib/phony/countries/somalia.rb +26 -0
- data/lib/phony/countries/south_korea.rb +19 -10
- data/lib/phony/countries/sweden.rb +58 -38
- data/lib/phony/countries/taiwan.rb +28 -0
- data/lib/phony/countries/tajikistan.rb +79 -0
- data/lib/phony/countries/turkmenistan.rb +76 -0
- data/lib/phony/countries/ukraine.rb +630 -0
- data/lib/phony/countries/united_kingdom.rb +639 -44
- data/lib/phony/countries/uruguay.rb +53 -0
- data/lib/phony/countries/vietnam.rb +133 -0
- data/lib/phony/countries/zimbabwe.rb +39 -0
- data/lib/phony/countries.rb +901 -301
- data/lib/phony/country.rb +177 -20
- data/lib/phony/country_codes.rb +119 -101
- data/lib/phony/dsl.rb +113 -68
- data/lib/phony/local_splitters/fixed.rb +25 -1
- data/lib/phony/local_splitters/regex.rb +16 -2
- data/lib/phony/national_code.rb +7 -7
- data/lib/phony/national_splitters/default.rb +35 -3
- data/lib/phony/national_splitters/dsl.rb +12 -7
- data/lib/phony/national_splitters/fixed.rb +7 -1
- data/lib/phony/national_splitters/none.rb +7 -3
- data/lib/phony/national_splitters/regex.rb +6 -0
- data/lib/phony/national_splitters/variable.rb +13 -9
- data/lib/phony/trunk_code.rb +57 -0
- data/lib/phony/vanity.rb +3 -3
- data/lib/phony.rb +239 -55
- data/spec/functional/config_spec.rb +44 -0
- data/spec/functional/plausibility_spec.rb +656 -0
- data/spec/lib/phony/countries_spec.rb +1207 -119
- data/spec/lib/phony/country_codes_spec.rb +99 -81
- data/spec/lib/phony/country_spec.rb +54 -14
- data/spec/lib/phony/dsl_spec.rb +2 -2
- data/spec/lib/phony/local_splitters/fixed_spec.rb +4 -4
- data/spec/lib/phony/local_splitters/regex_spec.rb +50 -2
- data/spec/lib/phony/national_code_spec.rb +34 -34
- data/spec/lib/phony/national_splitters/default_spec.rb +34 -0
- data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -6
- data/spec/lib/phony/national_splitters/none_spec.rb +13 -3
- data/spec/lib/phony/national_splitters/regex_spec.rb +1 -1
- data/spec/lib/phony/national_splitters/variable_spec.rb +11 -5
- data/spec/lib/phony/trunk_code_spec.rb +85 -0
- data/spec/lib/phony/vanity_spec.rb +15 -19
- data/spec/lib/phony_spec.rb +59 -277
- metadata +67 -34
- data/lib/phony/validator.rb +0 -26
- data/lib/phony/validators.rb +0 -88
- data/spec/lib/phony/validations_spec.rb +0 -109
@@ -0,0 +1,656 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'plausibility' do
|
6
|
+
|
7
|
+
describe 'plausible?' do
|
8
|
+
|
9
|
+
# Validations test helper.
|
10
|
+
# @param country_name [String]
|
11
|
+
# @param options [Hash]
|
12
|
+
# @option options [String, Array<String>] :samples
|
13
|
+
#
|
14
|
+
def self.it_is_correct_for(country_name, options={})
|
15
|
+
samples = [*options[:samples]]
|
16
|
+
invalid_samples = [*options[:invalid_samples]]
|
17
|
+
|
18
|
+
raise ArgumentError, ':samples option should be specified' if samples.empty?
|
19
|
+
|
20
|
+
it "is correct for #{country_name}" do
|
21
|
+
samples.each do |sample|
|
22
|
+
correct = [*sample]
|
23
|
+
|
24
|
+
shortest = correct.min_by{|x| x.scan(/\d/).length}
|
25
|
+
incorrect = [shortest.sub(/\d\s*\z/, '')] # , longest + '0']
|
26
|
+
|
27
|
+
correct.each do |value|
|
28
|
+
Phony.plausible?(value).should be_truthy,
|
29
|
+
"It should validate #{value}, but does not."
|
30
|
+
end
|
31
|
+
incorrect.each do |value|
|
32
|
+
Phony.plausible?(value).should be_falsey,
|
33
|
+
"It should not validate #{value}, but does."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
invalid_samples.each do |sample|
|
38
|
+
invalid = [*sample]
|
39
|
+
|
40
|
+
invalid.each do |value|
|
41
|
+
Phony.plausible?(value).should be_falsey,
|
42
|
+
"It should not validate #{value}, but does."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
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']
|
190
|
+
it_is_correct_for 'Congo', :samples => '+242 1234 56789'
|
191
|
+
it_is_correct_for 'Cook Islands', :samples => '+682 71928'
|
192
|
+
it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
|
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'
|
204
|
+
it_is_correct_for 'Democratic Republic of Timor-Leste', :samples => ['+670 465 7886', '+670 7465 7886']
|
205
|
+
it_is_correct_for 'Democratic Republic of the Congo', :samples => '+243 80 864 9794'
|
206
|
+
it_is_correct_for 'Diego Garcia', :samples => '+246 123 7686'
|
207
|
+
it_is_correct_for 'Djibouti', :samples => '+253 3671 1431'
|
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
|
234
|
+
it_is_correct_for 'Equatorial Guinea', :samples => ['+240 222 201 123',
|
235
|
+
'+240 335 201 123']
|
236
|
+
it_is_correct_for 'Eritrea', :samples => '+291 6 334 475'
|
237
|
+
it_is_correct_for 'Ethiopia', :samples => '+251 89 558 3197'
|
238
|
+
it_is_correct_for 'Falkland Islands (Malvinas)', :samples => '+500 28494'
|
239
|
+
it_is_correct_for 'Faroe Islands', :samples => '+298 969 597'
|
240
|
+
it_is_correct_for 'Fiji (Republic of)', :samples => '+679 998 2441'
|
241
|
+
it 'is correct for Finland' do
|
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
|
257
|
+
end
|
258
|
+
it_is_correct_for 'French Guiana (French Department of)', :samples => '+594 594 123 456'
|
259
|
+
it_is_correct_for "French Polynesia (Territoire français d'outre-mer)", :samples => '+689 87 27 84 00'
|
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
|
+
# ]
|
268
|
+
it_is_correct_for 'Gambia', :samples => '+220 989 5148'
|
269
|
+
it_is_correct_for 'Germany', :samples => [
|
270
|
+
'+49 69 155 1',
|
271
|
+
'+49 1577 536 8701'
|
272
|
+
]
|
273
|
+
it_is_correct_for 'Georgia', :samples => ['+995 220 123 45',
|
274
|
+
'+995 32 123 4567',
|
275
|
+
'+995 342 123 456',
|
276
|
+
'+995 596 123 456']
|
277
|
+
it_is_correct_for 'Greenland', :samples => '+299 922 954'
|
278
|
+
it_is_correct_for 'Guadeloupe (French Department of)', :samples => '+590 123 456 789'
|
279
|
+
it_is_correct_for 'Guatemala (Republic of)', :samples => ['+502 19 123 456 789',
|
280
|
+
'+502 2 123 4567']
|
281
|
+
it_is_correct_for 'Guinea', :samples => [
|
282
|
+
'+224 664 12 34 56',
|
283
|
+
'+224 30 31 12 34',
|
284
|
+
'+224 3041 12 34',
|
285
|
+
'+224 700 00 00 00'
|
286
|
+
]
|
287
|
+
|
288
|
+
it_is_correct_for 'Guinea-Bissau', :samples => '+245 44 728 6998'
|
289
|
+
it_is_correct_for 'Guyana', :samples => '+592 263 1234'
|
290
|
+
it_is_correct_for 'Honduras (Republic of)', :samples => '+504 12 961 637'
|
291
|
+
it_is_correct_for 'Italy', :samples => ['+39 0574 1234',
|
292
|
+
'+39 06 49911']
|
293
|
+
it_is_correct_for 'Iraq', :samples => ['+964 1 123 4567',
|
294
|
+
'+964 21 113 456',
|
295
|
+
'+964 71 1234 5678']
|
296
|
+
|
297
|
+
|
298
|
+
it_is_correct_for 'Kiribati (Republic of)', :samples => '+686 31993'
|
299
|
+
it_is_correct_for "Democratic People's Republic of Korea", :samples => ['+850 2 123 45',
|
300
|
+
'+850 2 123 456 789',
|
301
|
+
'+850 2 381 2356',
|
302
|
+
#'+850 2 8801 1234 5678 1256',
|
303
|
+
'+850 191 123 4567']
|
304
|
+
it_is_correct_for 'Kuwait (State of)', :samples => ['+965 2345 6789', '+965 181 2345' ]
|
305
|
+
it_is_correct_for 'Kenya', :samples => [
|
306
|
+
'254201234567',
|
307
|
+
'254111234567',
|
308
|
+
'254723100220',
|
309
|
+
'+254-20-4262 140',
|
310
|
+
'+254-(0)20-4262 140'
|
311
|
+
]
|
312
|
+
|
313
|
+
it_is_correct_for "Lao People's Democratic Republic", :samples => ['+856 96 443 333',
|
314
|
+
'+856 30 443 3334',
|
315
|
+
'+856 20 4433 3334']
|
316
|
+
it_is_correct_for 'Latvia', :samples => ['+371 801 234 56',
|
317
|
+
'+371 637 234 56',
|
318
|
+
'+371 294 123 45']
|
319
|
+
it_is_correct_for 'Lebanon', :samples => ['+961 1 123 456',
|
320
|
+
'+961 4 123 456',
|
321
|
+
'+961 3 123 456',
|
322
|
+
'+961 70 123 456',
|
323
|
+
'+961 90 123 456',
|
324
|
+
'+961 81 123 456']
|
325
|
+
it_is_correct_for 'Lesotho', :samples => '+266 7612 6866'
|
326
|
+
it 'is correct for Liberia' do
|
327
|
+
Phony.plausible?('+231 2 123 4567').should be_truthy
|
328
|
+
Phony.plausible?('+231 4 123 456').should be_truthy
|
329
|
+
Phony.plausible?('+231 77 123 4567').should be_truthy
|
330
|
+
end
|
331
|
+
it_is_correct_for 'Macao', :samples => ['+853 28 12 3456',
|
332
|
+
'+853 8 123 4567',
|
333
|
+
'+853 6 123 4567',]
|
334
|
+
it_is_correct_for 'Macedonia', :samples => ['+389 2 123 4567',
|
335
|
+
'+389 7 124 3456',
|
336
|
+
'+389 7 234 5678']
|
337
|
+
it_is_correct_for 'Madagascar', :samples => ['+261 20 23 456 78',
|
338
|
+
'+261 32 34 546 78',
|
339
|
+
'+261 33 34 546 78',
|
340
|
+
'+261 34 34 546 78',
|
341
|
+
'+261 38 34 546 78']
|
342
|
+
it 'is incorrect for Madagascar' do
|
343
|
+
Phony.plausible?('+261 20 012 345 678').should be_falsey
|
344
|
+
Phony.plausible?('+261 20 12 434 569').should be_falsey
|
345
|
+
Phony.plausible?('+261 51 23 4567 8').should be_falsey
|
346
|
+
Phony.plausible?('+261 34 345 46789').should be_falsey
|
347
|
+
Phony.plausible?('+261 34 345 467').should be_falsey
|
348
|
+
end
|
349
|
+
|
350
|
+
it_is_correct_for 'Malawi', :samples => ['+265 1725 123',
|
351
|
+
'+265 213 456 789',
|
352
|
+
'+265 9123 456',
|
353
|
+
'+265 991 123 456']
|
354
|
+
it_is_correct_for 'Maldives (Republic of)', :samples => '+960 928 8399'
|
355
|
+
it_is_correct_for 'Mali', :samples => '+223 1117 9812'
|
356
|
+
|
357
|
+
it_is_correct_for 'Marshall Islands (Republic of the)', :samples => '+692 372 7183'
|
358
|
+
it_is_correct_for 'Martinique (French Department of)', :samples => '+596 596 123 456'
|
359
|
+
it_is_correct_for 'Mauritania', :samples => '+222 1234 5678'
|
360
|
+
it_is_correct_for 'Mauritius', :samples => '+230 5695 2277'
|
361
|
+
it_is_correct_for 'Micronesia (Federated States of)', :samples => '+691 766 7914'
|
362
|
+
it_is_correct_for 'Moldova', :samples => ['+373 800 123 45',
|
363
|
+
'+373 22 123 345',
|
364
|
+
'+373 241 123 45',
|
365
|
+
'+373 605 123 45',
|
366
|
+
'+373 803 123 45']
|
367
|
+
it_is_correct_for 'Namibia', :samples => ['+264 6751 613 24',
|
368
|
+
'+264 67 175 890',
|
369
|
+
'+264 63 088 612 345',
|
370
|
+
'+264 85 1234 567']
|
371
|
+
it_is_correct_for 'Nauru (Republic of)', :samples => '+674 239 8387'
|
372
|
+
it_is_correct_for 'Norway', :samples => ['+47 51 23 45 67',
|
373
|
+
'+47 41 23 45 67']
|
374
|
+
it_is_correct_for 'Nepal', :samples => ['+977 1 434 5678',
|
375
|
+
'+977 10 123 456',
|
376
|
+
'+977 98 1234 5678']
|
377
|
+
it_is_correct_for "New Caledonia (Territoire français d'outre-mer)", :samples => '+687 546 835'
|
378
|
+
it 'is correct for New Zealand' do
|
379
|
+
Phony.plausible?('+64800123123').should be_truthy # Free phone
|
380
|
+
Phony.plausible?('+648001231234').should be_truthy # Free phone
|
381
|
+
end
|
382
|
+
it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
|
383
|
+
it_is_correct_for 'Niger', :samples => '+227 1234 5678'
|
384
|
+
it_is_correct_for 'Nigeria', :samples => ['+234 807 059 1111',
|
385
|
+
'+234 811 234 5678',
|
386
|
+
'+234 64 830 00',
|
387
|
+
'+234 1 280 444',
|
388
|
+
'+234 85 123 456']
|
389
|
+
it_is_correct_for 'Niue', :samples => '+683 3791'
|
390
|
+
it_is_correct_for 'Oman', :samples => ['+968 24 423 123',
|
391
|
+
'+968 25 423 123']
|
392
|
+
it_is_correct_for 'Palau (Republic of)', :samples => '+680 483 7871'
|
393
|
+
|
394
|
+
it_is_correct_for 'Papua New Guinea', :samples => ['+675 180 1234',
|
395
|
+
'+675 170 12',
|
396
|
+
'+675 189 1',
|
397
|
+
'+675 184 1234 5678',
|
398
|
+
'+675 185 1234',
|
399
|
+
'+675 275 1234',
|
400
|
+
'+675 278 12',
|
401
|
+
'+675 115 1234 5678',
|
402
|
+
'+675 28 123 45',
|
403
|
+
'+675 16 123 12',
|
404
|
+
'+675 711 23 456',
|
405
|
+
'+675 731 23 456',
|
406
|
+
'+675 741 23 456',
|
407
|
+
'+675 770 12 345',
|
408
|
+
'+675 771 12 345',
|
409
|
+
'+675 772 12 345',
|
410
|
+
'+675 773 01 234',
|
411
|
+
'+675 774 12 345',
|
412
|
+
'+675 775 12 345',
|
413
|
+
'+675 80 123 456',
|
414
|
+
'+675 90 123 456',
|
415
|
+
'+675 3 123 456']
|
416
|
+
|
417
|
+
it_is_correct_for 'Panama (Republic of)', :samples => ['+507 800 1234',
|
418
|
+
'+507 6 123 4567',
|
419
|
+
'+507 2 123 456']
|
420
|
+
it_is_correct_for 'Reunion / Mayotte (new)', :samples => '+262 295 276 964'
|
421
|
+
it_is_correct_for 'Rwanda', :samples => ['+250 72 1234567',
|
422
|
+
'+250 73 1234567',
|
423
|
+
'+250 78 1234567',
|
424
|
+
'+250 79 1234567',
|
425
|
+
'+250 25 1234567',
|
426
|
+
'+250 06 123456']
|
427
|
+
it_is_correct_for 'Saint Helena', :samples => '+290 5134'
|
428
|
+
it_is_correct_for 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)', :samples => '+508 474 714'
|
429
|
+
it_is_correct_for 'Salvador (El)', :samples => [
|
430
|
+
'+503 2112 1234',
|
431
|
+
'+503 6112 1234'
|
432
|
+
]
|
433
|
+
it_is_correct_for 'Samoa (Independent State of)', :samples => ['+685 800 123',
|
434
|
+
'+685 61 123',
|
435
|
+
'+685 721 2345',
|
436
|
+
'+685 830 123',
|
437
|
+
'+685 601 234',
|
438
|
+
'+685 841 2345']
|
439
|
+
it_is_correct_for 'San Marino', :samples => ['+378 800 123',
|
440
|
+
'+378 800 123 4567',
|
441
|
+
'+378 012 345',
|
442
|
+
'+378 012 345 6789',
|
443
|
+
'+378 512 345',
|
444
|
+
'+378 512 345 6789']
|
445
|
+
it_is_correct_for 'Sao Tome and Principe', :samples => ['+239 2 220 012',
|
446
|
+
'+239 9 920 012']
|
447
|
+
it_is_correct_for 'Saudi Arabia (Kingdom of)', :samples => ['+966 50 296 3727',
|
448
|
+
'+966 011 307 4838']
|
449
|
+
it_is_correct_for 'Senegal', :samples => '+221 1234 56789'
|
450
|
+
it_is_correct_for 'Serbia', :samples => ['+381 800 123 45',
|
451
|
+
['+381 10 123 45', '+381 10 123 456'],
|
452
|
+
['+381 11 123 456', '+381 11 123 4567'],
|
453
|
+
'+381 72 123 456',
|
454
|
+
'+381 60 123',
|
455
|
+
['+381 60 123 4567', '+381 69 123 456'],
|
456
|
+
'+381 42 123 456',
|
457
|
+
'+381 677 123 456',
|
458
|
+
'+381 678 123 456',
|
459
|
+
'+381 9 123 4567',
|
460
|
+
'+381 60 123',
|
461
|
+
'+381 60 123 456 7890',
|
462
|
+
'+381 70 123 456',
|
463
|
+
'+381 66 12 1234',
|
464
|
+
'+381 63 123 456',
|
465
|
+
['+381 64 12 34567', '+381 64 12 3456'],
|
466
|
+
['+381 62 12 34567', '+381 62 12 3456'],
|
467
|
+
['+381 65 12 34567', '+381 65 12 3456']]
|
468
|
+
it_is_correct_for 'Sierra Leone', :samples => '+232 42 393 972'
|
469
|
+
it_is_correct_for 'Singapore', :samples => ['+65 6123 1234',
|
470
|
+
'+65 800 852 1234']
|
471
|
+
it_is_correct_for 'Solomon Islands', :samples => '+677 97851'
|
472
|
+
it_is_correct_for 'Somali Democratic Republic', :samples => ['+252 1034 123 45',
|
473
|
+
'+252 1313 123',
|
474
|
+
'+252 160 12 34',
|
475
|
+
'+252 500 123 45',
|
476
|
+
'+252 67 1234 567']
|
477
|
+
|
478
|
+
it 'is correct for South Korea' do
|
479
|
+
Phony.plausible?('+82 2 1234 5678').should be_truthy
|
480
|
+
Phony.plausible?('+82 2 711 2222').should be_truthy
|
481
|
+
Phony.plausible?('+82 51 1234 5678').should be_truthy
|
482
|
+
Phony.plausible?('+82 51 123 5678').should be_truthy
|
483
|
+
Phony.plausible?('+82 10 2797 5588').should be_truthy
|
484
|
+
Phony.plausible?('+82 10 8797 1234').should be_truthy
|
485
|
+
end
|
486
|
+
|
487
|
+
it_is_correct_for 'South Sudan', :samples => ['+211 123 212 345',
|
488
|
+
'+211 973 212 345']
|
489
|
+
it_is_correct_for 'Suriname (Republic of)', :samples => ['+597 212 345', '+597 612 3456']
|
490
|
+
it_is_correct_for 'Swaziland', :samples => ['+268 2207 1234', '+268 550 1234']
|
491
|
+
it_is_correct_for 'Sweden', :samples => ['+46 42 123 45', ['+46 417 123 45', '+46 522 636 365', '+46 513 12 34 56']]
|
492
|
+
it_is_correct_for 'Syrian Arab Republic', :samples => ['+963 11 123 4567',
|
493
|
+
'+963 31 123 4567',
|
494
|
+
'+963 15 731 234',
|
495
|
+
'+963 9 1234 5678']
|
496
|
+
it_is_correct_for 'Taiwan', :samples => ['+886 6 123 4567',
|
497
|
+
'+886 3 123 4567',
|
498
|
+
'+886 33 123 456',
|
499
|
+
'+886 827 123 45',
|
500
|
+
'+886 4 123 1234',
|
501
|
+
'+886 9 1234 5678']
|
502
|
+
it_is_correct_for 'Tajikistan', :samples => ['+992 3130 123 45',
|
503
|
+
'+992 331700 123',
|
504
|
+
'+992 372 123 345',
|
505
|
+
'+992 505 123 456',
|
506
|
+
'+992 973 123 456',
|
507
|
+
'+992 474 456 123']
|
508
|
+
it_is_correct_for 'Thailand', :samples => ['+6621231234',
|
509
|
+
'+6636123123',
|
510
|
+
'+66612345678',
|
511
|
+
'+66851234567',
|
512
|
+
'+66921234567']
|
513
|
+
it_is_correct_for 'Togolese Republic', :samples => '+228 1234 5678'
|
514
|
+
it_is_correct_for 'Tokelau', :samples => '+690 3 291'
|
515
|
+
it_is_correct_for 'Tonga (Kingdom of)', :samples => ['+676 20 123',
|
516
|
+
'+676 84 123',
|
517
|
+
'+676 77 123 45',
|
518
|
+
'+676 89 123 45']
|
519
|
+
it_is_correct_for 'Turkmenistan', :samples => ['+993 12 456 789',
|
520
|
+
'+993 131 456 78',
|
521
|
+
'+993 1392 4567',
|
522
|
+
'+993 6 123 4567']
|
523
|
+
it_is_correct_for 'Tuvalu', :samples => '+688 93742'
|
524
|
+
it_is_correct_for 'Uzbekistan (Republic of)', :samples => '+998 78 867 4419'
|
525
|
+
it_is_correct_for 'Vanuatu (Republic of)', :samples => ['+678 7216 123', '+678 26 123']
|
526
|
+
it_is_correct_for 'Lybia', :samples => ['+218 205 123 45',
|
527
|
+
'+218 22 123 456',
|
528
|
+
'+218 21 1234 456',
|
529
|
+
'+218 91 1234 456',
|
530
|
+
'+218 92 1234 456',
|
531
|
+
'+218 94 1234 456',
|
532
|
+
'+218 95 1234 456']
|
533
|
+
it_is_correct_for 'Mongolia', :samples => ['+976 11 123 45',
|
534
|
+
['+976 121 12 34', '+976 121 12 345'],
|
535
|
+
'+976 70 123 456',
|
536
|
+
'+976 75 123 456',
|
537
|
+
'+976 88 123 456',
|
538
|
+
'+976 50 123 456']
|
539
|
+
it_is_correct_for 'Mozambique', :samples => ['+258 600 123 456',
|
540
|
+
'+258 251 123 45',
|
541
|
+
'+258 82 1234 456',
|
542
|
+
'+258 7 1234 4567']
|
543
|
+
it_is_correct_for 'Ukraine', :samples => ['+380 800 123 456',
|
544
|
+
'+380 312 123 456',
|
545
|
+
'+380 32 2123 456',
|
546
|
+
'+380 3259 123 45',
|
547
|
+
'+380 32606 1234',
|
548
|
+
'+380 50 123 45 67',
|
549
|
+
'+380 66 123 45 67',
|
550
|
+
'+380 95 123 45 67',
|
551
|
+
'+380 99 123 45 67',
|
552
|
+
'+380 67 123 45 67',
|
553
|
+
'+380 96 123 45 67',
|
554
|
+
'+380 97 123 45 67',
|
555
|
+
'+380 98 123 45 67',
|
556
|
+
'+380 63 123 45 67',
|
557
|
+
'+380 93 123 45 67',
|
558
|
+
'+380 39 123 45 67',
|
559
|
+
'+380 68 123 45 67',
|
560
|
+
'+380 91 123 45 67',
|
561
|
+
'+380 92 123 45 67',
|
562
|
+
'+380 94 123 45 67'
|
563
|
+
]
|
564
|
+
it_is_correct_for 'United Arab Emirates', :samples => ['+971 800 12',
|
565
|
+
'+971 800 12 345 6789',
|
566
|
+
'+971 800 12 345 67',
|
567
|
+
'+971 2 123 4567',
|
568
|
+
'+971 50 641 2345',
|
569
|
+
'+971 600 641 234',
|
570
|
+
'+971 500 641 234',
|
571
|
+
'+971 200 641 234',
|
572
|
+
'+971 54 999 9999',
|
573
|
+
'+971 58 999 9999']
|
574
|
+
|
575
|
+
it_is_correct_for 'United Kingdom', :samples => ['+44 1827 50111'], :invalid_samples => ['+44 0000 123456']
|
576
|
+
|
577
|
+
it_is_correct_for 'Uruguay (Eastern Republic of)', :samples => ['+598 800 123 45',
|
578
|
+
'+598 2 012 3456',
|
579
|
+
'+598 21 123 456',
|
580
|
+
'+598 909 123 45',
|
581
|
+
'+598 93 123 456',
|
582
|
+
'+598 908 123 45',
|
583
|
+
'+598 805 123 45']
|
584
|
+
it_is_correct_for 'Vietnam', :samples => ['+84 24 41234567',
|
585
|
+
'+84 28 41234567',
|
586
|
+
'+84 23 61234567']
|
587
|
+
it_is_correct_for 'Yemen', :samples => [['+967 1 234 567', '+967 1 234 5678'],
|
588
|
+
'+967 7 234 567',
|
589
|
+
'+967 77 123 4567',
|
590
|
+
'+967 58 1234']
|
591
|
+
it 'is correct for Zambia' do
|
592
|
+
Phony.plausible?('+260 211 123456').should be_truthy # Fixed
|
593
|
+
Phony.plausible?('+260 96 512 4567').should be_truthy # MTN Mobile
|
594
|
+
Phony.plausible?('+260 97 712 3456').should be_truthy # Airtel Mobile
|
595
|
+
Phony.plausible?('+260 95 512 4567').should be_truthy # Zamtel Mobile
|
596
|
+
Phony.plausible?('+260 96 512 456').should be_falsy # MTN Mobile (Too short)
|
597
|
+
Phony.plausible?('+260 97 812 345').should be_falsy # Airtel Mobile (Too short)
|
598
|
+
Phony.plausible?('+260 95 512 345').should be_falsy # Zamtel Mobile (Too short)
|
599
|
+
Phony.plausible?('+260 800 123 456').should be_truthy # Toll free
|
600
|
+
end
|
601
|
+
it_is_correct_for 'Zimbabwe', :samples => [['+263 2582 123 456', '+263 2582 123'],
|
602
|
+
['+263 147 123 456', '+263 147 123'],
|
603
|
+
['+263 270 123 456', '+263 270 123 45'],
|
604
|
+
'+263 86 1235 4567']
|
605
|
+
|
606
|
+
it 'is correct for Indonesia' do
|
607
|
+
Phony.plausible?('+62 22 000 0').should be_falsey
|
608
|
+
Phony.plausible?('+62 22 000 00').should be_truthy
|
609
|
+
Phony.plausible?('+62 22 000 0000').should be_truthy
|
610
|
+
Phony.plausible?('+62 22 0000 0000').should be_truthy
|
611
|
+
Phony.plausible?('+62 22 000 000 000').should be_truthy
|
612
|
+
end
|
613
|
+
|
614
|
+
it 'is correct for Russia' do
|
615
|
+
Phony.plausible?('+7 3522 000 000').should be_truthy
|
616
|
+
end
|
617
|
+
|
618
|
+
it 'is correct for Peru' do
|
619
|
+
Phony.plausible?('+51 1 123 1234').should be_truthy # Lima
|
620
|
+
Phony.plausible?('+51 9 1234 1234').should be_truthy # mobile
|
621
|
+
Phony.plausible?('+51 84 123 123').should be_truthy # Cuzco, best effort
|
622
|
+
end
|
623
|
+
|
624
|
+
it 'is correct for Kosovo' do
|
625
|
+
Phony.plausible?('+383 29 000 000').should be_truthy # Landline
|
626
|
+
Phony.plausible?('+383 44 000 000').should be_truthy # Mobile
|
627
|
+
end
|
628
|
+
|
629
|
+
it 'is correct for Bulgaria' do
|
630
|
+
Phony.plausible?('+359 2 123 123').should be_truthy # Landline Sofia
|
631
|
+
Phony.plausible?('+359 2 123 1234').should be_truthy # Landline Sofia
|
632
|
+
Phony.plausible?('+359 30 123 12').should be_truthy # Landline
|
633
|
+
Phony.plausible?('+359 30 123 123').should be_truthy # Landline
|
634
|
+
Phony.plausible?('+359 89 123 1234').should be_truthy # Mobile
|
635
|
+
end
|
636
|
+
|
637
|
+
it 'is correct for Malaysia' do
|
638
|
+
Phony.plausible?('+60 5 123 1234').should be_truthy # Non Selangor Landline
|
639
|
+
Phony.plausible?('+60 3 1234 1234').should be_truthy # Selangor Landline
|
640
|
+
Phony.plausible?('+60 88 123 123').should be_truthy # Landline Sabah – Kota Kinabalu and Kudat
|
641
|
+
end
|
642
|
+
|
643
|
+
it 'is correct for Japan' do
|
644
|
+
Phony.plausible?('+81 90 1234 1234').should be_truthy
|
645
|
+
Phony.plausible?('+81 120 123 123').should be_truthy
|
646
|
+
Phony.plausible?('+81 800 123 1234').should be_truthy
|
647
|
+
end
|
648
|
+
|
649
|
+
it 'is correct for Philippine' do
|
650
|
+
Phony.plausible?('+63 2 89889999').should be_truthy
|
651
|
+
Phony.plausible?('+63 976 1234567').should be_truthy # mobile phone with area code 9
|
652
|
+
Phony.plausible?('+63 876 1234567').should be_truthy # mobile phone with area code 8
|
653
|
+
end
|
654
|
+
end
|
655
|
+
end
|
656
|
+
end
|