Last Updated: February 25, 2016
·
975
· 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__))

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

Guarding a web app includes the code that arrives in the browser, not only the code in source control. Tags and dependencies can change in production between deploys.

Security insights from Cside