Skip to content

Random Test Failure: Faker::Omniauth tests fail when generating a name with an apostrophe #2943

@alextaujenis

Description

@alextaujenis

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:

  1. Locate the test file test/faker/default/test_faker_omniauth.rb.
  2. Provide a name with an apostrophe such as: Faker::Omniauth.linkedin(name: "Alexis O'Connell")
  3. 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
end

Expected 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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions