lib/faker/default/internet.rb in faker-3.3.1 vs lib/faker/default/internet.rb in faker-3.4.1
- old
+ new
@@ -61,12 +61,15 @@
# Faker::Internet.username(specifier: 5..10) #=> "morris"
# Faker::Internet.username(specifier: 5..10) #=> "berryberry"
# Faker::Internet.username(specifier: 20, separators: ['_']) #=> "nikki_sawaynnikki_saway"
def username(specifier: nil, separators: %w[. _])
with_locale(:en) do
- return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan)
-
case specifier
+ when ::String
+ names = specifier&.gsub("'", '')&.split
+ shuffled_names = shuffle(names)
+
+ return shuffled_names.join(sample(separators)).downcase
when Integer
# If specifier is Integer and has large value, Argument error exception is raised to overcome memory full error
raise ArgumentError, 'Given argument is too large' if specifier > 10**6
tries = 0 # Don't try forever in case we get something like 1_000_000.