1 つの機能一覧ページの統合テスト ケースを作成する必要があり、その機能インデックス メソッドには以下のようなコードがあります。
def index
@food_categories = current_user.food_categories
end
これのテストケースを書き込もうとすると、エラーがスローされます
'undefined method features for nil class' because it can not get the current user
今私がしていることは以下のとおりです。各ステートメントの前にログインプロセスを記述し、機能リストページのテストケースを記述しました
を入手する方法を教えてくださいcurrent_user
。
参考までに、私はdevise gemを使用し、Rspecとの統合テストケースに取り組んでいます
ここに私のspecファイルがあります そしてここに私のfood_categories_spec.rbがあります