π€ ok but not great
Because you can't understand it without reading through the procedure.
let(:author1) { create(:author) }
let(:author2) { create(:author) }
let(:book1) { create(:book, author: author1) }
let(:book2) { create(:book, author: author2) }
let(:books) { [book1, book2] }
π Great
The intention is clear. The test needs the books array, and each book has different author.
let(:authors){ create_list(:author, 2) }
let(:books){
[
create(:book, author: authors[0]),
create(:book, author: authors[1])
]
}
do-end is ok instead of the {}
let(:companies) do [
create(:company, name: 'Hoge Company'),
create(:company, name: 'Fuga Company'),
create(:company, name: 'Piyo Company')
] end
Top comments (0)