-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Labels
Description
Describe The Bug
The Faker::Omniauth module sometimes initializes a last name with an apostrophe (such as O'Connell), which will generate an email address that fails the validation tests within TestFakerInternetOmniauth.
To Reproduce
With Faker v3.3.1:
- Locate the test file
test/faker/default/test_faker_omniauth.rb. - Provide a name with an apostrophe such as:
Faker::Omniauth.linkedin(name: "Alexis O'Connell") - Validate the returned omniauth email address with
def email_regex(first_name, last_name)(found within the test file, also below in the reproduction script).
Use the reproduction script below to reproduce the issue:
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main'
gem "minitest"
end
require "minitest/autorun"
class TestFakerInternetOmniauth < Minitest::Test
def test_omniauth_linkedin
@tester = Faker::Omniauth
auth = @tester.linkedin(name: "Alexis O'Connell")
info = auth[:info]
first_name = info[:first_name].downcase
last_name = info[:last_name].downcase
assert_match email_regex(first_name, last_name), info[:email]
end
def email_regex(first_name, last_name)
/(#{first_name}(.|_)#{last_name}|#{last_name}(.|_)#{first_name})@(.*).(example|test)/i
end
endExpected Behavior
The TestFakerInternetOmniauth tests should pass when generating an omniauth profile that includes an apostrophe in the name.
Additional Context
This email validation issue was mentioned in PR #2940 (review).
thdaraujo