RoR:参数数量错误
我试图在 Rails 3 代码中调用一个方法,但得到:
失败/错误:集成登录错误用户 参数错误: 参数数量错误(0 代表 1)
这是调用代码(在 RSpec 帮助器中):
before(:each) do
wrong_user = Factory(:user, :email => "[email protected]", :password=>"hellohello", :password_confirmation => "hellohello")
integration_sign_in wrong_user
end
因此它显然传递了一个参数。如果参数由于某种原因为空,是否会认为它不是参数?
相关背景故事:为了测试,我刚刚从 webrat 切换到 capybara。按照 Railscast 257 中的建议,我还安装了 launchy 和 database_cleaner gem。当我使用 webrat 时,上面的代码按预期工作,但现在(我相信与database_cleaner相关)出了问题。
可能相关:在我的spec_helper.rb中我更改为: config.use_transactional_fixtures = false
(即使“true”也有同样的问题)
有什么想法吗?谢谢。
I am trying to call a method in my Rails 3 code but am getting:
Failure/Error: integration_sign_in wrong_user
ArgumentError:
wrong number of arguments (0 for 1)
Here is the calling code (in an RSpec helper):
before(:each) do
wrong_user = Factory(:user, :email => "[email protected]", :password=>"hellohello", :password_confirmation => "hellohello")
integration_sign_in wrong_user
end
So it is clearly passing one argument. If the argument is null for some reason, would that make it consider it not a parameter?
RELEVANT BACKSTORY: For testing, I just switched from webrat to capybara. As suggested in Railscast 257, I also installed the launchy and database_cleaner gems. When I was using webrat, the code above worked as expected, but now (I believe related to database_cleaner) something is going wrong.
Possibly relevant: In my spec_helper.rb I changed to:config.use_transactional_fixtures = false
(even though 'true' has the same problem)
Any ideas? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来参数错误实际上并不在这个函数中(尽管堆栈的顶部使它看起来像这样。实际的错误在integration_sign_in函数内部:
看起来
click_button
需要一个在 capybara 中存在争论,但在 webrat 中则不然。It looks like the argument error was not actually in this function (even though the top of the stack makes it look like it is. The actual error is inside of the integration_sign_in function:
It looks like
click_button
needs an argument in capybara, but it does not in webrat.