RSpec Cannot find my Controllers Uninitialized Constant

I have added

--require rails_helper

in .rspec in my rails application, it resolves the error.


I added

require File.expand_path("../../config/environment", __FILE__)

to the spec_helper.rb file and this resolved the error. I'm not sure why the spec_helper needs this, but I think it has something to do with Rails' ability to locate a file's path relative to another file, and I suspect this was messing up RSpec's ability to find the appropriate controllers, models, etc.

I did some research and found that previously we were on RSpec 2.14 and we're now on 3.2, and I think there may be some differences in the way rspec uses these two files. In our old spec_helper file we had this line:

require File.expand_path("../../config/environment", __FILE__)