diff --git a/lib/rspec-puppet/spec_helper.rb b/lib/rspec-puppet/spec_helper.rb index 541391ecc..2ac5db142 100644 --- a/lib/rspec-puppet/spec_helper.rb +++ b/lib/rspec-puppet/spec_helper.rb @@ -5,8 +5,7 @@ fixture_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures') RSpec.configure do |c| - c.module_path = File.join(fixture_path, 'modules') - c.manifest_dir = File.join(fixture_path, 'manifests') - c.manifest = File.join(fixture_path, 'manifests', 'site.pp') - c.environmentpath = File.join(Dir.pwd, 'spec') + c.module_path = File.join(__dir__, 'fixtures', 'modules') + c.manifest = File.join(fixture_path, 'manifests', 'site.pp') + c.environmentpath = __dir__ end diff --git a/spec/classes/server_facts_spec.rb b/spec/classes/server_facts_spec.rb index 6b90a53f7..6304fafcd 100644 --- a/spec/classes/server_facts_spec.rb +++ b/spec/classes/server_facts_spec.rb @@ -15,11 +15,10 @@ end let(:node) { 'test123.test.com' } - it { is_expected.to contain_class('server_facts') } - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_notify('servername-test123.test.com') } - it { is_expected.to contain_notify('serverip-192.168.1.10') } - it { is_expected.to contain_notify("serverversion-#{Puppet.version}") } - it { is_expected.to contain_notify('environment-rp_env') } - end + it { is_expected.to contain_class('server_facts') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_notify('servername-test123.test.com') } + it { is_expected.to contain_notify('serverip-192.168.1.10') } + it { is_expected.to contain_notify("serverversion-#{Puppet.version}") } + it { is_expected.to contain_notify('environment-rp_env') } end diff --git a/spec/unit/adapters_spec.rb b/spec/unit/adapters_spec.rb index 5a8ba2b1b..15ee84463 100644 --- a/spec/unit/adapters_spec.rb +++ b/spec/unit/adapters_spec.rb @@ -31,6 +31,25 @@ def context_double(options = {}) end end + it 'sets Puppet[:strict_variables] to false by default' do + subject.setup_puppet(context_double) + # strict variables enabled by default in puppet 8.x + + setting = Puppet::Util::Package.versioncmp(Puppet.version, '8.0.0') >= 0 + expect(Puppet[:strict_variables]).to be(setting) + end + + it 'reads the :strict_variables setting' do + context = context_double strict_variables: true + subject.setup_puppet(context) + expect(Puppet[:strict_variables]).to be(true) + end + + it 'overrides the environmentpath set by Puppet::Test::TestHelper' do + context = context_double environmentpath: '/path/to/my/environments' + subject.setup_puppet(context) + expect(Puppet[:environmentpath]).to match(%r{(C:)?/path/to/my/environments}) + end + describe '#set_setting' do describe 'with a context specific setting' do it 'sets the Puppet setting based on the example group setting' do diff --git a/spec/unit/matchers/compile_spec.rb b/spec/unit/matchers/compile_spec.rb index 4b1e9c84b..335520c42 100644 --- a/spec/unit/matchers/compile_spec.rb +++ b/spec/unit/matchers/compile_spec.rb @@ -172,10 +172,10 @@ } end - context 'when expecting the failure' do - let(:expected_error) do - "Evaluation Error: Error while evaluating a Function Call, #{error_detail} on node rspec::puppet::manifestmatchers::compile" - end + context 'when expecting the failure' do + let(:expected_error) do + 'Evaluation Error: Error while evaluating a Function Call, failure (line: 52, column: 1) on node rspec::puppet::manifestmatchers::compile' + end before { subject.and_raise_error(expected_error) }