I'm working on an app that allows you to post images using Active Strage. Here is an example of how to write a test at that time.
factories
FactoryBot.define do
factory :post do
...
trait :post_image do
image {
fixture_file_upload("app/assets/images/XXX.PNG")
}
end
...
let(Definition name) {Definition content}
let(:post_image) { FactoryBot.create(:post_image) }
post = FactoryBot.create(:post,:post_image)
https://qiita.com/maca12vel/items/ee4d16827f24f69080ae https://shuttodev.hatenablog.com/entry/2019/09/04/015756
Recommended Posts