require 'faker' FactoryGirl.define do factory :user do name { Faker::Name.name } email { Faker::Internet.email } password 'secret' password_confirmation 'secret' phone '13712345678' factory :user_with_sequence_number do sequence(:email){ |n| "email#{n}@example.com" } sequence(:name){ |n| "username#{n}"} end factory :user_name_length_gt_30 do name Faker::Internet.password(31, 31) end factory :user_email_length_gt_50 do email '12345678901234567890123456789012345678901234567890@qq.com' end factory :user_password_length_lt_6 do password { Faker::Internet.password( 0, 5 ) } end end end