Skip to content

Commit

Permalink
+ closes floere#39, + US formatted using format :national does not pr…
Browse files Browse the repository at this point in the history
…efix a 0 anymore
  • Loading branch information
floere committed May 17, 2012
1 parent e8d17ae commit 0481660
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions spec/lib/phony/country_codes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end
it 'formats correctly' do
old_format = @countries.international_absolute_format
@countries.international_absolute_format = '!!! %s%s%s%s'
@countries.international_absolute_format = '!!! %s%s%s'

@countries.formatted('41443643532', :format => :international).should == '!!! 41 44 364 35 32'

Expand All @@ -25,7 +25,7 @@
end
it 'formats correctly' do
old_format = @countries.international_relative_format
@countries.international_relative_format = '000 %s%s%s%s'
@countries.international_relative_format = '000 %s%s%s'

@countries.formatted('41443643532', :format => :international_relative).should == '000 41 44 364 35 32'

Expand All @@ -48,7 +48,7 @@

describe 'split' do
it 'splits correctly' do
@countries.split('41443643532').should == ['41', '44', '364', '35', '32']
@countries.split('41443643532').should == ['41', '0', '44', '364', '35', '32']
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/lib/phony/country_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@iceland = described_class.new national_code
end
it 'splits correctly' do
@iceland.split('112').should == ['112']
@iceland.split('112').should == [nil, nil, '112']
end
end
end
Expand All @@ -28,7 +28,7 @@

describe "split" do
it "should handle ZH" do
@switzerland.split('443643532').should == ['44', '364', '35', '32']
@switzerland.split('443643532').should == ['0', '44', '364', '35', '32']
end
end
describe 'normalize' do
Expand All @@ -53,10 +53,10 @@

describe "split" do
it "should handle ZH" do
@switzerland.split('443643532').should == ['44', '364', '35', '32']
@switzerland.split('443643532').should == ['0', '44', '364', '35', '32']
end
it "should handle 800" do
@switzerland.split('800333666').should == ['800', '333', '666']
@switzerland.split('800333666').should == ['0', '800', '333', '666']
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/phony/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

it 'has a todo' do
Phony.define do
todo.split("123456789012345").should == ["123456789012345"]
todo.split("123456789012345").should == [nil, nil, nil, nil, '123456789012345']
end
end

Expand Down
10 changes: 5 additions & 5 deletions spec/lib/phony/national_code_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@national = Phony::NationalCode.new national_splitter, local_splitter
end
it 'splits correctly' do
@national.split('112').should == [nil, '112']
@national.split('112').should == [nil, nil, '112']
end
end
end
Expand All @@ -24,10 +24,10 @@
@national = Phony::NationalCode.new national_splitter, local_splitter
end
it 'splits correctly' do
@national.split('443643532').should == ['44', '364', '35', '32']
@national.split('443643532').should == ['0', '44', '364', '35', '32']
end
it 'splits correctly' do
@national.split('44364353').should == ['44', '364', '35', '3']
@national.split('44364353').should == ['0', '44', '364', '35', '3']
end
it 'normalizes correctly' do
@national.normalize('044364353').should == '44364353'
Expand All @@ -44,10 +44,10 @@
@national = Phony::NationalCode.new national_splitter, local_splitter
end
it 'splits correctly' do
@national.split('142278186').should == ['1', '42', '27', '81', '86']
@national.split('142278186').should == ['0', '1', '42', '27', '81', '86']
end
it 'splits correctly' do
@national.split('14227818').should == ['1', '42', '27', '81', '8']
@national.split('14227818').should == ['0', '1', '42', '27', '81', '8']
end
it 'normalizes correctly' do
@national.normalize('0142278186').should == '142278186'
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/phony/national_splitters/fixed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
@splitter = Phony::NationalSplitters::Fixed.new 2
end
it 'splits correctly' do
@splitter.split('443643532').should == ['44', '3643532']
@splitter.split('443643532').should == ['0', '44', '3643532']
end
it 'splits correctly even when the number is too long' do
@splitter.split('44364353211').should == ['44', '364353211']
@splitter.split('44364353211').should == ['0', '44', '364353211']
end
it 'splits correctly even when the number is too short' do
@splitter.split('443').should == ['44','3']
@splitter.split('443').should == ['0', '44','3']
end
end
describe 'split' do
before(:each) do
@splitter = Phony::NationalSplitters::Fixed.new nil
end
it 'splits correctly' do
@splitter.split('443643532').should == ['443643532']
@splitter.split('443643532').should == ['0', '443643532']
end
it 'splits correctly even when the number is too long' do
@splitter.split('44364353211').should == ['44364353211']
@splitter.split('44364353211').should == ['0', '44364353211']
end
it 'splits correctly even when the number is too short' do
@splitter.split('443').should == ['443']
@splitter.split('443').should == ['0', '443']
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/phony/national_splitters/none_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
describe 'split' do
let(:splitter) { described_class.instance_for }
it 'splits correctly into ndc and rest' do
splitter.split('123456789').should == [nil, '123456789']
splitter.split('123456789').should == [nil, nil, '123456789']
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/phony/national_splitters/regex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
context 'with on_fail 2' do
let(:splitter) { described_class.instance_for(/^(123)\d+$/, 2) }
it 'uses the on_fail_take' do
splitter.split('23456789').should == ['23', '456789']
splitter.split('23456789').should == ['0', '23', '456789']
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/phony/national_splitters/variable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
@splitter = Phony::NationalSplitters::Variable.new 4, ['1', '316', '67', '68', '669', '711']
end
it "handles Vienna" do
@splitter.split('198110').should == ['1', '98110']
@splitter.split('198110').should == ['0', '1', '98110']
end
it "handles some mobile services" do
@splitter.split('66914093902').should == ['669', '14093902']
@splitter.split('66914093902').should == ['0', '669', '14093902']
end
it "handles Graz" do
@splitter.split('3161234567891').should == ['316', '1234567891']
@splitter.split('3161234567891').should == ['0', '316', '1234567891']
end
it "handles Rohrau" do
@splitter.split('2164123456789').should == ['2164', '123456789']
@splitter.split('2164123456789').should == ['0', '2164', '123456789']
end
end
context 'special handling for using the variable size splitter for Swiss service numbers' do
before(:each) do
@splitter = Phony::NationalSplitters::Variable.new 2, ['800']
end
it "should handle swiss service numbers" do
@splitter.split('800223344').should == ['800', '223344']
@splitter.split('800223344').should == ['0', '800', '223344']
end
end
end
Expand Down

0 comments on commit 0481660

Please sign in to comment.