phony 2.19.2 → 2.20.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,12 +12,12 @@ describe Phony::Country do
12
12
  end
13
13
  describe '#clean' do
14
14
  it 'cleans the number' do
15
- country.clean('+41-44-123-12-12').should eql '41441231212'
15
+ expect(country.clean('+41-44-123-12-12')).to eq '41441231212'
16
16
  end
17
17
  end
18
18
  describe '#vanity_to_number' do
19
19
  it 'turns the vanity number into a number' do
20
- country.vanity_to_number('1-800-HELLO').should eql '1-800-43556'
20
+ expect(country.vanity_to_number('1-800-HELLO')).to eq '1-800-43556'
21
21
  end
22
22
  end
23
23
  end
@@ -32,27 +32,27 @@ describe Phony::Country do
32
32
  described_class.new national_code
33
33
  end
34
34
  it 'splits correctly' do
35
- country.split('112').should == [nil, false, '112']
35
+ expect(country.split('112')).to eq [nil, false, '112']
36
36
  end
37
37
  end
38
38
  describe 'San Marino' do
39
39
  it 'normalizes correctly' do
40
- Phony.normalize('+3780549903549').should == '3780549903549'
40
+ expect(Phony.normalize('+3780549903549')).to eq '3780549903549'
41
41
  end
42
42
  xit 'automatically adds the sole NC' do
43
- Phony.normalize('+378903549').should == '3780549903549'
43
+ expect(Phony.normalize('+378903549')).to eq '3780549903549'
44
44
  end
45
45
  end
46
46
  describe 'Japan' do
47
47
  it 'normalizes correctly' do
48
- Phony.normalize('+81-03-1234-5634').should == '81312345634'
49
- Phony.normalize('03-1234-5634', cc: '81').should == '81312345634'
48
+ expect(Phony.normalize('+81-03-1234-5634')).to eq '81312345634'
49
+ expect(Phony.normalize('03-1234-5634', cc: '81')).to eq '81312345634'
50
50
  end
51
51
  it 'formats correctly' do
52
- Phony.format('81312345634').should == '+81-3-1234-5634'
52
+ expect(Phony.format('81312345634')).to eq '+81-3-1234-5634'
53
53
  end
54
54
  it 'splits correctly' do
55
- Phony.split('81312345634').should == %w(81 3 1234 5634)
55
+ expect(Phony.split('81312345634')).to eq %w(81 3 1234 5634)
56
56
  end
57
57
  end
58
58
  end
@@ -68,12 +68,12 @@ describe Phony::Country do
68
68
 
69
69
  describe "split" do
70
70
  it "should handle ZH" do
71
- country.split('443643532').should == [nil, '44', '364', '35', '32']
71
+ expect(country.split('443643532')).to eq [nil, '44', '364', '35', '32']
72
72
  end
73
73
  end
74
74
  describe 'normalize' do
75
75
  it "should handle ZH" do
76
- country.normalize('0443643532').should == '443643532'
76
+ expect(country.normalize('0443643532')).to eq '443643532'
77
77
  end
78
78
  end
79
79
  end
@@ -93,10 +93,10 @@ describe Phony::Country do
93
93
 
94
94
  describe "split" do
95
95
  it "should handle ZH" do
96
- country.split('443643532').should == [nil, '44', '364', '35', '32']
96
+ expect(country.split('443643532')).to eq [nil, '44', '364', '35', '32']
97
97
  end
98
98
  it "should handle 800" do
99
- country.split('800333666').should == [nil, '800', '333', '666']
99
+ expect(country.split('800333666')).to eq [nil, '800', '333', '666']
100
100
  end
101
101
  end
102
102
  end
@@ -7,9 +7,13 @@ describe Phony::DSL do
7
7
  let(:dsl) { described_class.new }
8
8
 
9
9
  it 'has a todo' do
10
+ result = nil
11
+
10
12
  Phony.define do
11
- todo.split("123456789012345").should == [nil, false, '123456789012345']
13
+ result = todo.split("123456789012345")
12
14
  end
15
+
16
+ expect(result).to eq [nil, false, '123456789012345']
13
17
  end
14
18
 
15
19
  describe 'match' do
@@ -17,7 +21,7 @@ describe Phony::DSL do
17
21
  expect { dsl.match(/123/) }.to raise_error("Regexp /123/ needs a group in it that defines which digits belong to the NDC.")
18
22
  end
19
23
  it 'should return a Phony::NationalSplitters::Regex' do
20
- dsl.match(/(123)/).class.name.should == Phony::NationalSplitters::Regex.name
24
+ expect(dsl.match(/(123)/).class.name).to eq Phony::NationalSplitters::Regex.name
21
25
  end
22
26
  end
23
27
 
@@ -16,40 +16,37 @@ describe Phony::LocalSplitters::Regex do
16
16
  end
17
17
 
18
18
  describe 'split' do
19
- before(:each) do
20
- # Norway as example.
21
- #
22
- @splitter = described_class.instance_for(/^[489].*$/ => [3,2,3], :fallback => [2,2,2,2])
23
- end
19
+ # Norway.
20
+ let(:splitter) { described_class.instance_for(/^[489].*$/ => [3,2,3], :fallback => [2,2,2,2]) }
24
21
  it 'splits a number correctly' do
25
- @splitter.split('21234567').should == ['21','23','45','67']
22
+ expect(splitter.split('21234567')).to eq ['21','23','45','67']
26
23
  end
27
24
  it 'splits a number correctly' do
28
- @splitter.split('31234567').should == ['31','23','45','67']
25
+ expect(splitter.split('31234567')).to eq ['31','23','45','67']
29
26
  end
30
27
  it 'splits a number correctly' do
31
- @splitter.split('41234567').should == ['412','34','567']
28
+ expect(splitter.split('41234567')).to eq ['412','34','567']
32
29
  end
33
30
  it 'splits a number correctly' do
34
- @splitter.split('51234567').should == ['51','23','45','67']
31
+ expect(splitter.split('51234567')).to eq ['51','23','45','67']
35
32
  end
36
33
  it 'splits a number correctly' do
37
- @splitter.split('61234567').should == ['61','23','45','67']
34
+ expect(splitter.split('61234567')).to eq ['61','23','45','67']
38
35
  end
39
36
  it 'splits a number correctly' do
40
- @splitter.split('71234567').should == ['71','23','45','67']
37
+ expect(splitter.split('71234567')).to eq ['71','23','45','67']
41
38
  end
42
39
  it 'splits a number correctly' do
43
- @splitter.split('81234567').should == ['812','34','567']
40
+ expect(splitter.split('81234567')).to eq ['812','34','567']
44
41
  end
45
42
  it 'splits a number correctly' do
46
- @splitter.split('91234567').should == ['912','34','567']
43
+ expect(splitter.split('91234567')).to eq ['912','34','567']
47
44
  end
48
45
  it 'splits it fast' do
49
- performance_of { @splitter.split('21234567').should == ['21','23','45','67'] }.should < 0.00005
46
+ expect(performance_of { splitter.split('21234567') }).to be < 0.00005
50
47
  end
51
48
  it 'splits it fast' do
52
- performance_of { @splitter.split('91234567').should == ['912','34','567'] }.should < 0.00004
49
+ expect(performance_of { splitter.split('91234567') }).to be < 0.00004
53
50
  end
54
51
  end
55
52
 
@@ -5,87 +5,57 @@ describe Phony::NationalCode do
5
5
  describe 'split' do
6
6
  context 'regression' do
7
7
  describe 'iceland' do
8
- before(:each) do
8
+ let(:national) do
9
9
  national_splitter = Phony::NationalSplitters::None.instance_for
10
10
  local_splitter = Phony::LocalSplitters::Fixed.instance_for [3, 4]
11
11
 
12
- @national = Phony::NationalCode.new national_splitter, local_splitter
12
+ Phony::NationalCode.new national_splitter, local_splitter
13
13
  end
14
14
  it 'splits correctly' do
15
- @national.split('112').should == [nil, false, '112']
15
+ expect(national.split('112')).to eq [nil, false, '112']
16
16
  end
17
17
  end
18
18
  end
19
19
  context 'with fixed ndc (Swiss)' do
20
- before(:each) do
20
+ let(:national) do
21
21
  national_splitter = Phony::NationalSplitters::Fixed.instance_for 2
22
22
  local_splitter = Phony::LocalSplitters::Fixed.instance_for [3, 2, 2]
23
23
 
