views:

207

answers:

1

I don't really care about testing file uploads, but since I have validates_attachment_presence, etc.. in my model, rspec is complaining.

So now I'm creating my model with these attributes in the spec to try and shut it up:

@attr = {
  :name => "value for name",
  :title => "value for title",
  :content => "value for content",
  :pic_file_name => "example.jpg",
  :pic_content_type => "image/jpg",
  :pic_file_size => "8192",
  :pic_updated_at => nil
}

This doesn't work, though.

Some googling led me to this: http://fr.ivolo.us/posts/mocking-paperclip-with-rspec So I tried something like this:

Post.should_receive(:save_attached_files).and_return(true)

Which doesn't work either. How do I appease RSpec?

+2  A: 

If the model has_attached_file :pic, you should be able to just point the pic attribute at some file and all should be dandy.

Meaning something like @attr = { :pic => File.join(Rails.root, 'spec', 'fixtures', 'file.png') }

theIV