{"action":"created","issue":{"url":"https://api.github.com/repos/ffaker/ffaker/issues/19","repository_url":"https://api.github.com/repos/ffaker/ffaker","labels_url":"https://api.github.com/repos/ffaker/ffaker/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/ffaker/ffaker/issues/19/comments","events_url":"https://api.github.com/repos/ffaker/ffaker/issues/19/events","html_url":"https://github.com/ffaker/ffaker/issues/19","id":1002788,"node_id":"MDU6SXNzdWUxMDAyNzg4","number":19,"title":"Usernames are not random enough -- getting collisions in my specs","user":{"login":"d11wtq","id":37948,"node_id":"MDQ6VXNlcjM3OTQ4","avatar_url":"https://avatars2.githubusercontent.com/u/37948?v=4","gravatar_id":"","url":"https://api.github.com/users/d11wtq","html_url":"https://github.com/d11wtq","followers_url":"https://api.github.com/users/d11wtq/followers","following_url":"https://api.github.com/users/d11wtq/following{/other_user}","gists_url":"https://api.github.com/users/d11wtq/gists{/gist_id}","starred_url":"https://api.github.com/users/d11wtq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d11wtq/subscriptions","organizations_url":"https://api.github.com/users/d11wtq/orgs","repos_url":"https://api.github.com/users/d11wtq/repos","events_url":"https://api.github.com/users/d11wtq/events{/privacy}","received_events_url":"https://api.github.com/users/d11wtq/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2011-06-04T14:40:06Z","updated_at":"2018-10-27T09:48:32Z","closed_at":null,"author_association":"NONE","body":"This happens very sporadically, but in tests I'm using ffaker to generate random usernames.  I was previously just using `ActiveSupport::SecureRandom.hex(16)`, but a colleague convinced me that ffaker was the way to go, so I switched and have had much success, besides this single issue.\n\nIn specs where I needs to create two or more users, sometimes, but not always (read, mostly not), ffaker generates the same username twice, which causes my specs to fail due to duplicate key conflicts in the database.  Re-running the test suite always corrects the issue.  My database is correctly cleaned between examples... this issue is localized to within a single example/test.\n\nI think a possible solution (and maybe it actually exists but I don't see it), is for ffaker to strike out already used usernames, so that the same one cannot be generated twice, then provide some method to reset ffaker's dictionary so that all struck-out entries are released for re-use.  This way one can just reset ffaker in their setup/teardown logic.\n"},"comment":{"url":"https://api.github.com/repos/ffaker/ffaker/issues/comments/433606697","html_url":"https://github.com/ffaker/ffaker/issues/19#issuecomment-433606697","issue_url":"https://api.github.com/repos/ffaker/ffaker/issues/19","id":433606697,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzYwNjY5Nw==","user":{"login":"toupeira","id":6501,"node_id":"MDQ6VXNlcjY1MDE=","avatar_url":"https://avatars1.githubusercontent.com/u/6501?v=4","gravatar_id":"","url":"https://api.github.com/users/toupeira","html_url":"https://github.com/toupeira","followers_url":"https://api.github.com/users/toupeira/followers","following_url":"https://api.github.com/users/toupeira/following{/other_user}","gists_url":"https://api.github.com/users/toupeira/gists{/gist_id}","starred_url":"https://api.github.com/users/toupeira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toupeira/subscriptions","organizations_url":"https://api.github.com/users/toupeira/orgs","repos_url":"https://api.github.com/users/toupeira/repos","events_url":"https://api.github.com/users/toupeira/events{/privacy}","received_events_url":"https://api.github.com/users/toupeira/received_events","type":"User","site_admin":false},"created_at":"2018-10-27T09:48:32Z","updated_at":"2018-10-27T09:48:32Z","author_association":"NONE","body":"This looks like an outdated issue, FFaker now supports [unique results](https://github.com/ffaker/ffaker#unique-results) e.g. `FFaker::Name.unique.name`."}}
{"actor":{"display_login":"toupeira"}}