Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/phone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def format(fmt)

# the default format is "+%c%a%n"
def to_s
format(:default)
extension.nil? ? format(:default) : format(:default_with_extension)
end

# does this number belong to the default country code?
Expand Down
6 changes: 6 additions & 0 deletions test/phone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def test_to_s
assert pn.to_s == '+385915125486'
end

def test_to_s_with_extension
Phoner::Phone.default_country_code = nil
pn = Phoner::Phone.new '5125486', '91', '385', '111'
assert pn.to_s == '+385915125486x111'
end

def test_to_s_without_country_code
Phoner::Phone.default_country_code = '385'
pn = Phoner::Phone.new '5125486', '91'
Expand Down