Skip to content

Faker::Internet.password method doesn't add numbers anymore #2704

Description

Describe the bug

The docs and comments suggest numbers are included, but looking at the source code it only includes lowercase, uppercase, and symbols.

To Reproduce

Describe a way to reproduce your bug. To get the Faker version, run Faker::VERSION.

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 BugTest < Minitest::Test
  def test_faker

    result = Faker::Internet.password(min_length: 8, mix_case: true)

    assert result.match(/[0-9]+/)  # returns nil if no matches
  end
end

Expected behavior

I would expect that you are guaranteed to have a number for all permutations, or that there is an extra parameter to ensure numbers are included

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