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.

【RSpec】データ作成で使える小技

Posted at

環境

Rails 6.0.1
Ruby 2.6.3
PostgreSQL 11.16

テストデータの作成で使える小技

before

let(:cancel_applicatoions) { create_list(:cancel_applicatoion, 30) }
cancel_applicatoions.each do |cancel_applicatoion|
  create(:cancel_applicatoion_status, cancel_application: cancel_applicatoion)
end

after

create_listで作成したデータをeachのようにループできる。

create_list(:cancel_applicatoion, 30) do |cancel_applicatoion|
  create(:cancel_applicatoion_status, cancel_application: cancel_applicatoion)
end
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?