CarrierWave and FactoryGirl

Anybody have success getting FactoryGirl to be able to build a record which requires an image created with CarrierWave? The CarrierWave documentation is sadly lacking and Mr. google has no love for my questions. It seems to be a catch 22: CW needs a record_id to put the image in the correct spot and FactoryGirl can’t save the record until there’s an image available.

Now… it works in production so it can’t be that bad, but I can’t figure it out. Any help greatly appreciated!

Updated

Finally found it, buried on the CarrierWave wiki:

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

@JESii You can also do this:

include ActionDispatch::TestProcess 

FactoryGirl.define 
  factory :brand do
    name "My Brand"
    description "Foo"
    logo {fixture_file_upload("#{Rails.root}/spec/support/brands/logos/logo_image.jpg", 'image/png')}
  end
end

Thanks @zamith… always good to have TMTOWTDI :=)