phony 2.17.0 → 2.20.12

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.textile +34 -6
  3. data/lib/phony/config.rb +91 -0
  4. data/lib/phony/countries/argentina.rb +355 -0
  5. data/lib/phony/countries/austria.rb +4 -2
  6. data/lib/phony/countries/bangladesh.rb +2 -0
  7. data/lib/phony/countries/belarus.rb +2 -0
  8. data/lib/phony/countries/brazil.rb +4 -2
  9. data/lib/phony/countries/cambodia.rb +3 -5
  10. data/lib/phony/countries/china.rb +7 -2
  11. data/lib/phony/countries/croatia.rb +2 -0
  12. data/lib/phony/countries/georgia.rb +2 -0
  13. data/lib/phony/countries/germany.rb +5 -2
  14. data/lib/phony/countries/guinea.rb +8 -5
  15. data/lib/phony/countries/india.rb +2 -0
  16. data/lib/phony/countries/indonesia.rb +2 -0
  17. data/lib/phony/countries/ireland.rb +27 -23
  18. data/lib/phony/countries/italy.rb +41 -18
  19. data/lib/phony/countries/japan.rb +60 -8
  20. data/lib/phony/countries/kyrgyzstan.rb +2 -0
  21. data/lib/phony/countries/latvia.rb +2 -0
  22. data/lib/phony/countries/libya.rb +3 -1
  23. data/lib/phony/countries/malaysia.rb +2 -0
  24. data/lib/phony/countries/moldova.rb +2 -0
  25. data/lib/phony/countries/montenegro.rb +2 -0
  26. data/lib/phony/countries/myanmar.rb +2 -0
  27. data/lib/phony/countries/namibia.rb +2 -0
  28. data/lib/phony/countries/nepal.rb +2 -0
  29. data/lib/phony/countries/netherlands.rb +2 -0
  30. data/lib/phony/countries/pakistan.rb +2 -0
  31. data/lib/phony/countries/paraguay.rb +2 -0
  32. data/lib/phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb +2 -0
  33. data/lib/phony/countries/saudi_arabia.rb +2 -0
  34. data/lib/phony/countries/serbia.rb +7 -1
  35. data/lib/phony/countries/somalia.rb +2 -0
  36. data/lib/phony/countries/south_korea.rb +7 -2
  37. data/lib/phony/countries/sweden.rb +2 -0
  38. data/lib/phony/countries/taiwan.rb +3 -0
  39. data/lib/phony/countries/tajikistan.rb +2 -0
  40. data/lib/phony/countries/turkmenistan.rb +2 -0
  41. data/lib/phony/countries/ukraine.rb +2 -0
  42. data/lib/phony/countries/united_kingdom.rb +5 -2
  43. data/lib/phony/countries/uruguay.rb +2 -0
  44. data/lib/phony/countries/vietnam.rb +7 -1
  45. data/lib/phony/countries/zimbabwe.rb +2 -0
  46. data/lib/phony/countries.rb +108 -65
  47. data/lib/phony/country.rb +11 -3
  48. data/lib/phony/country_codes.rb +16 -3
  49. data/lib/phony/dsl.rb +5 -3
  50. data/lib/phony/local_splitters/fixed.rb +2 -0
  51. data/lib/phony/national_code.rb +1 -1
  52. data/lib/phony/national_splitters/none.rb +1 -3
  53. data/lib/phony/trunk_code.rb +5 -5
  54. data/lib/phony.rb +62 -57
  55. data/spec/functional/config_spec.rb +44 -0
  56. data/spec/functional/plausibility_spec.rb +104 -19
  57. data/spec/lib/phony/countries_spec.rb +107 -35
  58. data/spec/lib/phony/country_codes_spec.rb +82 -58
  59. data/spec/lib/phony/country_spec.rb +29 -9
  60. data/spec/lib/phony/dsl_spec.rb +7 -3
  61. data/spec/lib/phony/local_splitters/regex_spec.rb +19 -15
  62. data/spec/lib/phony/national_code_spec.rb +15 -45
  63. data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -16
  64. data/spec/lib/phony/national_splitters/none_spec.rb +3 -3
  65. data/spec/lib/phony/national_splitters/variable_spec.rb +9 -13
  66. data/spec/lib/phony/trunk_code_spec.rb +85 -0
  67. data/spec/lib/phony/vanity_spec.rb +4 -4
  68. metadata +23 -18
data/lib/phony.rb CHANGED
@@ -1,70 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ # NOTE We use Kernel.load here, as it's possible to redefine Phony via Phony::Config.
4
+
1
5
  # Framework.
2
6
  #
3
- require File.expand_path '../phony/vanity', __FILE__
4
- require File.expand_path '../phony/local_splitters/fixed', __FILE__
5
- require File.expand_path '../phony/local_splitters/regex', __FILE__
6
- require File.expand_path '../phony/national_splitters/dsl', __FILE__
7
- require File.expand_path '../phony/national_splitters/fixed', __FILE__
8
- require File.expand_path '../phony/national_splitters/variable', __FILE__
9
- require File.expand_path '../phony/national_splitters/regex', __FILE__
10
- require File.expand_path '../phony/national_splitters/default', __FILE__
11
- require File.expand_path '../phony/national_splitters/none', __FILE__
12
- require File.expand_path '../phony/national_code', __FILE__
13
- require File.expand_path '../phony/country', __FILE__
14
- require File.expand_path '../phony/trunk_code', __FILE__
15
- require File.expand_path '../phony/country_codes', __FILE__
16
-
17
- require File.expand_path '../phony/dsl', __FILE__
7
+ load File.expand_path '../phony/config.rb', __FILE__
8
+ load File.expand_path '../phony/vanity.rb', __FILE__
9
+ load File.expand_path '../phony/local_splitters/fixed.rb', __FILE__
10
+ load File.expand_path '../phony/local_splitters/regex.rb', __FILE__
11
+ load File.expand_path '../phony/national_splitters/dsl.rb', __FILE__
12
+ load File.expand_path '../phony/national_splitters/fixed.rb', __FILE__
13
+ load File.expand_path '../phony/national_splitters/variable.rb', __FILE__
14
+ load File.expand_path '../phony/national_splitters/regex.rb', __FILE__
15
+ load File.expand_path '../phony/national_splitters/default.rb', __FILE__
16
+ load File.expand_path '../phony/national_splitters/none.rb', __FILE__
17
+ load File.expand_path '../phony/national_code.rb', __FILE__
18
+ load File.expand_path '../phony/country.rb', __FILE__
19
+ load File.expand_path '../phony/trunk_code.rb', __FILE__
20
+ load File.expand_path '../phony/country_codes.rb', __FILE__
21
+ load File.expand_path '../phony/dsl.rb', __FILE__
18
22
 
19
23
  # Countries.
20
24
  #
21
25
  # The ones that need more space to define.
22
26
  #
23
- require File.expand_path '../phony/countries/austria', __FILE__
24
- require File.expand_path '../phony/countries/bangladesh', __FILE__
25
- require File.expand_path '../phony/countries/belarus', __FILE__
26
- require File.expand_path '../phony/countries/brazil', __FILE__
27
- require File.expand_path '../phony/countries/cambodia', __FILE__
28
- require File.expand_path '../phony/countries/croatia', __FILE__
29
- require File.expand_path '../phony/countries/china', __FILE__
30
- require File.expand_path '../phony/countries/georgia', __FILE__
31
- require File.expand_path '../phony/countries/germany', __FILE__
32
- require File.expand_path '../phony/countries/guinea', __FILE__
33
- require File.expand_path '../phony/countries/india', __FILE__
34
- require File.expand_path '../phony/countries/indonesia', __FILE__
35
- require File.expand_path '../phony/countries/ireland', __FILE__
36
- require File.expand_path '../phony/countries/italy', __FILE__
37
- require File.expand_path '../phony/countries/japan', __FILE__
38
- require File.expand_path '../phony/countries/kyrgyzstan', __FILE__
39
- require File.expand_path '../phony/countries/latvia', __FILE__
40
- require File.expand_path '../phony/countries/libya', __FILE__
41
- require File.expand_path '../phony/countries/malaysia', __FILE__
42
- require File.expand_path '../phony/countries/moldova', __FILE__
43
- require File.expand_path '../phony/countries/montenegro', __FILE__
44
- require File.expand_path '../phony/countries/myanmar', __FILE__
45
- require File.expand_path '../phony/countries/namibia', __FILE__
46
- require File.expand_path '../phony/countries/nepal', __FILE__
47
- require File.expand_path '../phony/countries/netherlands', __FILE__
48
- require File.expand_path '../phony/countries/pakistan', __FILE__
49
- require File.expand_path '../phony/countries/paraguay', __FILE__
50
- require File.expand_path '../phony/countries/russia_kazakhstan_abkhasia_south_ossetia', __FILE__
51
- require File.expand_path '../phony/countries/saudi_arabia', __FILE__
52
- require File.expand_path '../phony/countries/serbia', __FILE__
53
- require File.expand_path '../phony/countries/somalia', __FILE__
54
- require File.expand_path '../phony/countries/south_korea', __FILE__
55
- require File.expand_path '../phony/countries/sweden', __FILE__
56
- require File.expand_path '../phony/countries/taiwan', __FILE__
57
- require File.expand_path '../phony/countries/tajikistan', __FILE__
58
- require File.expand_path '../phony/countries/turkmenistan', __FILE__
59
- require File.expand_path '../phony/countries/vietnam', __FILE__
60
- require File.expand_path '../phony/countries/ukraine', __FILE__
61
- require File.expand_path '../phony/countries/united_kingdom', __FILE__
62
- require File.expand_path '../phony/countries/uruguay', __FILE__
63
- require File.expand_path '../phony/countries/zimbabwe', __FILE__
27
+ load File.expand_path '../phony/countries/argentina.rb', __FILE__
28
+ load File.expand_path '../phony/countries/austria.rb', __FILE__
29
+ load File.expand_path '../phony/countries/bangladesh.rb', __FILE__
30
+ load File.expand_path '../phony/countries/belarus.rb', __FILE__
31
+ load File.expand_path '../phony/countries/brazil.rb', __FILE__
32
+ load File.expand_path '../phony/countries/cambodia.rb', __FILE__
33
+ load File.expand_path '../phony/countries/croatia.rb', __FILE__
34
+ load File.expand_path '../phony/countries/china.rb', __FILE__
35
+ load File.expand_path '../phony/countries/georgia.rb', __FILE__
36
+ load File.expand_path '../phony/countries/germany.rb', __FILE__
37
+ load File.expand_path '../phony/countries/guinea.rb', __FILE__
38
+ load File.expand_path '../phony/countries/india.rb', __FILE__
39
+ load File.expand_path '../phony/countries/indonesia.rb', __FILE__
40
+ load File.expand_path '../phony/countries/ireland.rb', __FILE__
41
+ load File.expand_path '../phony/countries/italy.rb', __FILE__
42
+ load File.expand_path '../phony/countries/japan.rb', __FILE__
43
+ load File.expand_path '../phony/countries/kyrgyzstan.rb', __FILE__
44
+ load File.expand_path '../phony/countries/latvia.rb', __FILE__
45
+ load File.expand_path '../phony/countries/libya.rb', __FILE__
46
+ load File.expand_path '../phony/countries/malaysia.rb', __FILE__
47
+ load File.expand_path '../phony/countries/moldova.rb', __FILE__
48
+ load File.expand_path '../phony/countries/montenegro.rb', __FILE__
49
+ load File.expand_path '../phony/countries/myanmar.rb', __FILE__
50
+ load File.expand_path '../phony/countries/namibia.rb', __FILE__
51
+ load File.expand_path '../phony/countries/nepal.rb', __FILE__
52
+ load File.expand_path '../phony/countries/netherlands.rb', __FILE__
53
+ load File.expand_path '../phony/countries/pakistan.rb', __FILE__
54
+ load File.expand_path '../phony/countries/paraguay.rb', __FILE__
55
+ load File.expand_path '../phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb', __FILE__
56
+ load File.expand_path '../phony/countries/saudi_arabia.rb', __FILE__
57
+ load File.expand_path '../phony/countries/serbia.rb', __FILE__
58
+ load File.expand_path '../phony/countries/somalia.rb', __FILE__
59
+ load File.expand_path '../phony/countries/south_korea.rb', __FILE__
60
+ load File.expand_path '../phony/countries/sweden.rb', __FILE__
61
+ load File.expand_path '../phony/countries/taiwan.rb', __FILE__
62
+ load File.expand_path '../phony/countries/tajikistan.rb', __FILE__
63
+ load File.expand_path '../phony/countries/turkmenistan.rb', __FILE__
64
+ load File.expand_path '../phony/countries/vietnam.rb', __FILE__
65
+ load File.expand_path '../phony/countries/ukraine.rb', __FILE__
66
+ load File.expand_path '../phony/countries/united_kingdom.rb', __FILE__
67
+ load File.expand_path '../phony/countries/uruguay.rb', __FILE__
68
+ load File.expand_path '../phony/countries/zimbabwe.rb', __FILE__
64
69
 
