spring
spring copied to clipboard
Spring returns error after a few tries
I strart bin/rspec and the tests are executed correctly. Spring is started. Then I run again bin/rspec and the tests are executed correclty. At a certain point bin/rspec starts returning "unninitialized constant error" or db table does not exist.
Then I do a bin/spring stop bin/rspec my_test
and it again works correctly for a few runs and then starts returning an error. It happens almost immidiately to return an error if I stop the bin/rspec process with Crtl+C
Durring this time running just rspec my_test is successful.
I don`t know even where to start debuging this. What should I look for. What should I inspect.
I'm getting this too. Rails 3.2.21.
Probably related to #368.
For what it's worth, this seems to happen more frequently when using Guard.
this happens to me as well, even when using spring rspec and not binstubs
database foobar could come from reusing the same db connection ... on ctrl+c it might not be properly closed ... multi test constant foobar most likely from reloading ... try to find a pattern of changed files that trigger this ... turn SPRING_LOG=log/spring.log on to see more details
if you can reproduce anything try adding failing test ... from there it should be easy to fix
figured it out! these intermittent failures started happening once i enabled config.threadsafe! across all environments. i'm guessing this should be disabled with Spring because of its forking model?
@grosser is there a way I can check if Spring is preloading / running within config/application.rb, so that I can turn off thread safety only in the case that Spring is preloading?
defined?(Spring) should do
no idea why threadsafe would mess with spring though ... it's not using threads :D could be something weird that threadsafe triggers like more eager loading ...
@grosser the config.threadsafe! command in Rails 3 breaks Spring because it forces config.cache_classes to true.
adding this line in my test.rb fixed the issue:
if defined?(Spring::Commands::RSpec)
config.cache_classes = false
end