Faker: Add User generator that accepts arguments

Created on 28 Jul 2019  路  6Comments  路  Source: faker-ruby/faker

Type: Feature Request

About: Rather than cobbling together a User object during development using individual Faker methods, it could be nice to have a generic user method that accepts arguments such as name, id, email, username, password and other common user attributes and returns an object with the desired attributes. Or if no arguments are provided, returns a default User object that has username and password attributes (or whatever attributes make sense for a default case).

Example

Instead of having to do:

    name: Faker::Internet.user_name,
    email: Faker::Internet.safe_email,
    password: Faker::Internet.password(6),

Create method that allows:

user = Faker::Internet.user('name', 'email', password')
=> {'name' => 'John Doe', 'email' => '[email protected]', 'password' => 'pass123' }

All 6 comments

Would this return a hash with the info or a data class with attributes for the data? I believe this would be a nice addition to some other classes as well, like Vehicle, where you could generate one with a random or fixed brand, and it returns a vehicle class with the brand, model, year, doors, license plate, etc

Hi, I was passing by and I found this one, I noticed @ashishra0 started working on it but he closed the PR, So is there any problem working on it? I've came up with a solution to this new one, Check it please, I used some of @ashishra0 code for testing my method too, So thanks to him.

@AmrAdelKhalil Hey, I had to close that issue because apparently the author had just changed the file structure moments before I came up with a solution. So i had to delete the branch I was working on and pull the fresh changes and start working again.

@AmrAdelKhalil The issue is still open, I had created a new PR for it #1730

@ashishra0 Hey, This is my bad, I didn't notice the PR, My apologies.

Hey @vbrazo,
it looks like there are two PRs for the same feature as I guess, both #1730 and #1744 are solving the same request, @ashishra0 started it already and made a PR. So, I could close my PR in this case.

@AmrAdelKhalil Appreciate it mate! Cheers 馃憤馃徎

Was this page helpful?
0 / 5 - 0 ratings

Related issues

supiash1 picture supiash1  路  5Comments

zyrthofar picture zyrthofar  路  6Comments

benpolinsky picture benpolinsky  路  5Comments

elangovan-selvaraj picture elangovan-selvaraj  路  6Comments

vbrazo picture vbrazo  路  3Comments