Skip to content

Commit 3f2b1e3

Browse files
committed
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 `<top (required)>' # ./spec/spec_helper_acceptance.rb:4:in `require' # ./spec/spec_helper_acceptance.rb:4:in `<top (required)>' # ./spec/acceptance/01_apt_class_spec.rb:3:in `require' # ./spec/acceptance/01_apt_class_spec.rb:3:in `<top (required)>' ```
1 parent df48cfd commit 3f2b1e3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

spec/spec_helper_acceptance.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'puppet_litmus'
4-
require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))
5-
64
PuppetLitmus.configure!
5+
6+
require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))

spec/spec_helper_acceptance_local.rb

+10-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
RETRY_WAIT = 3
66
ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)}.freeze
77

8-
# lsb-release is needed for facter 3 (puppet 6) to resolve os.distro facts. Not needed with facter
9-
# 4 (puppet 7).
10-
lsb_package = <<-MANIFEST
8+
RSpec.configure do |c|
9+
c.before :suite do
10+
# lsb-release is needed for facter 3 (puppet 6) to resolve os.distro facts. Not needed with facter
11+
# 4 (puppet 7).
12+
lsb_package = <<-MANIFEST
1113
package { 'lsb-release':
1214
ensure => installed,
1315
}
1416
MANIFEST
15-
16-
include PuppetLitmus
17-
apply_manifest(lsb_package)
17+
include PuppetLitmus
18+
extend PuppetLitmus
19+
apply_manifest(lsb_package)
20+
end
21+
end
1822

1923
# This method allows a block to be passed in and if an exception is raised
2024
# that matches the 'error_matcher' matcher, the block will wait a set number

0 commit comments

Comments
 (0)