File: path_setting_spec.rb

package info (click to toggle)
puppet-agent 7.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,092 kB
  • sloc: ruby: 245,074; sh: 456; makefile: 38; xml: 33
file content (29 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'spec_helper'

describe Puppet::Settings::PathSetting do
  subject { described_class.new(:settings => double('settings'), :desc => "test") }

  context "#munge" do
    it "should expand all path elements" do
      munged = subject.munge("hello#{File::PATH_SEPARATOR}good/morning#{File::PATH_SEPARATOR}goodbye")
      munged.split(File::PATH_SEPARATOR).each do |p|
        expect(Puppet::Util).to be_absolute_path(p)
      end
    end

    it "should leave nil as nil" do
      expect(subject.munge(nil)).to be_nil
    end

    context "on Windows", :if => Puppet::Util::Platform.windows? do
      it "should convert \\ to /" do
        expect(subject.munge('C:\test\directory')).to eq('C:/test/directory')
      end

      it "should work with UNC paths" do
        expect(subject.munge('//localhost/some/path')).to eq('//localhost/some/path')
        expect(subject.munge('\\\\localhost\some\path')).to eq('//localhost/some/path')
      end
    end
  end
end