24
- @national = Phony::NationalCode.new national_splitter, local_splitter
24
+ Phony::NationalCode.new national_splitter, local_splitter
25
25
  end
26
26
  it 'splits correctly' do
27
- @national.split('443643532').should == [nil, '44', '364', '35', '32']
27
+ expect(national.split('443643532')).to eq [nil, '44', '364', '35', '32']
28
28
  end
29
29
  it 'splits correctly' do
30
- @national.split('44364353').should == [nil, '44', '364', '35', '3']
30
+ expect(national.split('44364353')).to eq [nil, '44', '364', '35', '3']
31
31
  end
32
32
  it 'normalizes correctly' do
33
- @national.normalize('044364353').should == '44364353'
33
+ expect(national.normalize('044364353')).to eq '44364353'
34
34
  end
35
35
  it 'normalizes correctly' do
36
- @national.normalize('44364353').should == '44364353'
36
+ expect(national.normalize('44364353')).to eq '44364353'
37
37
  end
38
38
  end
39
39
  context 'with fixed ndc (French)' do
40
- before(:each) do
40
+ let(:national) do
41
41
  national_splitter = Phony::NationalSplitters::Fixed.instance_for 1
42
42
  local_splitter = Phony::LocalSplitters::Fixed.instance_for [2, 2, 2, 2]
43
43
 
44
- @national = Phony::NationalCode.new national_splitter, local_splitter
44
+ Phony::NationalCode.new national_splitter, local_splitter
45
45
  end
46
46
  it 'splits correctly' do
47
- @national.split('142278186').should == [nil, '1', '42', '27', '81', '86']
47
+ expect(national.split('142278186')).to eq [nil, '1', '42', '27', '81', '86']
48
48
  end
49
49
  it 'splits correctly' do
50
- @national.split('14227818').should == [nil, '1', '42', '27', '81', '8']
50
+ expect(national.split('14227818')).to eq [nil, '1', '42', '27', '81', '8']
51
51
  end
52
52
  it 'normalizes correctly' do
53
- @national.normalize('0142278186').should == '142278186'
53
+ expect(national.normalize('0142278186')).to eq '142278186'
54
54
  end
55
55
  it 'normalizes correctly' do
56
- @national.normalize('142278186').should == '142278186'
56
+ expect(national.normalize('142278186')).to eq '142278186'
57
57
  end
58
58
  end
59
- # context 'normalizing' do
60
- # context 'false' do
61
- # before(:each) do
62
- # @national = Phony::NationalCode.new nil, nil, false
63
- # end
64
- # it 'normalizes an italian case correctly' do
65
- # @national.normalize('0909709511').should == '0909709511'
66
- # end
67
- # end
68
- # context 'true' do
69
- # before(:each) do
70
- # national_splitter = Phony::NationalSplitters::Fixed.instance_for 2
71
- # local_splitter = Phony::LocalSplitters::Fixed.instance_for [3, 2, 2]
72
- # @national = Phony::NationalCode.new national_splitter, local_splitter, true
73
- # end
74
- # it 'normalizes a swiss case correctly' do
75
- # @national.normalize('044364353').should == '44364353'
76
- # end
77
- # end
78
- # context 'nil (true)' do
79
- # before(:each) do
80
- # national_splitter = Phony::NationalSplitters::Fixed.instance_for 2
81
- # local_splitter = Phony::LocalSplitters::Fixed.instance_for [3, 2, 2]
82
- # @national = Phony::NationalCode.new national_splitter, local_splitter, nil
83
- # end
84
- # it 'normalizes a swiss case correctly' do
85
- # @national.normalize('044364353').should == '44364353'
86
- # end
87
- # end
88
- # end
89
59
  end
90
60
 
91
61
  end
@@ -4,45 +4,41 @@ describe Phony::NationalSplitters::Fixed do
4
4
 
5
5
  describe 'instance_for' do
6
6
  it 'caches' do
7
- Phony::NationalSplitters::Fixed.instance_for(3).should equal(Phony::NationalSplitters::Fixed.instance_for(3))
7
+ expect(Phony::NationalSplitters::Fixed.instance_for(3)).to eq Phony::NationalSplitters::Fixed.instance_for(3)
8
8
  end
9
9
  it 'caches correctly' do
