Failing fast in rails with a smoke test initializer
11 Sep 2012The Rails app that I’m working on has a dependency on ImageMagick. In fact, if ImageMagick is either missing or broken in the app’s environment, the app is beyond repair and Rails shouldn’t even start.
To achieve this, I have added an initializer under config/initializers/dependency_tests.rb
:
Note : this particular example is specific to ruby 1.9.3 (in the way that minitest
is used) but can be easily adapted to other versions of ruby.
If the test fails, then its error messages are rethrown on the console. This approach has already saved me quite a few minutes of troubleshooting (most recently yesterday when I was bringing everything up to scratch post the Mountain Lion upgrade).