[英]Stack level too Deep - Rspec
I've seen tons of these questions, but none of their solutions are working for me. 我已经看到了很多这些问题,但他们的解决方案都没有对我有用。 I have a single test like so: 我有一个这样的测试:
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
Simple, simple, simple. 简单,简单,简单。 Yet I get the typical error: 但我得到了典型的错误:
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
and I'm all like ... what? 而且我都喜欢......什么? Again I have read dozens of questions on this and it seems to be something with factory girl but I cannot see what the issue here would be. 我再次阅读了几十个关于此问题的问题,这似乎与工厂女孩有关,但我看不出这里的问题是什么。 I have tons of other tests that instantiate factory girl based object like this with no issue. 我有很多其他测试实例化像这样的工厂女孩对象没有问题。
根本就没有用,你用定义变量let
,因为它触发无限递归下面的代码块中。
I think some naming conflicts causing this stack level too deep error. 我认为一些命名冲突导致这个堆栈级别太深的错误。
let(:adminRole) { FactoryGirl.create(:adminRole) }
How about you rename the adminRole
factory to :admin_role
: 如何将adminRole
工厂重命名为:admin_role
:
factory :admin_role do
...
end
And change the let
to follow variable convention : 并改变let
遵循变量约定 :
let(:admin_role) { FactoryGirl.create(:admin_role) }
Hope this may help you. 希望这可以帮到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.