Class: Tack::TestSet

Inherits:
Object
  • Object
show all
Defined in:
lib/tack/test_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(root_dir) ⇒ TestSet

Returns a new instance of TestSet.



5
6
7
# File 'lib/tack/test_set.rb', line 5

def initialize(root_dir)
  @root_dir = root_dir
end

Instance Method Details

#tests_for(paths, pattern = TestPattern.new) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tack/test_set.rb', line 9

def tests_for(paths, pattern=TestPattern.new)
  paths = Array(paths).map { |path| path.to_s}
  files = paths.inject([]) do |files, path|
    if File.directory?(path)
      files += Dir[File.join(path,"**/*")].select {|f| valid_test_file?(f)}
    else
      files << path
    end
  end

  files.inject([]) do |tests, file|
    adapter = Adapters::Adapter.for(file)
    tests += adapter.tests_for(file, pattern)
  end
end