diff options
| author | Jacob Helwig <jacob@puppetlabs.com> | 2011-08-02 17:05:10 -0700 |
|---|---|---|
| committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-08-02 17:05:10 -0700 |
| commit | 11b4d2ddcc240e1d3ea4106c984ef98e6de9b653 (patch) | |
| tree | accb62eb82b2dfda19f386b57bf0c267f9c993bb /spec | |
| parent | e9233b67a5d73852d89eb2e14dcf5255fe082a6a (diff) | |
| parent | 447c1171845d8d17e4e684c9508fddecc003d15e (diff) | |
| download | puppet-11b4d2ddcc240e1d3ea4106c984ef98e6de9b653.tar.gz puppet-11b4d2ddcc240e1d3ea4106c984ef98e6de9b653.tar.xz puppet-11b4d2ddcc240e1d3ea4106c984ef98e6de9b653.zip | |
Merge branch 'file-test-on-windows'
* file-test-on-windows:
Check for the appropriate permissions in File type tests on Windows
Remove :fails_on_windows from file type tests that no longer fail on Windows
Disable file bucket diffing tests on Windows
Always put a slash between the checksum and path in filebucket URLs
Treat Windows absolute paths as absolute paths
Consolidate test logic determining if a registered file is in the temp directory
Clarify logic and error messages when initializing Puppet::FileBucket::File
Disable symlink related file tests on Windows
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/integration/type/file_spec.rb | 30 | ||||
| -rwxr-xr-x | spec/lib/puppet_spec/files.rb | 18 | ||||
| -rwxr-xr-x | spec/unit/file_bucket/dipper_spec.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/file_bucket/file_spec.rb | 12 | ||||
| -rwxr-xr-x | spec/unit/indirector/file_bucket_file/file_spec.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/type/file_spec.rb | 380 |
6 files changed, 198 insertions, 246 deletions
diff --git a/spec/integration/type/file_spec.rb b/spec/integration/type/file_spec.rb index 241861cc5..9814c4539 100755 --- a/spec/integration/type/file_spec.rb +++ b/spec/integration/type/file_spec.rb @@ -73,7 +73,7 @@ describe Puppet::Type.type(:file) do File.read(file[:path]).should == "bar\n" end - it "should not backup symlinks", :fails_on_windows => true do + it "should not backup symlinks", :unless => Puppet.features.microsoft_windows? do link = tmpfile("link") dest1 = tmpfile("dest1") dest2 = tmpfile("dest2") @@ -214,7 +214,7 @@ describe Puppet::Type.type(:file) do end end - it "should be able to recursively make links to other files", :fails_on_windows => true do + it "should be able to recursively make links to other files", :unless => Puppet.features.microsoft_windows? do source = tmpfile("file_link_integration_source") build_path(source) @@ -289,23 +289,24 @@ describe Puppet::Type.type(:file) do (File.stat(file).mode & 007777).should == 0644 end - it "should recursively manage files even if there is an explicit file whose name is a prefix of the managed file", :fails_on_windows => true do + it "should recursively manage files even if there is an explicit file whose name is a prefix of the managed file" do dir = tmpfile("recursion_vs_explicit_2") - managed = File.join(dir, "file") - generated = File.join(dir, "file_with_a_name_starting_with_the_word_file") + managed = File.join(dir, "file") + generated = File.join(dir, "file_with_a_name_starting_with_the_word_file") + managed_mode = Puppet.features.microsoft_windows? ? 0444 : 0700 FileUtils.mkdir_p(dir) File.open(managed, "w") { |f| f.puts "" } File.open(generated, "w") { |f| f.puts "" } @catalog = Puppet::Resource::Catalog.new - @catalog.add_resource Puppet::Type::File.new(:name => dir, :recurse => true, :backup => false, :mode => "755") + @catalog.add_resource Puppet::Type::File.new(:name => dir, :recurse => true, :backup => false, :mode => managed_mode) @catalog.add_resource Puppet::Type::File.new(:name => managed, :recurse => true, :backup => false, :mode => "644") @catalog.apply - (File.stat(generated).mode & 007777).should == 0755 + (File.stat(generated).mode & 007777).should == managed_mode end end @@ -349,7 +350,7 @@ describe Puppet::Type.type(:file) do describe "when copying files" do # Ticket #285. - it "should be able to copy files with pound signs in their names", :fails_on_windows => true do + it "should be able to copy files with pound signs in their names" do source = tmpfile("filewith#signs") dest = tmpfile("destwith#signs") @@ -366,7 +367,7 @@ describe Puppet::Type.type(:file) do File.read(dest).should == "foo" end - it "should be able to copy files with spaces in their names", :fails_on_windows => true do + it "should be able to copy files with spaces in their names" do source = tmpfile("filewith spaces") dest = tmpfile("destwith spaces") @@ -381,11 +382,12 @@ describe Puppet::Type.type(:file) do catalog.apply + expected_mode = Puppet.features.microsoft_windows? ? 0644 : 0755 File.read(dest).should == "foo" - (File.stat(dest).mode & 007777).should == 0755 + (File.stat(dest).mode & 007777).should == expected_mode end - it "should be able to copy individual files even if recurse has been specified", :fails_on_windows => true do + it "should be able to copy individual files even if recurse has been specified" do source = tmpfile("source") dest = tmpfile("dest") @@ -434,7 +436,7 @@ describe Puppet::Type.type(:file) do File.read(dest).should == "this is some content, yo" end - it "should delete files with sources but that are set for deletion", :fails_on_windows => true do + it "should delete files with sources but that are set for deletion" do dest = tmpfile("dest_source_with_ensure") source = tmpfile("source_source_with_ensure") File.open(source, "w") { |f| f.puts "yay" } @@ -455,7 +457,7 @@ describe Puppet::Type.type(:file) do File.should_not be_exist(dest) end - describe "when purging files", :fails_on_windows => true do + describe "when purging files" do before do @sourcedir = tmpfile("purge_source") @destdir = tmpfile("purge_dest") @@ -470,7 +472,6 @@ describe Puppet::Type.type(:file) do # this file should get removed File.open(@purgee, "w") { |f| f.puts "footest" } - @lfobj = Puppet::Type.newfile( :title => "localfile", :path => @localfile, @@ -479,7 +480,6 @@ describe Puppet::Type.type(:file) do :backup => false ) - @destobj = Puppet::Type.newfile( :title => "destdir", :path => @destdir, diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb index 9e75d3142..725bf2af9 100755 --- a/spec/lib/puppet_spec/files.rb +++ b/spec/lib/puppet_spec/files.rb @@ -1,21 +1,19 @@ require 'fileutils' require 'tempfile' +require 'pathname' # A support module for testing files. module PuppetSpec::Files # This code exists only to support tests that run as root, pretty much. # Once they have finally been eliminated this can all go... --daniel 2011-04-08 - if Puppet.features.posix? then - def self.in_tmp(path) - path =~ /^\/tmp/ or path =~ /^\/var\/folders/ - end - elsif Puppet.features.microsoft_windows? - def self.in_tmp(path) - tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp")) - path =~ /^#{tempdir}/ + def self.in_tmp(path) + tempdir = Dir.tmpdir + + Pathname.new(path).ascend do |dir| + return true if File.identical?(tempdir, dir) end - else - fail "Help! Can't find in_tmp for this platform" + + false end def self.cleanup diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb index 431b12371..605719324 100755 --- a/spec/unit/file_bucket/dipper_spec.rb +++ b/spec/unit/file_bucket/dipper_spec.rb @@ -91,7 +91,7 @@ describe Puppet::FileBucket::Dipper do [request1, request2].each do |r| r.server.should == 'puppetmaster' r.port.should == 31337 - r.key.should == "md5/#{checksum}#{real_path}" + r.key.should == "md5/#{checksum}/#{real_path}" end end diff --git a/spec/unit/file_bucket/file_spec.rb b/spec/unit/file_bucket/file_spec.rb index c4444ae77..ebf02438c 100755 --- a/spec/unit/file_bucket/file_spec.rb +++ b/spec/unit/file_bucket/file_spec.rb @@ -26,11 +26,17 @@ describe Puppet::FileBucket::File do it "should raise an error if changing content" do x = Puppet::FileBucket::File.new("first") - proc { x.contents = "new" }.should raise_error + expect { x.contents = "new" }.to raise_error(NoMethodError, /undefined method .contents=/) end it "should require contents to be a string" do - proc { Puppet::FileBucket::File.new(5) }.should raise_error(ArgumentError) + expect { Puppet::FileBucket::File.new(5) }.to raise_error(ArgumentError, /contents must be a String, got a Fixnum$/) + end + + it "should complain about options other than :bucket_path" do + expect { + Puppet::FileBucket::File.new('5', :crazy_option => 'should not be passed') + }.to raise_error(ArgumentError, /Unknown option\(s\): crazy_option/) end it "should set the contents appropriately" do @@ -61,7 +67,7 @@ describe Puppet::FileBucket::File do it "should reject a url-ish name with an invalid checksum" do bucket = Puppet::FileBucket::File.new(@contents) - lambda { bucket.name = "sha1/4a8ec4fa5f01b4ab1a0ab8cbccb709f0/new/path" }.should raise_error + expect { bucket.name = "sha1/4a8ec4fa5f01b4ab1a0ab8cbccb709f0/new/path" }.to raise_error(NoMethodError, /undefined method .name=/) end it "should convert the contents to PSON" do diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb index eb86eee85..808da17d8 100755 --- a/spec/unit/indirector/file_bucket_file/file_spec.rb +++ b/spec/unit/indirector/file_bucket_file/file_spec.rb @@ -111,7 +111,7 @@ describe Puppet::FileBucketFile::File do end end - describe "when diffing files" do + describe "when diffing files", :unless => Puppet.features.microsoft_windows? do it "should generate an empty string if there is no diff" do checksum = save_bucket_file("I'm the contents of a file") Puppet::FileBucket::File.indirection.find("md5/#{checksum}", :diff_with => checksum).should == '' diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 6be8acfca..65c7a091c 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -37,7 +37,6 @@ describe Puppet::Type.type(:file) do end describe "#write" do - it "should propagate failures encountered when renaming the temporary file" do File.stubs(:open) @@ -92,7 +91,6 @@ describe Puppet::Type.type(:file) do lambda { @file.write :NOTUSED }.should_not raise_error(Puppet::Error) end - end end @@ -152,254 +150,204 @@ describe Puppet::Type.type(:file) do end describe "when using POSIX filenames" do - describe "on POSIX systems" do - before do - Puppet.features.stubs(:posix?).returns(true) - Puppet.features.stubs(:microsoft_windows?).returns(false) - end - - it "should autorequire its parent directory" do - file = Puppet::Type::File.new(:path => "/foo/bar") - dir = Puppet::Type::File.new(:path => "/foo") - @catalog.add_resource file - @catalog.add_resource dir - reqs = file.autorequire - reqs[0].source.must == dir - reqs[0].target.must == file - end - - it "should autorequire its nearest ancestor directory" do - file = Puppet::Type::File.new(:path => "/foo/bar/baz") - dir = Puppet::Type::File.new(:path => "/foo") - root = Puppet::Type::File.new(:path => "/") - @catalog.add_resource file - @catalog.add_resource dir - @catalog.add_resource root - reqs = file.autorequire - reqs.length.must == 1 - reqs[0].source.must == dir - reqs[0].target.must == file - end - - it "should not autorequire anything when there is no nearest ancestor directory" do - file = Puppet::Type::File.new(:path => "/foo/bar/baz") - @catalog.add_resource file - file.autorequire.should be_empty - end - - it "should not autorequire its parent dir if its parent dir is itself" do - file = Puppet::Type::File.new(:path => "/") - @catalog.add_resource file - file.autorequire.should be_empty - end - - it "should remove trailing slashes" do - file = Puppet::Type::File.new(:path => "/foo/bar/baz/") - file[:path].should == "/foo/bar/baz" - end - - it "should remove double slashes" do - file = Puppet::Type::File.new(:path => "/foo/bar//baz") - file[:path].should == "/foo/bar/baz" - end + it "should autorequire its parent directory" do + file = Puppet::Type::File.new(:path => "/foo/bar") + dir = Puppet::Type::File.new(:path => "/foo") + @catalog.add_resource file + @catalog.add_resource dir + reqs = file.autorequire + reqs[0].source.must == dir + reqs[0].target.must == file + end - it "should remove trailing double slashes" do - file = Puppet::Type::File.new(:path => "/foo/bar/baz//") - file[:path].should == "/foo/bar/baz" - end + it "should autorequire its nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "/foo/bar/baz") + dir = Puppet::Type::File.new(:path => "/foo") + root = Puppet::Type::File.new(:path => "/") + @catalog.add_resource file + @catalog.add_resource dir + @catalog.add_resource root + reqs = file.autorequire + reqs.length.must == 1 + reqs[0].source.must == dir + reqs[0].target.must == file + end - it "should leave a single slash alone" do - file = Puppet::Type::File.new(:path => "/") - file[:path].should == "/" - end + it "should not autorequire anything when there is no nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "/foo/bar/baz") + @catalog.add_resource file + file.autorequire.should be_empty + end - it "should accept a double-slash at the start of the path" do - expect { - file = Puppet::Type::File.new(:path => "//tmp/xxx") - # REVISIT: This should be wrong, later. See the next test. - # --daniel 2011-01-31 - file[:path].should == '/tmp/xxx' - }.should_not raise_error - end + it "should not autorequire its parent dir if its parent dir is itself" do + file = Puppet::Type::File.new(:path => "/") + @catalog.add_resource file + file.autorequire.should be_empty + end - # REVISIT: This is pending, because I don't want to try and audit the - # entire codebase to make sure we get this right. POSIX treats two (and - # exactly two) '/' characters at the start of the path specially. - # - # See sections 3.2 and 4.11, which allow DomainOS to be all special like - # and still have the POSIX branding and all. --daniel 2011-01-31 - it "should preserve the double-slash at the start of the path" + it "should remove trailing slashes" do + file = Puppet::Type::File.new(:path => "/foo/bar/baz/") + file[:path].should == "/foo/bar/baz" end - describe "on Microsoft Windows systems" do - before do - Puppet.features.stubs(:posix?).returns(false) - Puppet.features.stubs(:microsoft_windows?).returns(true) - end + it "should remove double slashes" do + file = Puppet::Type::File.new(:path => "/foo/bar//baz") + file[:path].should == "/foo/bar/baz" + end - it "should refuse to work" do - lambda { Puppet::Type::File.new(:path => "/foo/bar") }.should raise_error(Puppet::Error) - end + it "should remove trailing double slashes" do + file = Puppet::Type::File.new(:path => "/foo/bar/baz//") + file[:path].should == "/foo/bar/baz" end - end - describe "when using Microsoft Windows filenames", :if => Puppet.features.microsoft_windows? do - describe "on Microsoft Windows systems" do - before do - Puppet.features.stubs(:posix?).returns(false) - Puppet.features.stubs(:microsoft_windows?).returns(true) - end + it "should leave a single slash alone" do + file = Puppet::Type::File.new(:path => "/") + file[:path].should == "/" + end - it "should autorequire its parent directory" do - file = Puppet::Type::File.new(:path => "X:/foo/bar") - dir = Puppet::Type::File.new(:path => "X:/foo") - @catalog.add_resource file - @catalog.add_resource dir - reqs = file.autorequire - reqs[0].source.must == dir - reqs[0].target.must == file - end + it "should accept a double-slash at the start of the path" do + expect { + file = Puppet::Type::File.new(:path => "//tmp/xxx") + # REVISIT: This should be wrong, later. See the next test. + # --daniel 2011-01-31 + file[:path].should == '/tmp/xxx' + }.should_not raise_error + end - it "should autorequire its nearest ancestor directory" do - file = Puppet::Type::File.new(:path => "X:/foo/bar/baz") - dir = Puppet::Type::File.new(:path => "X:/foo") - root = Puppet::Type::File.new(:path => "X:/") - @catalog.add_resource file - @catalog.add_resource dir - @catalog.add_resource root - reqs = file.autorequire - reqs.length.must == 1 - reqs[0].source.must == dir - reqs[0].target.must == file - end + # REVISIT: This is pending, because I don't want to try and audit the + # entire codebase to make sure we get this right. POSIX treats two (and + # exactly two) '/' characters at the start of the path specially. + # + # See sections 3.2 and 4.11, which allow DomainOS to be all special like + # and still have the POSIX branding and all. --daniel 2011-01-31 + it "should preserve the double-slash at the start of the path" + end - it "should not autorequire anything when there is no nearest ancestor directory" do - file = Puppet::Type::File.new(:path => "X:/foo/bar/baz") - @catalog.add_resource file - file.autorequire.should be_empty - end + describe "when using Microsoft Windows filenames" do + it "should autorequire its parent directory" do + file = Puppet::Type::File.new(:path => "X:/foo/bar") + dir = Puppet::Type::File.new(:path => "X:/foo") + @catalog.add_resource file + @catalog.add_resource dir + reqs = file.autorequire + reqs[0].source.must == dir + reqs[0].target.must == file + end - it "should not autorequire its parent dir if its parent dir is itself" do - file = Puppet::Type::File.new(:path => "X:/") - @catalog.add_resource file - file.autorequire.should be_empty - end + it "should autorequire its nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "X:/foo/bar/baz") + dir = Puppet::Type::File.new(:path => "X:/foo") + root = Puppet::Type::File.new(:path => "X:/") + @catalog.add_resource file + @catalog.add_resource dir + @catalog.add_resource root + reqs = file.autorequire + reqs.length.must == 1 + reqs[0].source.must == dir + reqs[0].target.must == file + end - it "should remove trailing slashes" do - file = Puppet::Type::File.new(:path => "X:/foo/bar/baz/") - file[:path].should == "X:/foo/bar/baz" - end + it "should not autorequire anything when there is no nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "X:/foo/bar/baz") + @catalog.add_resource file + file.autorequire.should be_empty + end - it "should remove double slashes" do - file = Puppet::Type::File.new(:path => "X:/foo/bar//baz") - file[:path].should == "X:/foo/bar/baz" - end + it "should not autorequire its parent dir if its parent dir is itself" do + file = Puppet::Type::File.new(:path => "X:/") + @catalog.add_resource file + file.autorequire.should be_empty + end - it "should remove trailing double slashes" do - file = Puppet::Type::File.new(:path => "X:/foo/bar/baz//") - file[:path].should == "X:/foo/bar/baz" - end + it "should remove trailing slashes" do + file = Puppet::Type::File.new(:path => "X:/foo/bar/baz/") + file[:path].should == "X:/foo/bar/baz" + end - it "should leave a drive letter with a slash alone", :'fails_on_ruby_1.9.2' => true do - file = Puppet::Type::File.new(:path => "X:/") - file[:path].should == "X:/" - end + it "should remove double slashes" do + file = Puppet::Type::File.new(:path => "X:/foo/bar//baz") + file[:path].should == "X:/foo/bar/baz" + end - it "should not accept a drive letter without a slash", :'fails_on_ruby_1.9.2' => true do - lambda { Puppet::Type::File.new(:path => "X:") }.should raise_error(/File paths must be fully qualified/) - end + it "should remove trailing double slashes" do + file = Puppet::Type::File.new(:path => "X:/foo/bar/baz//") + file[:path].should == "X:/foo/bar/baz" end - describe "on POSIX systems" do - before do - Puppet.features.stubs(:posix?).returns(true) - Puppet.features.stubs(:microsoft_windows?).returns(false) - end + it "should leave a drive letter with a slash alone", :'fails_on_ruby_1.9.2' => true do + file = Puppet::Type::File.new(:path => "X:/") + file[:path].should == "X:/" + end - it "should refuse to work" do - lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error) - end + it "should not accept a drive letter without a slash", :'fails_on_ruby_1.9.2' => true do + lambda { Puppet::Type::File.new(:path => "X:") }.should raise_error(/File paths must be fully qualified/) end end - describe "when using UNC filenames" do - describe "on Microsoft Windows systems", :if => Puppet.features.microsoft_windows?, :'fails_on_ruby_1.9.2' => true do - before do - Puppet.features.stubs(:posix?).returns(false) - Puppet.features.stubs(:microsoft_windows?).returns(true) - end - - it "should autorequire its parent directory" do - file = Puppet::Type::File.new(:path => "//server/foo/bar") - dir = Puppet::Type::File.new(:path => "//server/foo") - @catalog.add_resource file - @catalog.add_resource dir - reqs = file.autorequire - reqs[0].source.must == dir - reqs[0].target.must == file - end - - it "should autorequire its nearest ancestor directory" do - file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux") - dir = Puppet::Type::File.new(:path => "//server/foo/bar") - root = Puppet::Type::File.new(:path => "//server/foo") - @catalog.add_resource file - @catalog.add_resource dir - @catalog.add_resource root - reqs = file.autorequire - reqs.length.must == 1 - reqs[0].source.must == dir - reqs[0].target.must == file - end + describe "when using UNC filenames", :'fails_on_ruby_1.9.2' => true do + before :each do + pending("UNC file paths not yet supported") + end - it "should not autorequire anything when there is no nearest ancestor directory" do - file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux") - @catalog.add_resource file - file.autorequire.should be_empty - end + it "should autorequire its parent directory" do + file = Puppet::Type::File.new(:path => "//server/foo/bar") + dir = Puppet::Type::File.new(:path => "//server/foo") + @catalog.add_resource file + @catalog.add_resource dir + reqs = file.autorequire + reqs[0].source.must == dir + reqs[0].target.must == file + end - it "should not autorequire its parent dir if its parent dir is itself" do - file = Puppet::Type::File.new(:path => "//server/foo") - @catalog.add_resource file - puts file.autorequire - file.autorequire.should be_empty - end + it "should autorequire its nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux") + dir = Puppet::Type::File.new(:path => "//server/foo/bar") + root = Puppet::Type::File.new(:path => "//server/foo") + @catalog.add_resource file + @catalog.add_resource dir + @catalog.add_resource root + reqs = file.autorequire + reqs.length.must == 1 + reqs[0].source.must == dir + reqs[0].target.must == file + end - it "should remove trailing slashes" do - file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/") - file[:path].should == "//server/foo/bar/baz" - end + it "should not autorequire anything when there is no nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux") + @catalog.add_resource file + file.autorequire.should be_empty + end - it "should remove double slashes" do - file = Puppet::Type::File.new(:path => "//server/foo/bar//baz") - file[:path].should == "//server/foo/bar/baz" - end + it "should not autorequire its parent dir if its parent dir is itself" do + file = Puppet::Type::File.new(:path => "//server/foo") + @catalog.add_resource file + puts file.autorequire + file.autorequire.should be_empty + end - it "should remove trailing double slashes" do - file = Puppet::Type::File.new(:path => "//server/foo/bar/baz//") - file[:path].should == "//server/foo/bar/baz" - end + it "should remove trailing slashes" do + file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/") + file[:path].should == "//server/foo/bar/baz" + end - it "should remove a trailing slash from a sharename" do - file = Puppet::Type::File.new(:path => "//server/foo/") - file[:path].should == "//server/foo" - end + it "should remove double slashes" do + file = Puppet::Type::File.new(:path => "//server/foo/bar//baz") + file[:path].should == "//server/foo/bar/baz" + end - it "should not modify a sharename" do - file = Puppet::Type::File.new(:path => "//server/foo") - file[:path].should == "//server/foo" - end + it "should remove trailing double slashes" do + file = Puppet::Type::File.new(:path => "//server/foo/bar/baz//") + file[:path].should == "//server/foo/bar/baz" end - describe "on POSIX systems" do - before do - Puppet.features.stubs(:posix?).returns(true) - Puppet.features.stubs(:microsoft_windows?).returns(false) - end + it "should remove a trailing slash from a sharename" do + file = Puppet::Type::File.new(:path => "//server/foo/") + file[:path].should == "//server/foo" + end - it "should refuse to work" do - lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error) - end + it "should not modify a sharename" do + file = Puppet::Type::File.new(:path => "//server/foo") + file[:path].should == "//server/foo" end end |
