I have a Banner, with an attached file, using paperclip. Paperclip will create “derivatives” for an uploaded image, using the “styles” parameter:
class Banner < ActiveRecord::Base
has_attached_file :image,
:styles => {:medium => "300x300>",
:thumb => "100x100>"}
end
I want to test this attached_file generation, preferably without testing the whole roundtrip to a disk and so on. I could create a Banner, attach a file and then look on the filesystem if a certain file with certain dimensions is created, but that goes against my idea of testing a focused part, without testing the entire stack.
How can I test if the attached file :image has certain styles in Paperclip?
All the
has_attached_filemethod does is add the passed definitions to the model. The generation is done by paperclip and shouldn’t need to be tested.Source:
https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip.rb#L174
However, you could test that the definitions were created properly using the
attachment_definitionsmethod. Something like this: