From 3f2b1e3ff0ac3bb11526d61d935483e3a2d7d89b Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 26 Jan 2021 18:21:04 +0000 Subject: [PATCH] Wrap apply_manifest into RSpec context; initialise litmus earlier This fixes the following error by exposing the necessary PuppetLitmus context: ``` An error occurred while loading ./spec/acceptance/01_apt_class_spec.rb. Failure/Error: apply_manifest(lsb_package) NameError: undefined local variable or method `os' for main:Object # ./vendor/bundle/ruby/2.5.0/gems/puppet_litmus-0.22.0/lib/puppet_litmus/puppet_helpers.rb:86:in `block in apply_manifest' # ./vendor/bundle/ruby/2.5.0/gems/honeycomb-beeline-2.4.0/lib/honeycomb/client.rb:70:in `start_span' # ./vendor/bundle/ruby/2.5.0/gems/puppet_litmus-0.22.0/lib/puppet_litmus/puppet_helpers.rb:41:in `apply_manifest' # ./spec/spec_helper_acceptance_local.rb:17:in `' # ./spec/spec_helper_acceptance.rb:4:in `require' # ./spec/spec_helper_acceptance.rb:4:in `' # ./spec/acceptance/01_apt_class_spec.rb:3:in `require' # ./spec/acceptance/01_apt_class_spec.rb:3:in `' ``` --- spec/spec_helper_acceptance.rb | 4 ++-- spec/spec_helper_acceptance_local.rb | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 4ac8d7e..73a0238 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true require 'puppet_litmus' -require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) - PuppetLitmus.configure! + +require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index cc3fc3f..6f7777c 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -5,16 +5,20 @@ MAX_RETRY_COUNT = 5 RETRY_WAIT = 3 ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)}.freeze -# lsb-release is needed for facter 3 (puppet 6) to resolve os.distro facts. Not needed with facter -# 4 (puppet 7). -lsb_package = <<-MANIFEST +RSpec.configure do |c| + c.before :suite do + # lsb-release is needed for facter 3 (puppet 6) to resolve os.distro facts. Not needed with facter + # 4 (puppet 7). + lsb_package = <<-MANIFEST package { 'lsb-release': ensure => installed, } MANIFEST - -include PuppetLitmus -apply_manifest(lsb_package) + include PuppetLitmus + extend PuppetLitmus + apply_manifest(lsb_package) + end +end # This method allows a block to be passed in and if an exception is raised # that matches the 'error_matcher' matcher, the block will wait a set number -- 2.32.3