Skip to content

Instantly share code, notes, and snippets.

@henrik
Created April 8, 2010 12:23
Show Gist options
  • Save henrik/360028 to your computer and use it in GitHub Desktop.
Save henrik/360028 to your computer and use it in GitHub Desktop.
Find the closest spec_helper.rb, in the _root_ dir or an ancestor.
root = '/Users/henrik/Sites/auktion/spec/models/auction'
max = root.scan('/').length + 1
x = max.times { |i|
path = "#{root}/#{'../'*i}spec_helper.rb"
unless (found = Dir[path]).empty?
break(File.expand_path(found.first))
end
}
p x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment