RSpec给控制器中的每个动作一个错误?

时间:2012-06-03 06:56:57

标签: ruby-on-rails-3 rspec tdd

这很奇怪,我在我的rails应用程序上运行bundle exec guard并且我在一个单独的容器中为每个单独的操作得到了很长的错误列表。并且所有错误都完全相同并且毫无意义,这就是我为所有行动所获得的:

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几乎是一个标准的脚手架。我应该在哪里看这里。规范文件由脚手架自动生成。

更新----

这是我的控制器代码中的Extend函数:

# 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 个答案:

答案 0 :(得分:3)

extend是一个核心ruby方法,允许您将模块的方法添加到对象(有点像include)

某事(你可以通过查看回溯的其余部分来判断)试图在你的控制器实例上调用extend,期望核心ruby的extend方法,这需要1个参数)而是找到你的extend方法没有参数(当然也有一些完全不同的东西)。

最简单的方法是为您的方法选择一个不同的名称