Rspecそのものの実行はできています。
Factorybotも利用できており、Factorybotで作成したユーザーでは、テストの実施ができております。
spec/integration/relationship_spec.rb
require 'rails_helper' describe 'フォロー機能', type: :system do let!(:user){FactoryBot.create(:user,name:'一般ユーザー')} let!(:other_user){FactoryBot.create(:user,name:'その他ユーザー')} context 'フォロー時' do before do FactoryBot.create(:relationship, user: user, follow: other_user) end it 'フォロワー一覧に名前がある' do visit followings_user_path(user) expect(page).to have_content other_user.name end end end
spec/factories/relationships.rb
FactoryBot.define do factory :relationship do association :user association :follow, factory: :user end end
テスト実行結果として
NoMethodError: undefined method `user=' for #<Relationship:0x00007fce470c4be0>
がでております。
初歩的なことで申し訳ありません。
ご存知の方おられましたら、よろしくお願い致します。
あなたの回答
tips
プレビュー