Rails Diary

プログラミングの学習記録です。

2022-04-26から1日間の記事一覧

テストの書き方における疑問点(メモ)

テストの書き方で疑問だった箇所とその理由 describe '検索機能' do let(:article_with_author) { create(:article, :with_author, author_name: '田中') } let(:article_with_another_author) { create(:article, :with_author, author_name: '佐藤') } # …

FactoryBot 関連データの作成

FactoryBotにおけるアソシエーション belongs_toとhas_many ※ 解釈が合っているか分からない 所属(belongs_to)先を記載する場合はFactoryBotにassociation: author(associationは省略可)みたいに記載すればいい has_manyの場合はassociationによる記載が使え…