10
- Phony::NationalSplitters::Fixed.instance_for(1).should_not equal(Phony::NationalSplitters::Fixed.instance_for(2))
10
+ expect(Phony::NationalSplitters::Fixed.instance_for(1)).to_not eq Phony::NationalSplitters::Fixed.instance_for(2)
11
11
  end
12
12
  end
13
13
 
14
14
  describe 'split' do
15
- before(:each) do
16
- @splitter = Phony::NationalSplitters::Fixed.new 2
17
- end
15
+ let(:splitter) { Phony::NationalSplitters::Fixed.new(2) }
18
16
  it 'splits correctly' do
19
- @splitter.split('443643532').should == [nil, '44', '3643532']
17
+ expect(splitter.split('443643532')).to eq [nil, '44', '3643532']
20
18
  end
21
19
  it 'splits correctly even when the number is too long' do
22
- @splitter.split('44364353211').should == [nil, '44', '364353211']
20
+ expect(splitter.split('44364353211')).to eq [nil, '44', '364353211']
23
21
  end
24
22
  it 'splits correctly even when the number is too short' do
25
- @splitter.split('443').should == [nil, '44','3']
23
+ expect(splitter.split('443')).to eq [nil, '44','3']
26
24
  end
27
25
  it 'has a length of 2' do
28
- @splitter.length.should == 2
26
+ expect(splitter.length).to eq 2
29
27
  end
30
28
  end
31
29
  describe 'split' do
32
- before(:each) do
33
- @splitter = Phony::NationalSplitters::Fixed.new nil
34
- end
30
+ let(:splitter) { Phony::NationalSplitters::Fixed.new(nil) }
35
31
  it 'splits correctly' do
36
- @splitter.split('443643532').should == [nil, '443643532']
32
+ expect(splitter.split('443643532')).to eq [nil, '443643532']
37
33
  end
38
34
  it 'splits correctly even when the number is too long' do
39
- @splitter.split('44364353211').should == [nil, '44364353211']
35
+ expect(splitter.split('44364353211')).to eq [nil, '44364353211']
40
36
  end
41
37
  it 'splits correctly even when the number is too short' do
42
- @splitter.split('443').should == [nil, '443']
38
+ expect(splitter.split('443')).to eq [nil, '443']
43
39
  end
44
40
  it 'has a length of nil' do
45
- @splitter.length.should == nil
41
+ expect(splitter.length).to eq nil
46
42
  end
47
43
  end
48
44
 
@@ -4,7 +4,7 @@ describe Phony::NationalSplitters::None do
4
4
 
5
5
  describe 'instance_for' do
6
6
  it 'caches' do
7
- described_class.instance_for.should equal(described_class.instance_for)
7
+ expect(described_class.instance_for).to eq described_class.instance_for
8
8
  end
9
9
  end
10
10
 
@@ -13,13 +13,13 @@ describe Phony::NationalSplitters::None do
13
13
 
14
14
  describe 'split' do
15
15
  it 'splits correctly into ndc and rest' do
16
- splitter.split('123456789').should == [nil, false, '123456789']
16
+ expect(splitter.split('123456789')).to eq [nil, false, '123456789']
17
17
  end
18
18
  end
19
19
 
20
20
  describe 'length' do
21
21
  it 'is always 0' do
22
- splitter.length.should be_zero
22
+ expect(splitter.length).to be_zero
23
23
  end
24
24
  end
25
25
 
@@ -4,34 +4,30 @@ describe Phony::NationalSplitters::Variable do
4
4
 
5
5
  describe 'split' do
6
6
  context 'normal' do
7
- before(:each) do
8
- @splitter = Phony::NationalSplitters::Variable.new 4, ['1', '316', '67', '68', '669', '711']
9
- end
7
+ let(:splitter) { Phony::NationalSplitters::Variable.new 4, ['1', '316', '67', '68', '669', '711'] }
10
8
  it "handles Vienna" do
11
- @splitter.split('198110').should == [nil, '1', '98110']
9
+ expect(splitter.split('198110')).to eq [nil, '1', '98110']
12
10
  end
13
11
  it "handles some mobile services" do
14
- @splitter.split('66914093902').should == [nil, '669', '14093902']
12
+ expect(splitter.split('66914093902')).to eq [nil, '669', '14093902']
15
13
  end
16
14
  it "handles Graz" do
17
- @splitter.split('3161234567891').should == [nil, '316', '1234567891']
15
+ expect(splitter.split('3161234567891')).to eq [nil, '316', '1234567891']
18
16
  end
19
17
  it "handles Rohrau" do
20
- @splitter.split('2164123456789').should == [nil, '2164', '123456789']
18
+ expect(splitter.split('2164123456789')).to eq [nil, '2164', '123456789']
21
19
  end
22
20
  it 'has an NDC length of 3' do
23
- @splitter.length.should == (1..3)
21
+ expect(splitter.length).to eq (1..3)
24
22
  end
25
23
  end
26
24
  context 'special handling for using the variable size splitter for Swiss service numbers' do
27
- before(:each) do
28
- @splitter = Phony::NationalSplitters::Variable.new 2, ['800']
29
- end
25
+ let(:splitter) { Phony::NationalSplitters::Variable.new 2, ['800'] }
30
26
  it "should handle swiss service numbers" do
31
- @splitter.split('800223344').should == [nil, '800', '223344']
27
+ expect(splitter.split('800223344')).to eq [nil, '800', '223344']
32
28
  end
33
29
  it 'has an NDC length of 3' do
34
- @splitter.length.should == (3..3)
30
+ expect(splitter.length).to eq (3..3)
35
31
  end
36
32
  end
37
33
  end
@@ -8,22 +8,22 @@ describe Phony::Vanity do
8
8
 
9
9
  describe '.replace' do
10
10
  it 'replaces letters with digits' do
11
- vanity.replace('1-800-HELLO').should == '1-800-43556'
11
+ expect(vanity.replace('1-800-HELLO')).to eq '1-800-43556'
12
12
  end
13
13
  end
14
14
 
15
15
  describe '.vanity?' do
16
16
  it 'returns true on a vanity number' do
17
- vanity.vanity?('800HELLOES').should == true
17
+ expect(vanity.vanity?('800HELLOES')).to eq true
18
18
  end
19
19
  it 'returns false on a non-vanity number' do
20
- vanity.vanity?('8004355637').should == false
20
+ expect(vanity.vanity?('8004355637')).to eq false
21
21
  end
22
22
  end
23
23
 
24
24
  describe '.normalized' do
25
25
  it 'normalizes the vanity number' do
26
- vanity.normalized('1-800-HELLO').should == '1800HELLO'
26
+ expect(vanity.normalized('1-800-HELLO')).to eq '1800HELLO'
27
27
  end
28
28
  end
29
29
 
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.19.2
4
+ version: 2.20.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-05 00:00:00.000000000 Z
11
+ date: 2024-01-22 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
@@ -115,26 +115,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.0.3
118
+ rubygems_version: 3.4.19
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Fast international phone number (E164 standard) normalizing, splitting and
122
122
  formatting.
123
123
  test_files:
124
- - spec/lib/phony_spec.rb
125
- - spec/lib/phony/trunk_code_spec.rb
126
- - spec/lib/phony/country_spec.rb
127
- - spec/lib/phony/national_code_spec.rb
124
+ - spec/functional/config_spec.rb
125
+ - spec/functional/plausibility_spec.rb
128
126
  - spec/lib/phony/countries_spec.rb
127
+ - spec/lib/phony/country_codes_spec.rb
128
+ - spec/lib/phony/country_spec.rb
129
129
  - spec/lib/phony/dsl_spec.rb
130
- - spec/lib/phony/national_splitters/variable_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
131
135
  - spec/lib/phony/national_splitters/none_spec.rb
132
136
  - spec/lib/phony/national_splitters/regex_spec.rb
133
- - spec/lib/phony/national_splitters/fixed_spec.rb
134
- - spec/lib/phony/national_splitters/default_spec.rb
135
- - spec/lib/phony/country_codes_spec.rb
136
- - spec/lib/phony/local_splitters/regex_spec.rb
137
- - spec/lib/phony/local_splitters/fixed_spec.rb
137
+ - spec/lib/phony/national_splitters/variable_spec.rb
138
+ - spec/lib/phony/trunk_code_spec.rb
138
139
  - spec/lib/phony/vanity_spec.rb
139
- - spec/functional/config_spec.rb
140
- - spec/functional/plausibility_spec.rb
140
+ - spec/lib/phony_spec.rb