简体   繁体   English

RoR:错误的参数数量

[英]RoR: Wrong Number of Arguments

I am trying to call a method in my Rails 3 code but am getting: 我试图在我的Rails 3代码中调用一个方法,但我得到:

Failure/Error: integration_sign_in wrong_user ArgumentError: wrong number of arguments (0 for 1) 失败/错误:integration_sign_in wrong_user ArgumentError:错误的参数个数(0表示1)

Here is the calling code (in an RSpec helper): 这是调用代码(在RSpec助手中):

before(:each) do
    wrong_user = Factory(:user, :email => "test@test.com", :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? 如果参数由于某种原因为null,那会不会认为它不是参数?

RELEVANT BACKSTORY: For testing, I just switched from webrat to capybara. 相关的背景:为了测试,我刚刚从webrat切换到水豚。 As suggested in Railscast 257 , I also installed the launchy and database_cleaner gems. 正如Railscast 257中所建议的那样,我还安装了launchy和database_cleaner宝石。 When I was using webrat, the code above worked as expected, but now (I believe related to database_cleaner) something is going wrong. 当我使用webrat时,上面的代码按预期工作,但现在(我相信与database_cleaner相关)出现了问题。

Possibly relevant: In my spec_helper.rb I changed to: config.use_transactional_fixtures = false (even though 'true' has the same problem) 可能相关:在我的spec_helper.rb中,我改为: config.use_transactional_fixtures = false (尽管'true'有同样的问题)

Any ideas? 有任何想法吗? Thanks. 谢谢。

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: 看起来参数错误实际上并不在这个函数中(即使堆栈顶部看起来像它。实际错误在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

It looks like click_button needs an argument in capybara, but it does not in webrat. 看起来click_buttonclick_button需要一个参数,但它不在webrat中。

integration_sign_in(wrong_user)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM