Class: LiveUnit::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/liveunit/loader.rb

Overview

loads all the required test files when the <evaluate_me> method is called

Instance Method Summary collapse

Instance Method Details

#require_directory(dir, add_to_load_path = false, skip_invalid_syntax = false) ⇒ Object

extracted from require_directory gem



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/liveunit/loader.rb', line 7

def require_directory(dir, add_to_load_path = false, skip_invalid_syntax = false)
  raise "Not a directory: #{dir}" unless File.directory?(dir)
  if add_to_load_path
    $LOAD_PATH << dir
  end
  Dir.glob(File.join(dir + '/**/*.rb')).each do |file|
    if (skip_invalid_syntax && !(`/usr/bin/env ruby -c #{file}` =~ /Syntax OK/m))
      warn "Invalid syntax in: #{file}"
      next
    end
    require file
  end
end