0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

アクティブストレージを利用して複数枚の画像を投稿した際の単体テスト

Posted at

アクティブストレージを利用して複数枚の画像投稿には成功した。
しかしテストコードで詰まったので記録。
結論

RSpec.describe Item, type: :model do
  before do
    @item = FactoryBot.build(:item)
    @item.images = [ fixture_file_upload("/files/test_image.jpg")]
  end

このように書き換える。
画像1枚のときは fixture_file_uploadだけでよかったのですが、複数枚になったことで配列で渡す必要があったのですね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?