We have a pretty large test/test_helper.rb
file, which does quite a few unrelated things. Is there a "Rails way" to decompose it into subfiles, stored in some conventional location?
I tried searching the official docs, but couldn't find anything. Any help appreciated!
We do this in our spec/spec_helper.rb
(using RSpec rather than Minitest, but the same principle should apply):
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each do |file|
require file
end
We then have different configuration files such as spec/support/vcr.rb
, spec/support/redis.rb
, etc.
edit: This actually came from the file generated by rspec-rails
. Here is that line as of RSpec 3.9:
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }