-
Notifications
You must be signed in to change notification settings - Fork 346
Description
When I set eager_load = true in config/environments/test.rb
then after spring is loaded and any file is changed then running specs again will fail with a message like "uninitialized constant User (NameError)".
I created simple rails project repository to reproduce it: https://github.com/radarek/rails_rspec_spring_eager_load_bug. It's pure rails project. I added only gems rspec-rails and spring-commands-rspec and generated User
model. When I run bin/rspec
specs pass, running it again still gives success. But after modifying app/models/user.rb
file and running it again it will fail with a message user_spec.rb:3:in
<top (required)>': uninitialized constant User (NameError)`.
I know that doesn't have to be a problem with spring itself but it's hard to guess what it causes.
Steps to reproduce:
$ git clone git@github.com:radarek/rails_rspec_spring_eager_load_bug.git
$ cd rails_rspec_spring_eager_load_bug
$ bin/rails db:migrate RAILS_ENV=test
$ bin/rspec
Running via Spring preloader in process 81040
.
Finished in 0.00345 seconds (files took 0.38525 seconds to load)
1 example, 0 failures
$ bin/rspec
Running via Spring preloader in process 81140
.
Finished in 0.00326 seconds (files took 0.3545 seconds to load)
1 example, 0 failures
$ echo "# comment" >> app/models/user.rb
$ bin/rspec
Running via Spring preloader in process 81305
/Users/radarek/programming/github/radarek/rails_rspec_spring_eager_load_bug/spec/models/user_spec.rb:3:in `<top (required)>': uninitialized constant User (NameError)
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
from /Users/radarek/.rbenv/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `load'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/command_wrapper.rb:38:in `call'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/application.rb:191:in `block in serve'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/application.rb:161:in `fork'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/application.rb:161:in `serve'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/application.rb:131:in `block in run'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/application.rb:125:in `loop'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/application.rb:125:in `run'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/radarek/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'