簡體   English   中英

RoR:錯誤的參數數量

[英]RoR: Wrong Number of Arguments

我試圖在我的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

所以它顯然傳遞了一個論點。 如果參數由於某種原因為null,那會不會認為它不是參數?

相關的背景:為了測試,我剛剛從webrat切換到水豚。 正如Railscast 257中所建議的那樣,我還安裝了launchy和database_cleaner寶石。 當我使用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

看起來click_buttonclick_button需要一個參數,但它不在webrat中。

integration_sign_in(wrong_user)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM