How to properly do model testing with ActiveStorage in rails?

前端 未结 5 642
星月不相逢
星月不相逢 2021-01-01 09:17

I have just switched to using ActiveStorage on rails 5.1.4 and I am new to TDD and struggling to figure out how to test a model that has_one_attached :avatar

5条回答
  •  庸人自扰
    2021-01-01 10:07

    In config/environments/test.rb

    config.active_storage.service = :test

    In your spec

    it {expect(valid_user.avatar).to be_attached}

提交回复
热议问题