Cleanup via rubocop of ruby code
[puppet-modules/puppetlabs-apt.git] / spec / spec_helper_acceptance.rb
1 require 'beaker-rspec'
2 require 'beaker/puppet_install_helper'
3 require 'beaker/module_install_helper'
4
5 run_puppet_install_helper
6 install_module_on(hosts)
7 install_module_dependencies_on(hosts)
8
9 UNSUPPORTED_PLATFORMS = %w[RedHat Suse windows AIX Solaris].freeze
10
11 # This method allows a block to be passed in and if an exception is raised
12 # that matches the 'error_matcher' matcher, the block will wait a set number
13 # of seconds before retrying.
14 # Params:
15 # - max_retry_count - Max number of retries
16 # - retry_wait_interval_secs - Number of seconds to wait before retry
17 # - error_matcher - Matcher which the exception raised must match to allow retry
18 # Example Usage:
19 # retry_on_error_matching(3, 5, /OpenGPG Error/) do
20 #   apply_manifest(pp, :catch_failures => true)
21 # end
22 def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, error_matcher = nil)
23   try = 0
24   begin
25     try += 1
26     yield
27   rescue Exception => e
28     if try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher)
29       sleep retry_wait_interval_secs
30       retry
31     else
32       raise
33     end
34   end
35 end
36
37 RSpec.configure do |c|
38   # Project root
39   proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
40
41   # Readable test descriptions
42   c.formatter = :documentation
43 end