-
I could only find on the examples, how to test metadata extraction(such as size, width, height, etc) I couldn't find a way to properly test the validations added either by the validation plugin or the validation_helpers I am wondering, how can I test the code from the uploader to guarantee that the max/min size, dimensions etc are in place What I am looking for is something similar to should_matchers how can I manually test my validations? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It might be easiest to test through a specific model, especially if there is model-specific code in the uploader. photo = Photo.new
photo.image = StringIO.new("too small")
refute photo.valid?
assert_equal ["..."], photo.errors[:image] But if the uploader doesn't reference the model, it should also be possible to test the attacher individually: attacher = ImageUploader::Attacher.new
attacher.assign StringIO.new("too small")
assert_equal ["..."], attacher.errors |
Beta Was this translation helpful? Give feedback.
It might be easiest to test through a specific model, especially if there is model-specific code in the uploader.
But if the uploader doesn't reference the model, it should also be possible to test the attacher individually: