reset_session 在 Cucumber 测试中不起作用
对于 Cucumber 场景,我有以下步骤:
Given /^I am not logged in$/ do
request.reset_session
controller.instance_variable_set(:@_current_user, nil)
end
但是当我运行 Cucumber 功能时,我得到:
undefined method `reset_session' for nil:NilClass (NoMethodError)
我的设置:
- rails 3.0.3
- cucumber-rails 0.3.2
I have the following step for a Cucumber scenario:
Given /^I am not logged in$/ do
request.reset_session
controller.instance_variable_set(:@_current_user, nil)
end
But when I run my Cucumber features, I get:
undefined method `reset_session' for nil:NilClass (NoMethodError)
My setup:
- rails 3.0.3
- cucumber-rails 0.3.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Cucumber 旨在锻炼全栈能力。鉴于此,您通常不想像使用 rspec 那样在较低级别上搞乱内部结构。
尝试这样的操作:
此示例使用 Capybara 的
visit
方法,因此您需要进行相应调整,但这应该会给您正确的想法。Cucumber is intended to exercise the full stack. Given that, you generally don't want to muck around with the internals at a lower level as you might with rspec.
Try something like this:
This example uses Capybara's
visit
method, so you'll need to adjust accordingly, but this should give you the right idea.