From ec283f66575e5ffb9de290357435a3f4c00678b3 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Mon, 11 Mar 2024 20:17:55 +0530 Subject: [PATCH] fix: specs --- app/helpers/contact_helper.rb | 2 +- spec/helpers/contact_helper_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/contact_helper.rb b/app/helpers/contact_helper.rb index 2bd86937f..1944d62d3 100644 --- a/app/helpers/contact_helper.rb +++ b/app/helpers/contact_helper.rb @@ -31,7 +31,7 @@ module ContactHelper end def valid_number?(full_name) - full_name.gsub(/\s+/, '').match?(/\A\+?\d+\z/) + TelephoneNumber.parse(full_name).valid? end def single_word_name_hash(full_name) diff --git a/spec/helpers/contact_helper_spec.rb b/spec/helpers/contact_helper_spec.rb index 41953fb8d..c4f271e4b 100644 --- a/spec/helpers/contact_helper_spec.rb +++ b/spec/helpers/contact_helper_spec.rb @@ -63,8 +63,8 @@ RSpec.describe ContactHelper do end it 'handle name with mobile number with spaces correctly' do - full_name = '+1 234 567 890' - expected_result = { first_name: '+1 234 567 890', last_name: nil, middle_name: nil, prefix: nil, suffix: nil } + full_name = '+1 423-423-4234' + expected_result = { first_name: '+1 423-423-4234', last_name: nil, middle_name: nil, prefix: nil, suffix: nil } expect(helper.parse_name(full_name)).to eq(expected_result) end