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!


Finally found it, buried on the CarrierWave wiki:

Factory.define :brand do |f| "My Brand"
  f.description "Foo"
  f.logo {, 'spec', 'support', 'brands', 'logos', 'logo_image.jpg')) }

@JESii You can also do this:

include ActionDispatch::TestProcess 

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

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