Githubのwikiに書いてある。
Attaching a file to a FactoryGirl object is pretty much identical.
Factory.define :brand do |f| f.name "My Brand" f.description "Foo" f.logo { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'support', 'brands', 'logos', 'logo_image.jpg')) } end As far as I can tell the curly braces are required to make FactoryGirl attach it lazily, i.e. whenever the factory is built.https://github.com/jnicklas/carrierwave/wiki/How-to%3A-Use-test-fixtures
fixture_file_uploadを使う方法もあるらしい。これはActionDispatch::TestProcessに定義されている。