require 'rake'
require 'rspec/core/rake_task'

hosts = %w(
  dev-infra-dapc43-01
  dev-infra-jenkins-master-01
  dev-infra-manual-testing-01
  dev-infra-nexus-01
  dev-infra-openvpn1
  dev-infra-sentry-01
  dev-infra-sma-api-cache-warmup-01
  dev-infra-squid-01
)

task :spec => 'spec:all'

namespace :spec do
  task :all => hosts.map {|h| 'spec:' + h.split('.')[0] }
  hosts.each do |host|
    short_name = host.split('.')[0]

    desc "Run serverspec to #{host}"
    RSpec::Core::RakeTask.new(short_name) do |t|
      ENV['TARGET_HOST'] = host
      t.pattern = "spec/{base,qualys,splunk,tdms}/*_spec.rb"
      t.fail_on_error = false
    end
  end
end
