Reputation: 1834
I have an after_create_commit
callback on my model, Foo, which looks like this:
after_create_commit { LogBroadcastJob.perform_later self }
I've reduced my perform
method to return nil
to simplify things.
When I create a Foo instance in an RSpec test with factory_girl, the test suite freezes. This only happens when I test models with that callback.
FactoryGirl.create :foo
When I Ctl+C out of my test suite it fails to kill the process. I have to find the process, which is still using my database (Postgresql), and kill it, which means that I don't see any errors on the command line. If I run my test suite again, it creates another process that I have to find and kill.
Does this sound familiar to anyone? How would I find useful errors here?
Maybe relevant: I upgraded from Rails 4.2 to 5.0.0.1 a while back.
Upvotes: 0
Views: 234
Reputation: 1834
This was a concurrency issue. Thanks to the resource provided in @coreyward's comment, I was able to clear this up by setting config/environments/test.rb to
config.eager_load = true
This differs from my config in config/environments/development.rb (and everything works in development), so I can't say I understand yet why it works. But I can now run all my tests with bundle exec guard
or bundle exec rake spec
.
Upvotes: 3