Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 699
Adam Avatar asked Nov 24 '22 13:11

Adam


1 Answers

Simply do not use the variable you are defining with let inside the following code block as it triggers an endless recursion.

like image 78
Hubert Grzeskowiak Avatar answered Dec 08 '22 07:12

Hubert Grzeskowiak