Split `spec_helper` out from `chef_helper`
Summary
We have a chef_helper
to configure rspec, and chefspec, and add a bunch of local macros. It is heavy and for testing just ruby libraries it's overkill.
Extract the common rspec things we need out from chef_helper
into a spec_helper
and use that for testing libraries/ruby modules.
Proposal
When running a single rspec file that exercises some simple ruby classes:
$ bundle exec rspec spec/gitlab/build/metrics_spec.rb
...
Finished in 0.29399 seconds (files took 2.51 seconds to load)
After just removing the call to chef_helper
$ bundle exec rspec spec/gitlab/build/metrics_spec.rb
...
Finished in 0.03124 seconds (files took 0.43861 seconds to load)
I draw your attention to the final part of the run. 2.51 seconds to load vs 0.43861 seconds to load. This is quite some time we can claw back from the code/test cycle on our workstations, and make running subsets of the tests feel snappier.
A simple removal isn't quite right though, as the chef_helper
does also bring in important configurations such as the knapsack setup, and some other parts of rspec configuration, so we still need a place to put that.
To that end though I propose we extract spec_helper
(or libraries_helper
or some other better name) which is the minimal subset of rspec extensions, require that chef_helper
, and move the lighter libraries testing over to just use spec_helper
Potential downsides:
- After re-adding the useful common extensions it's not that much of a saving
- Adds a little complexity about where the correct helper to add things to is