Merge pull request #735 from pmcmaw/rubocop
[puppet-modules/puppetlabs-apt.git] / spec / spec_helper_acceptance.rb
index 1160438d9a0236981f8c0c230e930448b5871eec..2ec2dba4b2201dcc270bf8a7b34d66d744755fea 100644 (file)
@@ -27,7 +27,8 @@ def puppet_version
   (on default, puppet('--version')).output.chomp
 end
 
-def run_puppet_access_login(user:, password: '~!@#$%^*-/ aZ', lifetime: '5y')
+def run_puppet_access_login(user:, password:
+                            '~!@#$%^*-/ aZ', lifetime: '5y')
   on(master, puppet('access', 'login', '--username', user, '--lifetime', lifetime), stdin: password)
 end
 
@@ -69,25 +70,21 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
   begin
     try += 1
     yield
-  rescue Exception => e
-    if try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher)
-      sleep retry_wait_interval_secs
-      retry
-    else
-      raise
-    end
+  rescue StandardError => e
+    raise unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher)
+    sleep retry_wait_interval_secs
+    retry
   end
 end
 
 RSpec.configure do |c|
-  # Project root
-  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+  File.expand_path(File.join(File.dirname(__FILE__), '..'))
 
   # Readable test descriptions
   c.formatter = :documentation
 
   # Configure all nodes in nodeset
   c.before :suite do
-    run_puppet_access_login(user: 'admin') if pe_install?
+    run_puppet_access_login(user: 'admin') if pe_install? && puppet_version =~ %r{(5\.\d\.\d)}
   end
 end