ruby-on-railsfactory-botshrine

Testing Shrine gem return error undefined method `set_derivatives'


I am trying to test uploads through Shrine. I have Minio and followed this tutorial https://shrinerb.com/docs/testing#test-data

Yet FactoryBot.lint returns the following error from the TestModule code provided in the link:

profilepic - undefined method `set_derivatives' for #<Shrine::Attacher:0x000055ee893dfe00 @file=#<Shrine::UploadedFile storage=:store id="8aa14e79342fde0077fd48f1035f56c3" metadata={"size"=>576152, "mime_type"=>"image/jpeg", "filename"=>"profile_pic.jpg"}>, @cache=:cache, @store=:store, @context={}, @previous=nil, @column_serializer=Shrine::Plugins::Column::JsonSerializer, @model_cache=true, @model=nil, @destroy_block=nil, @promote_block=nil, @errors=[]> (NoMethodError)
# /home/maxence/.rvm/gems/ruby-3.0.3/gems/factory_bot-6.2.1/lib/factory_bot/linter.rb:13:in `lint!'
# /home/maxence/.rvm/gems/ruby-3.0.3/gems/factory_bot-6.2.1/lib/factory_bot.rb:70:in `lint'
# ./spec/support/factory_bot.rb:7:in `block (2 levels) in <top (required)>'

Any idea what's wrong ?


Solution

  • Just from the error it looks like derivatives plugin is not loaded. https://shrinerb.com/docs/plugins/derivatives

    Add this to the test module

    Shrine.plugin :derivatives