我已经看到了很多这些问题,但他们的解决方案都不适合我。我有这样一个单一的测试:堆栈太深 - Rspec
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
我都喜欢......什么?我再次读过几十个关于这个问题的问题,这似乎与工厂女孩有些关系,但我不明白这里会遇到什么问题。我有大量的其他测试,没有问题实例化工厂女孩为基础的对象。
你的堆栈跟踪是什么样的?无论如何,您需要分享您的工厂,以获得比相关问题更具体的帮助。 –
小心'let' - 这很懒。当您的测试运行'sign_in admin'时,它会在运行测试之前实例化'admin',但不会执行'user'或'adminRole'。 – zetetic
它似乎与Rspec没有关系。我在ActiveSupport instrumenter的同一行中得到了同样的错误,只是在生产模式下运行脚本,并且在该环境中排除了Rspec。我也在运行Ruby 2.0.0-p247和Rails 4. –