【发布时间】:2012-04-06 04:49:21
【问题描述】:
我必须为我的一个功能列表页面编写集成测试用例,并且该功能索引方法具有如下代码
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 进行集成测试用例
【问题讨论】:
-
嘿@chirag.sweng,您可能想要交换您提供的链接的名称。 spec_helper 文件指向 foot_categories_spec 文件,反之亦然。真的只是一个注释。这是我的规范文件这是我的 food_categories_spec.rb
标签: ruby-on-rails rspec devise integration-testing capybara