thoughtbot/factory_girl — Issue #219: Using rand() at factory definitions
Author: Exoth
Created: 2011-10-17 22:42:11+00:00
State: open

Whenever I use rand() at factory definitions, like this:

factory :album do
factory :album_with_photos do
after_create { |i| i.photos = FactoryGirl.build_list(:photo, rand(2) + 1, album: i) }
end
association :user
title 'album_title'
password 'secret'
description 'album_description'
end

I get

NoMethodError: undefined method `+' for #

Though I can use Random.rand(). Is it the way to go?