问题描述
|
我试图在我的Rails 3代码中调用一个方法,但得到:
失败/错误:integration_sign_in错误的用户
ArgumentError:
参数数量错误(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
因此,它显然是在通过一种论点。如果参数由于某种原因为null,那会否认为它不是参数?
相关背景:为了进行测试,我只是从webrat切换到了capybara。按照Railscast 257中的建议,我还安装了launchy和database_cleaner gem。当我使用webrat时,上面的代码按预期工作,但是现在(我相信与database_cleaner有关)出了问题。
可能相关:在我的spec_helper.rb中,我更改为:
config.use_transactional_fixtures = false
(即使\'true \'有相同的问题)
有任何想法吗?谢谢。
解决方法
看来参数错误实际上并未在此函数中出现(即使堆栈的顶部使它看起来也是如此。实际错误位于Integration_sign_in函数内部:
def integration_sign_in(user)
visit signin_path
fill_in :email,:with => user.email
fill_in :password,:with => user.password
click_button
end
看起来“ 3”在水豚中需要一个参数,但在webrat中则不需要。
,integration_sign_in(wrong_user)