source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/functions/validate_absolute_path_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 7 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1require 'spec_helper'
2
3describe 'validate_absolute_path' do
4 after(:all) do
5 ENV.delete('STDLIB_LOG_DEPRECATIONS')
6 end
7
8 # Checking for deprecation warning
9 it 'should display a single deprecation' do
10 ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
11 scope.expects(:warning).with(includes('This method is deprecated'))
12 is_expected.to run.with_params('c:/')
13 end
14
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, /wrong number of arguments/i) }
18 end
19
20 describe "valid paths handling" do
21 %w{
22 C:/
23 C:\\
24 C:\\WINDOWS\\System32
25 C:/windows/system32
26 X:/foo/bar
27 X:\\foo\\bar
28 \\\\host\\windows
29 //host/windows
30 /
31 /var/tmp
32 /var/opt/../lib/puppet
33 }.each do |path|
34 it { is_expected.to run.with_params(path) }
35 it { is_expected.to run.with_params(['/tmp', path]) }
36 end
37 end
38
39 describe 'invalid path handling' do
40 context 'garbage inputs' do
41 [
42 nil,
43 [ nil ],
44 [ nil, nil ],
45 { 'foo' => 'bar' },
46 { },
47 '',
48 ].each do |path|
49 it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
50 it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
51 it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
52 end
53 end
54
55 context 'relative paths' do
56 %w{
57 relative1
58 .
59 ..
60 ./foo
61 ../foo
62 etc/puppetlabs/puppet
63 opt/puppet/bin
64 relative\\windows
65 }.each do |path|
66 it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
67 it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
68 it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
69 end
70 end
71 end
72end
73
Note: See TracBrowser for help on using the repository browser.