Permalink
Browse files

Respect :spaces when removing trailing space(s)

  • Loading branch information...
1 parent 3851473 commit d0d9a835e7dba031b87d006f9e4ed5d627bbc6e4 @mrchucho committed Jul 15, 2011
Showing with 4 additions and 1 deletion.
  1. +1 −1 lib/phony/country_codes.rb
  2. +3 −0 spec/lib/phony_spec.rb
@@ -46,7 +46,7 @@ def format_cc_ndc_local format, space, cc, ndc, *parts
cc_ndc = format_cc_ndc(format, space, cc, ndc)
local = \
if parts.empty?
- cc_ndc = cc_ndc.slice(0...cc_ndc.size-1)
+ cc_ndc = cc_ndc.slice(0...cc_ndc.rindex(space.to_s))
EMPTY_STRING
else
format_local(space, parts) unless parts.empty?
@@ -137,6 +137,9 @@
it 'should format as a single block, respecting custom spaces' do
Phony.format('8801819372205', :spaces => :-).should == '+880-1819372205'
end
+ it 'should format as a single block, even without spaces' do
+ Phony.format('8801819372205', :spaces => '').should == '+8801819372205'
+ end
end
end
describe "national" do

0 comments on commit d0d9a83

Please sign in to comment.