phony 2.18.3 → 3.0.3

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