Ensuring executable command doesn't point to a directory

Ensuring executable command is not only executable as per Ruby's File class but also an actual file (and not a directory). My bower:update rake task was failing because it was pointing to the bower directory in one of my exec paths and not to the actual executable file. Turns out File.executable? returns true for directories too if they have the right permissions.