Simpler Ruby on Rails Testing Environment
Ruby on Rails comes with a harmful practice damaging both decoupling functionality and the speed of tests. It loads “all the things” every time the environment boots up. This means reading Ruby sources from disk and compiling them for even a medium-sized application, which can be 1000s of files.
A simpler testing environment starts at the `spec_helper.rb` level. For example, Routemaster’s `spec_helper` is very short: it configures RSpec. It doesn’t load any code or “environment,” nor should it.
When writing a Ruby application (e.g., in a gem or a Sinatra app), dependencies are required. Each file requires only what it needs. Top-level files will load the necessary tree (`config.ru` will load `app.rb`, which will load the various controllers, which will load the models).
The same rules should apply to tests. Each test file should require a minimal version of `spec_helper.rb`. Any files in `spec/support` need to function. The object under test and support classes, e.g. dependencies to be injected. `spec_helper.rb` is loaded every time a partial test is run. The cost of adding unnecessary things to this file is enormous.