In Rails, how can I load all the code before a specific Rspec test?

I have some Rspec tests, which sometimes fail with an error: Circular dependency detected while autoloading constant. These tests are multi-threaded (rufus-scheduler tests), which seems to be a known issue for code autoload ( http://route.imtqy.com/2013/11/13/rails-autoloading.html ).

I can get the tests to run sequentially if I install config.eager_load = truein config / environment / test.rb. However, I am worried that this will really slow down the rest of my test suite when it gets larger. Is there any way to set this hot boot option ONLY for my multi-threaded tests?

Rails 4.1.4

+4
source share
1 answer

Add to {MyApp :: Application.eager_load! } as a setting for this file / package only. (Agreeing with @SterlingParamore above)

FYI: you need to put it in before{}, and not just in the body of the description, because otherwise it will happen whenever the file is downloaded (for example, even if you download this file, but target another specification with a tag, for example rspec spec --tag=focus).

config.eager_load = true test.rb config , Spring (, , ). , Spring, , https://github.com/rails/spring/issues/519, . *

0

All Articles