对于控制器测试,在界定模型的Im光谱顶端:
let(:user) { Factory(:user, :company => company) }
let(:facility) { Factory(:facility, :company => company) }
let(:company) { Factory(:company, :facilities => [facility]) }
而且,基本指数的光谱:
context "responding to GET index" do
it "should expose all facilities as @facilities" do
user.company.should_receive(:facilities).and_return([facility])
get :index
assigns[:facilities].should == [facility]
end
end
但我犯了这一错误:
should expose all facilities as @facilities
stack level too deep
/Users/dmix/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.6.4/lib/rspec/core/let.rb:90
88 module InstanceMethods
89 def __memoized # :nodoc:
90 @__memoized ||= {}
91 end
92 end
问题似乎同时提到三个因素。
如果我从公司工厂的定义中删除:facilities,那么 st错误就会发生:
let(:company) { Factory(:company) }
我如何制造三种模式,它们相互参照,而不会陷入停滞?