Sha256: 9a4102440546ad61c5366cdd0e2ef7c84a188b870063e3d5b8a6045cc943739a

Contents?: true

Size: 931 Bytes

Versions: 9

Compression:

Stored size: 931 Bytes

Contents

__END__

module Etest::Grep
  def self.load_from_directories(*dirs)
    raise ArgumentError, "Missing directories" if dirs.empty?
    # -- collect tests

    STDERR.puts "\nLoad etests"

    etests = []
    rex = /^\s*module\s+(\S*\bEtest\b)/

    dirs.each do |dir|
      File.grep(rex, Dir.glob("#{dir}/**/*.rb")) do |_, _, matches|
        etests << matches[1]
      end
    end

    etests = etests.uniq.sort

    # -- load tests

    etests = etests.uniq.sort.each do |etest|
      mod = etest.constantize rescue nil
      next STDERR.puts("  #{etest}: cannot load test") unless mod
  
      tests = mod.instance_methods.select { |m| m =~ /^test_/ }

      next STDERR.puts("  #{etest}: Does not define any tests") if tests.empty?

      STDERR.puts("  #{etest}: w/#{tests.length} tests")

      klass = Class.new(Mpx::TestCase)
      klass.send :include, mod

      mod.const_set("TestCase", klass)
    end.compact
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
etest-0.6.3 lib/etest/grep.rb
etest-0.6.2 lib/etest/grep.rb
etest-0.6.1 lib/etest/grep.rb
etest-0.6.0 lib/etest/grep.rb
etest-0.4.2 lib/etest/grep.rb
etest-0.4.1 lib/etest/grep.rb
etest-0.4 lib/etest/grep.rb
etest-0.3.1 lib/etest/grep.rb
etest-0.1 lib/etest/grep.rb