Last Updated: February 25, 2016
·
805
· lightguard

Rake, bundler and File.dirname(__FILE__)

I noticed the other day on a project I'm working on that tests would work fine when called by rake, but failed with bundle and guard. Turns out File.dirname(__FILE__) is based on the location of the initializing script. To fix the tests for all environments try this: File.dirname(File.realdirpath(__FILE__))