Should I enable or disable downloads in a test environment?

This is in standard test.rb:

# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false

Does this advice make sense when running the entire test suite, or only when running a single test?

How do I decide whether to enable or disable?

Is there a great recipe for it to be false when running individual tests and true when running the whole package?

(I suspiciously that some types of errors I get are the result of being disabled)

+5
source share
1 answer

Hard loading is applied for each test, therefore, even if you run the entire test suite.

, , (, ), , eager_loading true .

eager_loading false true - :

# config/environments/test.rb

  config.eager_load = !!(ENV['ENABLE_SPRING'] == 'true')

,

$ ENABLE_SPRING=true bundle exec rspec spec/test_name.rb

: + https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoloading-in-the-test-environment.

0

All Articles