我正在用户登录功能在黄瓜和那里我必须测试,如果用户登录成功。一切顺利,除了最后一行:undefined method should_receive'for
Then I should be redirected to my home page
问题是,它不是正常的登录,它需要票。门票从ApplicationController#login_ticket获得。我想它存根,所以我写了这个网站的步骤:
Then(/^I should be redirected to my home page$/) do
ApplicationController.should_receive(:login_ticket).and_return("2081677")
current_path.should eq root_path
end
但它失败消息:
然后,我应该被重定向到我的主页# 功能/ step_definitions/web_steps.rb: 13 未定义的方法
should_receive' for ApplicationController:Class (NoMethodError) ./features/step_definitions/web_steps.rb:14:in
/^我应该被重定向到我的主页$ /“ 功能/ UserLogin.feature:9:'那么我应该被重定向到我的主页”
这里有什么问题?