Skip to content

Commit

Permalink
Use rspec-puppet settings to configure Puppet
Browse files Browse the repository at this point in the history
rspec-puppet exposes config options for strict_variables and ordering
(though ordering is dead since Puppet 6). Using these is better than
directly configuring Puppet.

The strict_variables statement is simplified to remove redundant logic.
  • Loading branch information
ekohl committed Apr 19, 2023
1 parent 1f86cf6 commit 82f3760
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/puppetlabs_spec_helper/module_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ def verify_contents(subject, title, expected_lines)
c.module_path = module_path
c.manifest_dir = File.join(fixture_path, 'manifests')

# https://github.com/puppetlabs/rspec-puppet#strict_variables
c.strict_variables = ENV['STRICT_VARIABLES'] != 'no'
# https://github.com/puppetlabs/rspec-puppet#ordering
c.ordering = ENV['ORDERING'] if ENV['ORDERING']

c.before :each do
if c.mock_framework.framework_name == :rspec
allow(Puppet.features).to receive(:root?).and_return(true)
else
Puppet.features.stubs(:root?).returns(true)
end

Puppet.settings[:strict_variables] = true if ENV['STRICT_VARIABLES'] == 'yes' || ENV['STRICT_VARIABLES'] != 'no'
Puppet.settings[:ordering] = ENV['ORDERING'] if ENV['ORDERING']
end
end

0 comments on commit 82f3760

Please sign in to comment.