Class: SetupBeaker

Inherits:
Object
  • Object
show all
Defined in:
lib/puppetlabs_spec_helper/tasks/beaker.rb

Class Method Summary collapse

Class Method Details

.setup_beaker(t) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/puppetlabs_spec_helper/tasks/beaker.rb', line 61

def self.setup_beaker(t)
  t.rspec_opts = ['--color']
  t.pattern = 'spec/acceptance'
  # TEST_TIERS env variable is a comma separated list of tiers to run. e.g. low, medium, high
  if ENV['TEST_TIERS']
    test_tiers = ENV['TEST_TIERS'].split(',')
    test_tiers_allowed = ENV.fetch('TEST_TIERS_ALLOWED', 'low,medium,high').split(',')
    raise 'TEST_TIERS env variable must have at least 1 tier specified. Either low, medium or high or one of the tiers listed in TEST_TIERS_ALLOWED (comma separated).' if test_tiers.count == 0
    test_tiers.each do |tier|
      tier_to_add = tier.strip.downcase
      raise "#{tier_to_add} not a valid test tier." unless test_tiers_allowed.include?(tier_to_add)
      tiers = "--tag tier_#{tier_to_add}"
      t.rspec_opts.push(tiers)
    end
  else
    puts 'TEST_TIERS env variable not defined. Defaulting to run all tests.'
  end
  t
end