我知道这必须是愚蠢的,但我在我的一个例子中不断收到以下错误:
undefined method `new' for #<Class:0x211d274>
我创建了一个显示错误的简单示例:
describe LateCharge do
before :each do
@membership = Membership.new
@location = mock_model(Location, :late_payment_rate => 10)
end
it "should initialize" do
LateCharge.respond_to?('new').should == true
@charge = LateCharge.new(@membership, @location)
end
end
奇怪的是,当我自己运行示例时,它会通过。当我用我的所有示例运行它时,它失败并出现以下错误:
NoMethodError in 'LateCharge should initialize'
undefined method `new' for #<Class:0x211d274>
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1964:in `method_missing_without_paginate'
/Users/l33/.gem/ruby/1.8/gems/mislav-will_paginate-2.3.11/lib/will_paginate/finder.rb:170:in `method_missing'
./spec/models/late_charge_spec.rb:15:
失败了:@ charge = LateCharge.new(@membership,@ location)
我在运行时或从控制台实例化LateCharge对象时没有任何问题。
有人有什么想法吗?
答案 0 :(得分:0)
在我看来,以下信息对您的问题至关重要:
will_paginate/finder.rb:170:in `method_missing'
答案 1 :(得分:0)