Scenario: Home page have a login page When I go to the home page And user is not logged in Then I should see "Sign In"
用于步骤定义
When /^user is not logged in$/ do signed_in? == falseend
我还为黄瓜世界添加了Devise助手.
World(Devise::Controllers::Helpers)
和黄瓜正在生成此错误:
And user is not logged in # features/step_deFinitions/web_steps.rb:260 wrong number of arguments (0 for 1) (ArgumentError) ./features/step_deFinitions/web_steps.rb:261:in `/^user is not logged in$/' features/manage_home_page.feature:13:in `And user is not logged in'
它为什么生成以及如何修复它?
更新
signed_in的定义?方法是
# Return true if the given scope is signed in session. If no scope given,return # true if any scope is signed in. Does not run authentication hooks. def signed_in?(scope=nil) [ scope || Devise.mapPings.keys ].flatten.any? do |scope| warden.authenticate?(:scope => scope) end end
它在Devise中定义,我通过将此代码World(Devise :: Controllers :: Helpers)编写到cucumber的paths.rb文件中,将帮助器添加到黄瓜中.
解决方法 试试这个When /^user is not logged in$/ do user_signed_in?.should be_falseend
更新
我想你需要做这样的事情
When /^user is not logged in$/ do |user| #check here user not logged inend
要么
您可以尝试将功能修改为
Scenario: Home page has a login page Given I am on the home page And I am not logged in Then I should see "Sign In"
然后在步骤中
Given /^user is not logged in$/ do visit('users/sign_out') # this will ensure that the user is not logged inend总结
以上是内存溢出为你收集整理的ruby-on-rails-3 – 参数个数错误(0表示1)(ArgumentError)全部内容,希望文章能够帮你解决ruby-on-rails-3 – 参数个数错误(0表示1)(ArgumentError)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)