Store_dimensions in specs outputs a warning

In a system spec in Rails I’m testing an avatar upload field using Capybara:

click_on 'Save changes'

expect(user.reload.avatar.metadata['filename']).to eq('logo.png')

The specs pass, but a warning is shown while running them:

SHRINE WARNING: Error occurred when attempting to extract image dimensions: #<FastImage::UnknownImageType: FastImage::UnknownImageType>

The warning is not that big of an issue, but I was wondering if I can get rid of it somehow. I’m going to have to test a lot more image uploads for this app, and it clutters the output.

You can choose to ignore errors when extracting dimensions in tests:

plugin :store_dimensions, on_error: Rails.env.test? ? :ignore : :warn
1 Like

Awesome! Thanks for the quick reply. :slight_smile: