我见过很多这样的问题,但他们的解决方案都不适合我。我有一个像这样的测试:
describe RolesController do
describe "#delet" do
context "When the user is logged in" do
let(:user) {FactoryGirl.create(:user)}
let(:admin) {FactoryGirl.create(:admin)}
let(:adminRole) {FactoryGirl.create(:adminRole)}
it "Should allow admins to delete roles" do
sign_in admin
put :destroy, :id => adminRole.id
end
end
end
end
简单,简单,简单。然而我得到了典型的错误:
1) RolesController#delet When the user is logged in Should allow admins to delete roles
Failure/Error: Unable to find matching line from backtrace
SystemStackError:
stack level too deep
# /home/adam/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:23
我都喜欢......什么?我再次阅读了数十个关于此的问题,这似乎与工厂女孩有关,但我看不出这里的问题是什么。我有大量其他测试可以毫无问题地实例化这样的基于工厂女孩的对象。