2012-06-03 49 views
0

這很奇怪,我在我的rails應用程序上運行bundle exec guard,並且我得到一個單獨容器中每個單獨操作的錯誤列表。所有的錯誤都是一樣的,沒有任何意義,這是我得到的所有行動:RSpec在控制器中的每個動作都發生錯誤?

1) PriceProfilesController GET index assigns all price_profiles as @price_profiles 
    Failure/Error: Unable to find matching line from backtrace 
    ArgumentError: 
     wrong number of arguments (1 for 0) 
    # ./app/controllers/price_profiles_controller.rb:15:in `extend' 

    2) PriceProfilesController GET show assigns the requested price_profile as @price_profile 
    Failure/Error: Unable to find matching line from backtrace 
    ArgumentError: 
     wrong number of arguments (1 for 0) 
    # ./app/controllers/price_profiles_controller.rb:15:in `extend' 

... and so forth 

任何想法是怎麼回事? PriceProfileContainer幾乎是一個標準的腳手架。我應該在哪裏看這裏。 spec文件由腳手架自動生成。

UPDATE ----

這裏是我的控制器代碼的擴展功能:

# GET /price_profiles/1/extend 
    def extend 
    @price_profile = PriceProfile.find(params[:id]) 
    @products = Product.all() 
    @locations = Location.all() 
    @price_profile_date_range = PriceProfileDateRange.new() 

    #respond_to do |format| 
    # format.html # extend.html.erb  
    #end 
    end 

這就是這麼多了。

+1

我想你會需要來發表您的控制器代碼。基於這個錯誤,看起來在你的'price_profiles_controller'中,你正在調用第15行的extend方法,並且在它沒有期望的地方向它傳遞一個參數。但需要查看代碼才能確定。 –

+0

@GeoffLanotte嗨,請檢查我的更新 – Ali

回答

3

extend是一個核心的紅寶石方法,可以讓你模塊的方法添加到對象(有點像包括)

東西(你可以通過查看回溯的剩餘部分可能會說)試圖調用在你的控制器的一個實例上進行擴展,期待覈心ruby的擴展方法,該方法需要1個參數),而是找到不帶參數的擴展方法(當然會做一些完全不同的事情)。

最簡單的事情是選擇一個不同的名稱爲您的方法

+0

Ouch - 但作爲一個應用程序,它在瀏覽器中運行得很好。我會做出改變和檢查。 – Ali

+1

rspec擴展你的控制器來做一些它的測試魔術 –

+0

Bingo!究竟是什麼問題在這裏,一個簡單的重命名和rspecs高興 - 非常感謝,我幾乎在我的智慧結束在這裏。 – Ali

相關問題