Skip to content

Instantly share code, notes, and snippets.

@mattetti
Created September 7, 2008 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattetti/9269 to your computer and use it in GitHub Desktop.
Save mattetti/9269 to your computer and use it in GitHub Desktop.
# Client factory
Factory.define :client do |c|
c.name 'John Doe'
c.email{|c| "#{(c.name || "John Doe").split(' ').first}.#{(c.name || "John Doe").split(' ').last}@email.com".downcase}
c.address "1234 DrPepper Road"
c.city "San Diego"
c.zip_code "92129"
c.phone "858-555-1234"
c.created_at Time.now
end
# Project factory
Factory.define :project do |p|
p.name "John's project"
p.association :client, :factory => :client
p.done false
p.note 'a note'
p.created_at Time.now
p.due_date {|p| p.created_at + 10.days}
p.estimated_budget { (5_000..40_000).to_a[rand(35_000)] }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment