module RSpec::Core::RubyProject

def add_dir_to_load_path(dir)

def add_dir_to_load_path(dir)
  $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
end

def add_to_load_path(*dirs)

def add_to_load_path(*dirs)
  dirs.map {|dir| add_dir_to_load_path(File.join(root, dir))}
end

def ascend_until

def ascend_until
  Pathname(File.expand_path('.')).ascend do |path|
    return path if yield(path)
  end
end

def determine_root

def determine_root
  find_first_parent_containing('spec') || '.'
end

def find_first_parent_containing(dir)

def find_first_parent_containing(dir)
  ascend_until {|path| File.exists?(File.join(path, dir))}
end

def root

def root
  @project_root ||= determine_root
end