我试图在Rails 3代码中调用一个方法,但是我得到了:
失败/错误: integration_sign_in wrong_user 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因此,它显然是在通过一个论点。如果由于某种原因该参数为空,那么它是否会认为它不是一个参数?
相关背景:为了测试,我刚从水豚转到了水豚。正如铁路257中所建议的,我还安装了launchy和database_cleaner宝石。当我使用webrat时,上面的代码按预期工作,但现在(我相信与database_cleaner有关)出了问题。
可能相关:在我的spec_helper.rb中,我改为:config.use_transactional_fixtures = false (尽管'true‘有相同的问题)
有什么想法吗?谢谢。
发布于 2011-04-16 00:18:14
看起来,参数错误实际上并不在这个函数中(尽管堆栈的顶部使它看起来是这样的)。实际错误在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看起来,click_button需要在水豚进行争论,但在微乎其微的时候却不需要争论。
发布于 2011-04-15 23:36:30
integration_sign_in(wrong_user)https://stackoverflow.com/questions/5683285
复制相似问题