65
70
  # All other countries.
66
71
  #
67
- require File.expand_path '../phony/countries', __FILE__
72
+ load File.expand_path '../phony/countries.rb', __FILE__
68
73
 
69
74
  # Phony is the main module and is generally used to process
70
75
  # E164 phone numbers directly.
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ #
3
+ describe 'Phony::Config' do
4
+ describe 'load' do
5
+ before do
6
+ # NOTE We redefine Phony as if it was not loaded for this set of tests.
7
+ Object.__send__(:remove_const, :Phony) if Object.constants.include?(:Phony)
8
+
9
+ load 'phony/config.rb'
10
+ end
11
+ after(:all) do
12
+ # After running this suite, we load all of Phony for the following tests.
13
+ load 'phony/config.rb'
14
+
15
+ Phony::Config.load
16
+ end
17
+
18
+ it 'does not fail when loading all' do
19
+ Phony::Config.load
20
+
21
+ expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
22
+ end
23
+ it 'raises when a CC is used that has not been loaded.' do
24
+ Phony::Config.load('41')
25
+
26
+ expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
27
+ end
28
+ it 'raises when a CC is used that has not been loaded.' do
29
+ Phony::Config.load(only: ['41'])
30
+
31
+ expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
32
+ end
33
+ it 'raises when a CC is used that has not been loaded.' do
34
+ Phony::Config.load(except: ['1'])
35
+
36
+ expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
37
+ end
38
+ it 'does not raise when a CC is used that has been loaded.' do
39
+ Phony::Config.load(except: ['41'])
40
+
41
+ expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
42
+ end
43
+ end
44
+ end
@@ -25,11 +25,11 @@ describe 'plausibility' do
25
25
  incorrect = [shortest.sub(/\d\s*\z/, '')] # , longest + '0']
26
26
 
27
27
  correct.each do |value|
28
- Phony.plausible?(value).should be_truthy,
28
+ expect(Phony.plausible?(value)).to be_truthy,
29
29
  "It should validate #{value}, but does not."
30
30
  end
31
31
  incorrect.each do |value|
32
- Phony.plausible?(value).should be_falsey,
32
+ expect(Phony.plausible?(value)).to be_falsey,
33
33
  "It should not validate #{value}, but does."
34
34
  end
35
35
  end
@@ -38,7 +38,7 @@ describe 'plausibility' do
38
38
  invalid = [*sample]
39
39
 
40
40
  invalid.each do |value|
41
- Phony.plausible?(value).should be_falsey,
41
+ expect(Phony.plausible?(value)).to be_falsey,
42
42
  "It should not validate #{value}, but does."
43
43
  end
44
44
  end
@@ -46,10 +46,19 @@ describe 'plausibility' do
46
46
  end
47
47
 
48
48
  context 'specific countries' do
49
- it_is_correct_for 'Austria', :samples => '+43 720 116987' # VoIP
49
+ it_is_correct_for 'Austria', :samples => ['+43 720 116987', # VoIP
50
+ '+43 463 12345'] # Klagenfurt
50
51
  it_is_correct_for 'Bosnia and Herzegovina', :samples => ['+387 66 666 666',
51
52
  '+387 37 123 456',
52
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
53
62
  it 'is correct for Bulgaria' do
54
63
  Phony.plausible?('+359 2 1234567').should be_truthy
55
64
  Phony.plausible?('+359 30 12345').should be_truthy
@@ -178,6 +187,14 @@ describe 'plausibility' do
178
187
  Phony.plausible?('+359 998 123456').should be_truthy
179
188
  Phony.plausible?('+359 999 123456').should be_truthy
180
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']
181
198
  it_is_correct_for 'Congo', :samples => '+242 1234 56789'
182
199
  it_is_correct_for 'Cook Islands', :samples => '+682 71928'
183
200
  it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
@@ -191,7 +208,7 @@ describe 'plausibility' do
191
208
  Phony.plausible?('+385 60 12 345').should be_truthy # Premium rate
192
209
  Phony.plausible?('+385 62 123 456').should be_truthy # Premium, personal and UAN
193
210
  end
194
- it_is_correct_for "Côte d'Ivoire", :samples => '+225 9358 8764'
211
+ it_is_correct_for "Côte d'Ivoire", :samples => '+225 01 9358 8764'
195
212
  it_is_correct_for 'Democratic Republic of Timor-Leste', :samples => ['+670 465 7886', '+670 7465 7886']
196
213
  it_is_correct_for 'Democratic Republic of the Congo', :samples => '+243 80 864 9794'
197
214
  it_is_correct_for 'Diego Garcia', :samples => '+246 123 7686'
@@ -248,10 +265,18 @@ describe 'plausibility' do
248
265
  end
249
266
  it_is_correct_for 'French Guiana (French Department of)', :samples => '+594 594 123 456'
250
267
  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'
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
+ # ]
252
276
  it_is_correct_for 'Gambia', :samples => '+220 989 5148'
253
277
  it_is_correct_for 'Germany', :samples => [
254
- '+49 157 753 6870'
278
+ '+49 69 155 1',
279
+ '+49 1577 536 8701'
255
280
  ]
256
281
  it_is_correct_for 'Georgia', :samples => ['+995 220 123 45',
257
282
  '+995 32 123 4567',
@@ -276,7 +301,7 @@ describe 'plausibility' do
276
301
  '+964 71 1234 5678']
277
302
 
278
303
 
279
- it_is_correct_for 'Kiribati (Republic of)', :samples => '+686 31993'
304
+ it_is_correct_for 'Kiribati (Republic of)', :samples => '+686 34814527'
280
305
  it_is_correct_for "Democratic People's Republic of Korea", :samples => ['+850 2 123 45',
281
306
  '+850 2 123 456 789',
282
307
  '+850 2 381 2356',
@@ -315,10 +340,19 @@ describe 'plausibility' do
315
340
  it_is_correct_for 'Macedonia', :samples => ['+389 2 123 4567',
316
341
  '+389 7 124 3456',
317
342
  '+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']
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 38 34 546 78']
348
+ it 'is incorrect for Madagascar' do
349
+ Phony.plausible?('+261 20 012 345 678').should be_falsey
350
+ Phony.plausible?('+261 20 12 434 569').should be_falsey
351
+ Phony.plausible?('+261 51 23 4567 8').should be_falsey
352
+ Phony.plausible?('+261 34 345 46789').should be_falsey
353
+ Phony.plausible?('+261 34 345 467').should be_falsey
354
+ end
355
+
322
356
  it_is_correct_for 'Malawi', :samples => ['+265 1725 123',
323
357
  '+265 213 456 789',
324
358
  '+265 9123 456',
@@ -329,7 +363,8 @@ describe 'plausibility' do
329
363
  it_is_correct_for 'Marshall Islands (Republic of the)', :samples => '+692 372 7183'
330
364
  it_is_correct_for 'Martinique (French Department of)', :samples => '+596 596 123 456'
331
365
  it_is_correct_for 'Mauritania', :samples => '+222 1234 5678'
332
- it_is_correct_for 'Mauritius', :samples => '+230 5695 2277'
366
+ it_is_correct_for 'Mauritius', :samples => ['+230 5 695 2277',
367
+ '+230 260 0070']
333
368
  it_is_correct_for 'Micronesia (Federated States of)', :samples => '+691 766 7914'
334
369
  it_is_correct_for 'Moldova', :samples => ['+373 800 123 45',
335
370
  '+373 22 123 345',
@@ -353,6 +388,11 @@ describe 'plausibility' do
353
388
  end
354
389
  it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
355
390
  it_is_correct_for 'Niger', :samples => '+227 1234 5678'
391
+ it_is_correct_for 'Nigeria', :samples => ['+234 807 059 1111',
392
+ '+234 811 234 5678',
393
+ '+234 64 830 00',
394
+ '+234 1 280 444',
395
+ '+234 85 123 456']
356
396
  it_is_correct_for 'Niue', :samples => '+683 3791'
357
397
  it_is_correct_for 'Oman', :samples => ['+968 24 423 123',
358
398
  '+968 25 423 123']
@@ -385,6 +425,12 @@ describe 'plausibility' do
385
425
  '+507 6 123 4567',
386
426
  '+507 2 123 456']
387
427
  it_is_correct_for 'Reunion / Mayotte (new)', :samples => '+262 295 276 964'
428
+ it_is_correct_for 'Rwanda', :samples => ['+250 72 1234567',
429
+ '+250 73 1234567',
430
+ '+250 78 1234567',
431
+ '+250 79 1234567',
432
+ '+250 25 1234567',
433
+ '+250 06 123456']
388
434
  it_is_correct_for 'Saint Helena', :samples => '+290 5134'
389
435
  it_is_correct_for 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)', :samples => '+508 474 714'
390
436
  it_is_correct_for 'Salvador (El)', :samples => [
@@ -413,8 +459,10 @@ describe 'plausibility' do
413
459
  ['+381 11 123 456', '+381 11 123 4567'],
414
460
  '+381 72 123 456',
415
461
  '+381 60 123',
416
- '+381 60 123 4567',
462
+ ['+381 60 123 4567', '+381 69 123 456'],
417
463
  '+381 42 123 456',
464
+ '+381 677 123 456',
465
+ '+381 678 123 456',
418
466
  '+381 9 123 4567',
419
467
  '+381 60 123',
420
468
  '+381 60 123 456 7890',
@@ -485,7 +533,10 @@ describe 'plausibility' do
485
533
  it_is_correct_for 'Lybia', :samples => ['+218 205 123 45',
486
534
  '+218 22 123 456',
487
535
  '+218 21 1234 456',
488
- '+218 91 1234 456']
536
+ '+218 91 1234 456',
537
+ '+218 92 1234 456',
538
+ '+218 94 1234 456',
539
+ '+218 95 1234 456']
489
540
  it_is_correct_for 'Mongolia', :samples => ['+976 11 123 45',
490
541
  ['+976 121 12 34', '+976 121 12 345'],
491
542
  '+976 70 123 456',
@@ -539,16 +590,21 @@ describe 'plausibility' do
539
590
  '+598 805 123 45']
540
591
  it_is_correct_for 'Vietnam', :samples => ['+84 24 41234567',
541
592
  '+84 28 41234567',
542
- '+84 23 61234567']
593
+ '+84 23 61234567',
594
+ '+84 1900 1212',
595
+ '+84 1900 541234']
543
596
  it_is_correct_for 'Yemen', :samples => [['+967 1 234 567', '+967 1 234 5678'],
544
597
  '+967 7 234 567',
545
598
  '+967 77 123 4567',
546
599
  '+967 58 1234']
547
600
  it 'is correct for Zambia' do
548
601
  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
602
+ Phony.plausible?('+260 96 512 4567').should be_truthy # MTN Mobile
603
+ Phony.plausible?('+260 97 712 3456').should be_truthy # Airtel Mobile
604
+ Phony.plausible?('+260 95 512 4567').should be_truthy # Zamtel Mobile
605
+ Phony.plausible?('+260 96 512 456').should be_falsy # MTN Mobile (Too short)
606
+ Phony.plausible?('+260 97 812 345').should be_falsy # Airtel Mobile (Too short)
607
+ Phony.plausible?('+260 95 512 345').should be_falsy # Zamtel Mobile (Too short)
552
608
  Phony.plausible?('+260 800 123 456').should be_truthy # Toll free
553
609
  end
554
610
  it_is_correct_for 'Zimbabwe', :samples => [['+263 2582 123 456', '+263 2582 123'],
@@ -564,6 +620,29 @@ describe 'plausibility' do
564
620
  Phony.plausible?('+62 22 000 000 000').should be_truthy
565
621
  end
566
622
 
623
+ it 'is correct for Italy' do
624
+ Phony.plausible?('+39 0574 123').should be_falsy
625
+ Phony.plausible?('+39 0574 1234').should be_truthy
626
+ Phony.plausible?('+39 0574 12345').should be_falsy
627
+
628
+ Phony.plausible?('+39 085 541').should be_falsy
629
+ Phony.plausible?('+39 085 5410').should be_truthy
630
+ Phony.plausible?('+39 085 54105').should be_truthy
631
+
632
+ Phony.plausible?('+39 06 4991').should be_falsy
633
+ Phony.plausible?('+39 06 49911').should be_truthy
634
+ Phony.plausible?('+39 06 499112').should be_truthy
635
+
636
+ Phony.plausible?('+39 800 081631').should be_truthy
637
+ Phony.plausible?('+39 800 0816311').should be_falsy
638
+
639
+ Phony.plausible?('+39 803 08163').should be_falsy
640
+ Phony.plausible?('+39 803 081').should be_truthy
641
+
642
+ Phony.plausible?('+39 06 8323074181').should be_falsy
643
+ Phony.plausible?('+39 06 832307418').should be_truthy
644
+ end
645
+
567
646
  it 'is correct for Russia' do
568
647
  Phony.plausible?('+7 3522 000 000').should be_truthy
569
648
  end
@@ -598,6 +677,12 @@ describe 'plausibility' do
598
677
  Phony.plausible?('+81 120 123 123').should be_truthy
599
678
  Phony.plausible?('+81 800 123 1234').should be_truthy
600
679
  end
680
+
681
+ it 'is correct for Philippine' do
682
+ Phony.plausible?('+63 2 89889999').should be_truthy
683
+ Phony.plausible?('+63 976 1234567').should be_truthy # mobile phone with area code 9
684
+ Phony.plausible?('+63 876 1234567').should be_truthy # mobile phone with area code 8
685
+ end
601
686
  end
602
687
  end
603
688
  end