Reputation: 200
I'm trying to test my photo uploads with Fabricator and paperclip, but I'm having trouble using fabricator to create a paperclip object.
My current thought process is to include this module: http://room118solutions.com/2011/05/25/stubbing-paperclip-during-testing/
After including, I should be able to fabricate on it?? Unfortunately, I don't quite know enough about Fabricator to do this.
Upvotes: 2
Views: 346
Reputation: 185
If you want just to test something related to upload logic, and your test suite does not include fabricating lot of objects with attachments, you can do this:
Fabricator(:fabricator_name) do
image { File.open(File.join(Rails.root, 'spec', 'fabricators', 'assets', 'image.jpg'))}
end
And place any small image named image.jpg to spec/fabricators/assets/ folder. As noted here in question.
Upvotes: 1