file_desc = Array.new 7, "" file_desc = file_desc.map do |p| Faker::Lorem.word end file = ["1.png", "5.pdf", "2.png", "6.pdf", "3.png", "7.pdf", "4.png"] rand = Random.new FactoryGirl.define do factory(:writing_conference_file, class: "WritingConferenceFile") do |f| f.sequence(:file) do |n| File.new(File.join(Rails.root, "db" ,"files", file[rand.rand(0..6)])) end f.sequence(:title) do |n| "#{file_desc[rand.rand(0..6)]}" end end end