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
data/lib/phony.rb CHANGED
@@ -1,81 +1,80 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # NOTE We use Kernel.load here, as it's possible to redefine Phony via Phony::Config.
3
+ # NOTE: We use Kernel.load here, as it's possible to redefine Phony via Phony::Config.
4
4
 
5
5
  # Framework.
6
6
  #
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__
7
+ load File.expand_path 'phony/config.rb', __dir__
8
+ load File.expand_path 'phony/vanity.rb', __dir__
9
+ load File.expand_path 'phony/local_splitters/fixed.rb', __dir__
10
+ load File.expand_path 'phony/local_splitters/regex.rb', __dir__
11
+ load File.expand_path 'phony/national_splitters/dsl.rb', __dir__
12
+ load File.expand_path 'phony/national_splitters/fixed.rb', __dir__
13
+ load File.expand_path 'phony/national_splitters/variable.rb', __dir__
14
+ load File.expand_path 'phony/national_splitters/regex.rb', __dir__
15
+ load File.expand_path 'phony/national_splitters/default.rb', __dir__
16
+ load File.expand_path 'phony/national_splitters/none.rb', __dir__
17
+ load File.expand_path 'phony/national_code.rb', __dir__
18
+ load File.expand_path 'phony/country.rb', __dir__
19
+ load File.expand_path 'phony/trunk_code.rb', __dir__
20
+ load File.expand_path 'phony/country_codes.rb', __dir__
21
+ load File.expand_path 'phony/dsl.rb', __dir__
22
22
 
23
23
  # Countries.
24
24
  #
25
25
  # The ones that need more space to define.
26
26
  #
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__
27
+ load File.expand_path 'phony/countries/argentina.rb', __dir__
28
+ load File.expand_path 'phony/countries/austria.rb', __dir__
29
+ load File.expand_path 'phony/countries/bangladesh.rb', __dir__
30
+ load File.expand_path 'phony/countries/belarus.rb', __dir__
31
+ load File.expand_path 'phony/countries/brazil.rb', __dir__
32
+ load File.expand_path 'phony/countries/cambodia.rb', __dir__
33
+ load File.expand_path 'phony/countries/croatia.rb', __dir__
34
+ load File.expand_path 'phony/countries/china.rb', __dir__
35
+ load File.expand_path 'phony/countries/georgia.rb', __dir__
36
+ load File.expand_path 'phony/countries/germany.rb', __dir__
37
+ load File.expand_path 'phony/countries/guinea.rb', __dir__
38
+ load File.expand_path 'phony/countries/india.rb', __dir__
39
+ load File.expand_path 'phony/countries/indonesia.rb', __dir__
40
+ load File.expand_path 'phony/countries/ireland.rb', __dir__
41
+ load File.expand_path 'phony/countries/italy.rb', __dir__
42
+ load File.expand_path 'phony/countries/japan.rb', __dir__
43
+ load File.expand_path 'phony/countries/kyrgyzstan.rb', __dir__
44
+ load File.expand_path 'phony/countries/latvia.rb', __dir__
45
+ load File.expand_path 'phony/countries/libya.rb', __dir__
46
+ load File.expand_path 'phony/countries/malaysia.rb', __dir__
47
+ load File.expand_path 'phony/countries/moldova.rb', __dir__
48
+ load File.expand_path 'phony/countries/montenegro.rb', __dir__
49
+ load File.expand_path 'phony/countries/myanmar.rb', __dir__
50
+ load File.expand_path 'phony/countries/namibia.rb', __dir__
51
+ load File.expand_path 'phony/countries/nepal.rb', __dir__
52
+ load File.expand_path 'phony/countries/netherlands.rb', __dir__
53
+ load File.expand_path 'phony/countries/pakistan.rb', __dir__
54
+ load File.expand_path 'phony/countries/paraguay.rb', __dir__
55
+ load File.expand_path 'phony/countries/russia_kazakhstan_abkhasia_south_ossetia.rb', __dir__
56
+ load File.expand_path 'phony/countries/saudi_arabia.rb', __dir__
57
+ load File.expand_path 'phony/countries/serbia.rb', __dir__
58
+ load File.expand_path 'phony/countries/somalia.rb', __dir__
59
+ load File.expand_path 'phony/countries/south_korea.rb', __dir__
60
+ load File.expand_path 'phony/countries/sweden.rb', __dir__
61
+ load File.expand_path 'phony/countries/taiwan.rb', __dir__
62
+ load File.expand_path 'phony/countries/tajikistan.rb', __dir__
63
+ load File.expand_path 'phony/countries/turkmenistan.rb', __dir__
64
+ load File.expand_path 'phony/countries/vietnam.rb', __dir__
65
+ load File.expand_path 'phony/countries/ukraine.rb', __dir__
66
+ load File.expand_path 'phony/countries/united_kingdom.rb', __dir__
67
+ load File.expand_path 'phony/countries/uruguay.rb', __dir__
68
+ load File.expand_path 'phony/countries/zimbabwe.rb', __dir__
69
69
 
70
70
  # All other countries.
71
71
  #
72
- load File.expand_path '../phony/countries.rb', __FILE__
72
+ load File.expand_path 'phony/countries.rb', __dir__
73
73
 
74
74
  # Phony is the main module and is generally used to process
75
75
  # E164 phone numbers directly.
76
76
  #
77
77
  module Phony
78
-
79
78
  # Raised in case Phony can't normalize a given number.
80
79
  #
81
80
  # @example
@@ -83,21 +82,21 @@ module Phony
83
82
  #
84
83
  class NormalizationError < ArgumentError
85
84
  def initialize
86
- super %Q{Phony could not normalize the given number. Is it a phone number?}
85
+ super(%(Phony could not normalize the given number. Is it a phone number?))
87
86
  end
88
87
  end
89
-
88
+
90
89
  # Raised in case Phony can't split a given number.
91
90
  #
92
91
  # @example
93
92
  # Phony.split("Fnork!") # Raises a Phony::SplittingError.
94
93
  #
95
94
  class SplittingError < ArgumentError
96
- def initialize number
97
- super %Q{Phony could not split the given number. Is #{(number.nil? || number == '') ? 'it' : number.inspect} a phone number?}
95
+ def initialize(number)
96
+ super(%(Phony could not split the given number. Is #{(number.nil? || number == '') ? 'it' : number.inspect} a phone number?))
98
97
  end
99
98
  end
100
-
99
+
101
100
  # Raised in case Phony can't format a given number.
102
101
  #
103
102
  # @example
@@ -105,7 +104,7 @@ module Phony
105
104
  #
106
105
  class FormattingError < ArgumentError
107
106
  def initialize
108
- super %Q{Phony could not format the given number. Is it a phone number?}
107
+ super(%(Phony could not format the given number. Is it a phone number?))
109
108
  end
110
109
  end
111
110
 
@@ -114,7 +113,6 @@ module Phony
114
113
  @codes = CountryCodes.instance
115
114
 
116
115
  class << self
117
-
118
116
  # Get the Country for the given CC.
119
117
  #
120
118
  # @param [String] cc A valid country code.
@@ -125,7 +123,7 @@ module Phony
125
123
  # nanp = Phony['1']
126
124
  # normalized_number = nanp.normalize number
127
125
  #
128
- def [] cc
126
+ def [](cc)
129
127
  @codes[cc]
130
128
  end
131
129
 
@@ -146,11 +144,12 @@ module Phony
146
144
  # @example Normalize a phone number assuming it's a NANP number.
147
145
  # Phony.normalize("301 555 0100", cc: '1') # => "13015550100"
148
146
  #
149
- def normalize phone_number, options = {}
150
- raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.normalize(number)." unless phone_number
151
-
147
+ def normalize(phone_number, options = {})
148
+ raise ArgumentError, 'Phone number cannot be nil. Use e.g. number && Phony.normalize(number).' unless phone_number
149
+
152
150
  normalize! phone_number.dup, options
153
151
  end
152
+
154
153
  # A destructive version of {#normalize}.
155
154
  #
156
155
  # @see #normalize
@@ -168,7 +167,7 @@ module Phony
168
167
  # @example Normalize a phone number assuming it's a NANP number.
169
168
  # Phony.normalize!("301 555 0100", cc: '1') # => "13015550100"
170
169
  #
171
- def normalize! phone_number, options = {}
170
+ def normalize!(phone_number, options = {})
172
171
  @codes.normalize phone_number, options
173
172
  rescue
174
173
  raise NormalizationError.new
@@ -188,11 +187,12 @@ module Phony
188
187
  # @example Split a NANP number.
189
188
  # Phony.split("13015550100") # => ["1", "301", "555", "0100"]
190
189
  #
191
- def split phone_number
192
- raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.split(number)." unless phone_number
193
-
190
+ def split(phone_number)
191
+ raise ArgumentError, 'Phone number cannot be nil. Use e.g. number && Phony.split(number).' unless phone_number
192
+
194
193
  split! phone_number.dup, phone_number
195
194
  end
195
+
196
196
  # A destructive version of {#split}.
197
197
  #
198
198
  # @see #split
@@ -207,7 +207,7 @@ module Phony
207
207
  # @example Split a NANP number.
208
208
  # Phony.split!("13015550100") # => ["1", "301", "555", "0100"]
209
209
  #
210
- def split! phone_number, error_number = nil
210
+ def split!(phone_number, error_number = nil)
211
211
  @codes.split phone_number
212
212
  rescue
213
213
  # NB The error_number (reference) is used because phone_number is destructively handled.
@@ -235,10 +235,12 @@ module Phony
235
235
  # @example Format a NANP number in a specific format.
236
236
  # Phony.format("13015550100", :format => '%{cc} (%{trunk}%{ndc}) %{local}') # => "555 0100"
237
237
  #
238
- def format phone_number, options = {}
239
- raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.format(number)." unless phone_number
238
+ def format(phone_number, options = {})
239
+ raise ArgumentError, 'Phone number cannot be nil. Use e.g. number && Phony.format(number).' unless phone_number
240
+
240
241
  format! phone_number.dup, options
241
242
  end
243
+
242
244
  # A destructive version of {#format}.
243
245
  #
244
246
  # @see #format
@@ -261,7 +263,7 @@ module Phony
261
263
  # @example Format a NANP number in local format.
262
264
  # Phony.format!("13015550100", :format => :local) # => "555 0100"
263
265
  #
264
- def format! phone_number, options = {}
266
+ def format!(phone_number, options = {})
265
267
  @codes.format phone_number, options
266
268
  rescue
267
269
  raise FormattingError.new
@@ -275,14 +277,14 @@ module Phony
275
277
  # If it returns true, it is unclear whether it is plausible,
276
278
  # leaning towards being plausible.
277
279
  #
278
- def plausible? number, hints = {}
280
+ def plausible?(number, hints = {})
279
281
  @codes.plausible? number, hints
280
282
  end
281
283
 
282
284
  # Returns true if there is a character in the number
283
285
  # after the first four numbers.
284
286
  #
285
- def vanity? phone_number
287
+ def vanity?(phone_number)
286
288
  @codes.vanity? phone_number.dup
287
289
  end
288
290
 
@@ -296,10 +298,8 @@ module Phony
296
298
  # @example De-vanitize a number.
297
299
  # Phony.vanity_to_number("1-800-HELLOTHERE") # => "1-800-4355684373"
298
300
  #
299
- def vanity_to_number vanity_number
301
+ def vanity_to_number(vanity_number)
300
302
  @codes.vanity_to_number vanity_number.dup
301
303
  end
302
-
303
304
  end
304
-
305
305
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.20.14
4
+ version: 2.20.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-10 00:00:00.000000000 Z
11
+ date: 2024-10-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Fast international phone number (E164 standard) normalizing, splitting
14
14
  and formatting. Lots of formatting options: International (+.., 00..), national
@@ -79,23 +79,6 @@ files:
79
79
  - lib/phony/national_splitters/variable.rb
80
80
  - lib/phony/trunk_code.rb
81
81
  - lib/phony/vanity.rb
82
- - spec/functional/config_spec.rb
83
- - spec/functional/plausibility_spec.rb
84
- - spec/lib/phony/countries_spec.rb
85
- - spec/lib/phony/country_codes_spec.rb
86
- - spec/lib/phony/country_spec.rb
87
- - spec/lib/phony/dsl_spec.rb
88
- - spec/lib/phony/local_splitters/fixed_spec.rb
89
- - spec/lib/phony/local_splitters/regex_spec.rb
90
- - spec/lib/phony/national_code_spec.rb
91
- - spec/lib/phony/national_splitters/default_spec.rb
92
- - spec/lib/phony/national_splitters/fixed_spec.rb
93
- - spec/lib/phony/national_splitters/none_spec.rb
94
- - spec/lib/phony/national_splitters/regex_spec.rb
95
- - spec/lib/phony/national_splitters/variable_spec.rb
96
- - spec/lib/phony/trunk_code_spec.rb
97
- - spec/lib/phony/vanity_spec.rb
98
- - spec/lib/phony_spec.rb
99
82
  homepage: https://github.com/floere/phony
100
83
  licenses:
101
84
  - MIT
@@ -108,33 +91,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
91
  requirements:
109
92
  - - ">="
110
93
  - !ruby/object:Gem::Version
111
- version: '0'
94
+ version: '2.7'
112
95
  required_rubygems_version: !ruby/object:Gem::Requirement
113
96
  requirements:
114
97
  - - ">="
115
98
  - !ruby/object:Gem::Version
116
99
  version: '0'
117
100
  requirements: []
118
- rubygems_version: 3.5.6
101
+ rubygems_version: 3.5.21
119
102
  signing_key:
120
103
  specification_version: 4
121
104
  summary: Fast international phone number (E164 standard) normalizing, splitting and
122
105
  formatting.
123
- test_files:
124
- - spec/functional/config_spec.rb
125
- - spec/functional/plausibility_spec.rb
126
- - spec/lib/phony/countries_spec.rb
127
- - spec/lib/phony/country_codes_spec.rb
128
- - spec/lib/phony/country_spec.rb
129
- - spec/lib/phony/dsl_spec.rb
130
- - spec/lib/phony/local_splitters/fixed_spec.rb
131
- - spec/lib/phony/local_splitters/regex_spec.rb
132
- - spec/lib/phony/national_code_spec.rb
133
- - spec/lib/phony/national_splitters/default_spec.rb
134
- - spec/lib/phony/national_splitters/fixed_spec.rb
135
- - spec/lib/phony/national_splitters/none_spec.rb
136
- - spec/lib/phony/national_splitters/regex_spec.rb
137
- - spec/lib/phony/national_splitters/variable_spec.rb
138
- - spec/lib/phony/trunk_code_spec.rb
139
- - spec/lib/phony/vanity_spec.rb
140
- - spec/lib/phony_spec.rb
106
+ test_files: []
@@ -1,44 +0,0 @@
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