Skip to content

Instantly share code, notes, and snippets.

@Zhengquan
Created December 19, 2014 17:32
Show Gist options
  • Save Zhengquan/5439a41235e1abe029cc to your computer and use it in GitHub Desktop.
Save Zhengquan/5439a41235e1abe029cc to your computer and use it in GitHub Desktop.
demo to generate fixture data with factory_girl
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