Created
December 19, 2014 17:32
-
-
Save Zhengquan/5439a41235e1abe029cc to your computer and use it in GitHub Desktop.
demo to generate fixture data with factory_girl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'securerandom' | |
require 'factory_girl' | |
class Assignee | |
attr_accessor :first_name, :last_name | |
def to_s | |
"#{first_name} #{last_name}" | |
end | |
end | |
FactoryGirl.define do | |
factory :assignee do | |
first_name { "first-name-#{SecureRandom.hex(20)}" } | |
last_name { "last-name-#{SecureRandom.hex(20)}" } | |
end | |
end | |
include FactoryGirl::Syntax::Methods | |
2.times {puts build(:assignee)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment