phony 2.20.14 → 2.20.15

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