ruby-qa/lib/manager.rb

44 lines
839 B
Ruby

module RubyQA
class Manager
attr_reader :resources
@@tests = Array.new
def initialize
@hosts = Array.new
end
def add_host(host)
@hosts << host
register_resources(host)
update_resources(host)
end
def register_resources (host)
Resource.all_resources.each do |resource|
host.add_resource(resource)
end
end
def update_resources (host)
host.update_resources
end
def self.new_test(name, options={}, &test_proc)
@@tests << Test.new(name, **options, &test_proc)
end
def run_tests
@hosts.each do |host|
tests = @@tests.select{|test| test.valid_host(host)}
tests.each do |test|
test.run(host)
end
end
end
def report
puts @@tests.map(&:report).join("\n")
end
end
end