rspec / rspec-core

RSpec runner and formatters
http://rspec.info
MIT License
1.23k stars 765 forks source link

stack level too deep on #get in request specs #3127

Closed mbajur closed 4 days ago

mbajur commented 4 days ago

Subject of the issue

I just installed rspec in the rails engine gem i maintain. All i did was adding rspec-rails as a dependency and run rails g rspec:install. I created the simplest request spec possible:

require 'rails_helper'

RSpec.describe 'Root request', type: :request do
  describe 'GET /' do
    it 'returns a successfull response' do
      get '/'
      expect(response).to be_success
    end
  end
end

However, running it raises :

Failure/Error: get '/'

     SystemStackError:
       stack level too deep

I'm sorry if that was solved anywhere but the error produced and keywors are so generic it's very hard to find anything even remotely similar to my issue.

Your environment

Steps to reproduce

Clone this app and run bundle exec rspec

pirj commented 4 days ago

If you run rspec with --backtrace, will there be anything pointing at an infinite loop? Can you share?

mbajur commented 4 days ago

Sure, there you go: https://gist.github.com/mbajur/2835f7b8adf5b933adb4e35eec70024c

mbajur commented 4 days ago

Ok, it turned out it was happening because i had no root_to route defined, rails was serving a default root template and it somehow messed up the get. Using a real route fixed that for me.