【发布时间】:2025-12-19 08:05:07
【问题描述】:
我试图在我的 Rails 3 代码中调用一个方法,但得到:
失败/错误:integration_sign_in wrong_user 参数错误: 参数数量错误(0 代表 1)
这是调用代码(在 RSpec 帮助器中):
before(:each) do
wrong_user = Factory(:user, :email => "test@test.com", :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' 也有同样的问题)
有什么想法吗?谢谢。
【问题讨论】:
-
我已经回答了下面的问题,但后续:为什么堆栈跟踪错误?这让它变得非常混乱。是否因为该方法位于 spec_helper.rb 文件中,堆栈无法到达(抓住稻草)?
标签: ruby-on-rails ruby integration-testing capybara