Class: Moto::Test::MetadataGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/test/metadata_generator.rb

Class Method Summary collapse

Class Method Details

.generate(directories = nil, tags = nil, filters = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/test/metadata_generator.rb', line 13

def self.generate(directories = nil, tags = nil, filters = nil)
   = []

  if directories
    directories.each do |directory|
      Dir.glob("#{MotoApp::DIR}/tests/#{directory}/**/*.rb").each do |test_path|
         << Moto::Test::.new(test_path)
      end
    end
  end

  if tags
    tests_total = Dir.glob("#{MotoApp::DIR}/tests/**/*.rb")
    tests_total.each do |test_path|

       = Moto::Test::.new(test_path)
       <<  unless (tags & .tags).empty?

    end
  end

  # Make sure there are no repetitions in gathered set
  .uniq! {|| .test_path}

  # Filter tests by provied tags
  # - test must contain ALL tags specified with -f param
  # - use ~ for negation
  # - test may contain other tags
  if filters
    filters.each do |filter|
      filtered = .select do ||
        next if .tags.empty?
        filter_matches_any_tag?(filter, .tags) || filter_negation_matches_none_tag?(filter, .tags)
      end
       &= filtered
    end
  end

  # TODO: THIS SHOULDN'T BE HERE - REMNANT OF THE PAST
  # Requires custom initializer if provided by application that uses Moto
  if File.exists?("#{MotoApp::DIR}/lib/initializer.rb")
    require("#{MotoApp::DIR}/lib/initializer.rb")
    initializer = MotoApp::Lib::Initializer.new
    initializer.init
  end

  return 
end