lib/facemock/user.rb in facemock-0.0.9 vs lib/facemock/user.rb in facemock-0.0.10

- old
+ new

@@ -1,5 +1,6 @@ +require 'faker' require 'facemock/database/table' require 'facemock/permission' require 'facemock/authorization_code' module Facemock @@ -9,17 +10,24 @@ CHILDREN = [ Permission, AuthorizationCode ] def initialize(options={}) opts = Hashie::Mash.new(options) id = opts.id || opts.identifier - @id = (id.to_i > 0) ? id.to_i : ("10000" + (0..9).to_a.shuffle[0..10].join).to_i - @name = opts.name || rand(36**10).to_s(36) - @email = opts.email || name.gsub(" ", "_") + "@example.com" - @password = opts.password || rand(36**10).to_s(36) + @id = (id.to_i > 0) ? id.to_i : ("10000" + Faker::Number.number(10)).to_i + @name = opts.name || create_user_name + @email = opts.email || Faker::Internet.email + @password = opts.password || Faker::Internet.password @installed = opts.installed || false - @access_token = opts.access_token || rand(36**255).to_s(36) + @access_token = opts.access_token || Faker::Lorem.characters app_id = opts.application_id.to_i @application_id = (app_id > 0) ? app_id : nil @created_at = opts.created_at + end + + private + + def create_user_name + n = Faker::Name.name + n.include?("'") ? create_user_name : n end end end