views:

26

answers:

0

I'm having problems with my functional tests involving paperclip and attachments. I'm using the fixture_file_upload method to fake the attachment uploads.

My tests intermittently give me the error below (or one similar to it), generated by a factory_girl call to create the object containing the attachment, which is in my setup block.

@asset = Factory(:asset, :item => fixture_file_upload('test.png','image/png'))

However, even though the setup block is run for every test in the final, this error isn't generated for every test. Running a single test in the file (which calls the setup block and the above method) runs fine. It's just with multiple tests that I get the error (and it's not always the same depending on how many tests are run.) So there's some sort of conflict with multiple calls to fixture_file_upload.

Anyone have any ideas of how to get around this problem? Thank you.

Errno::ENOENT: No such file or directory - /var/folders/cm/cmC3aPSEE7i3lzQGMwM2Kk+++TI/-Tmp-/stream,17938,0,17938,0
    /Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1407:in `stat'
    /Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1407:in `block in fu_each_src_dest'
    /Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1423:in `fu_each_src_dest0'
    /Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1405:in `fu_each_src_dest'
    /Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:504:in `mv'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/storage.rb:42:in `block in flush_writes'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/storage.rb:38:in `each'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/storage.rb:38:in `flush_writes'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:144:in `save'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:384:in `block in save_attached_files'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:377:in `block in each_attachment'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:376:in `each'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:376:in `each_attachment'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:383:in `save_attached_files'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:429:in `_run_save_callbacks'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/callbacks.rb:290:in `create_or_update'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/persistence.rb:53:in `save!'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/validations.rb:46:in `save!'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:240:in `block in save!'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:287:in `block in with_transaction_returning_status'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:202:in `transaction'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:285:in `with_transaction_returning_status'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:240:in `save!'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/proxy/create.rb:6:in `result'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:326:in `run'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:270:in `create'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:301:in `default_strategy'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl.rb:20:in `Factory'
    /Users/francis/dev/r3/works/test/functional/assets_controller_test.rb:13:in `block in <class:AssetsControllerTest>'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:433:in `_run_setup_callbacks'
    /Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activesupport-3.0.0.beta4/lib/active_support/testing/setup_and_teardown.rb:34:in `run'