3 describe 'validate_absolute_path' do
5 ENV.delete('STDLIB_LOG_DEPRECATIONS')
8 # Checking for deprecation warning
9 it 'displays a single deprecation' do
10 ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
11 expect(scope).to receive(:warning).with(include('This method is deprecated'))
12 is_expected.to run.with_params('c:/')
15 describe 'signature validation' do
16 it { is_expected.not_to eq(nil) }
17 it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
20 describe 'valid paths handling' do
21 ['C:/', 'C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', '//host/windows', '/', '/var/tmp', '/var/opt/../lib/puppet'].each do |path|
22 it { is_expected.to run.with_params(path) }
23 it { is_expected.to run.with_params(['/tmp', path]) }
27 describe 'invalid path handling' do
28 context 'with garbage inputs' do
37 it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
38 it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
39 it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
43 context 'with relative paths' do
44 ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'opt/puppet/bin', 'relative\\windows'].each do |path|
45 it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
46 it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
47 it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }