简体   繁体   中英

RoR: Wrong Number of Arguments

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 => "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?

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.

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:

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.

integration_sign_in(wrong_user)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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