Skip to content

Instantly share code, notes, and snippets.

@serbrech
Created November 13, 2011 16:01
Show Gist options
  • Save serbrech/1362260 to your computer and use it in GitHub Desktop.
Save serbrech/1362260 to your computer and use it in GitHub Desktop.
sequence of hash with factory_girl
Factory.sequence :writer_hash do |n|
{
"id" => "#{n}",
"name" => "name#{n}",
"article" => {
"id" => "#{n}",
"title" => "post title #{n}"
}
}
end
factory :publisher do |p|
l.association :owner, :factory => :user
l.raw_writers [Factory.next :writer_hash, Factory.next :writer_hash, Factory.next :writer_hash ]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment