summaryrefslogtreecommitdiff
path: root/spec/unit/provider/remote_file
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-05-20 07:55:44 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-05-21 10:13:07 -0500
commit8d969503cdb5805807aeec8d06629116c28e5877 (patch)
tree87d429c955787ec7f38c63081c624ef4b48ed3ab /spec/unit/provider/remote_file
parent6ba819dd88383a9ad7ef7af5b013cbf6a4da2c84 (diff)
downloadchef-8d969503cdb5805807aeec8d06629116c28e5877.tar.gz
Update specs for remote local file + spaces
Diffstat (limited to 'spec/unit/provider/remote_file')
-rw-r--r--spec/unit/provider/remote_file/local_file_spec.rb31
1 files changed, 25 insertions, 6 deletions
diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb
index b33d82f624..575996a540 100644
--- a/spec/unit/provider/remote_file/local_file_spec.rb
+++ b/spec/unit/provider/remote_file/local_file_spec.rb
@@ -25,26 +25,45 @@ describe Chef::Provider::RemoteFile::LocalFile do
let(:new_resource) { Chef::Resource::RemoteFile.new("local file backend test (new_resource)") }
let(:current_resource) { Chef::Resource::RemoteFile.new("local file backend test (current_resource)") }
subject(:fetcher) { Chef::Provider::RemoteFile::LocalFile.new(uri, new_resource, current_resource) }
-
- context "when parsing source path" do
+
+ context "when parsing source path on windows" do
+
+ before do
+ allow(Chef::Platform).to receive(:windows?).and_return(true)
+ end
+
describe "when given local unix path" do
let(:uri) { URI.parse("file:///nyan_cat.png") }
it "returns a correct unix path" do
- expect(fetcher.fix_windows_path(uri.path)).to eq("/nyan_cat.png")
+ expect(fetcher.source_path).to eq("/nyan_cat.png")
end
end
describe "when given local windows path" do
let(:uri) { URI.parse("file:///z:/windows/path/file.txt") }
it "returns a valid windows local path" do
- expect(fetcher.fix_windows_path(uri.path)).to eq("z:/windows/path/file.txt")
+ expect(fetcher.source_path).to eq("z:/windows/path/file.txt")
+ end
+ end
+
+ describe "when given local windows path with spaces" do
+ let(:uri) { URI.parse(URI.escape("file:///z:/windows/path/foo & bar.txt")) }
+ it "returns a valid windows local path" do
+ expect(fetcher.source_path).to eq("z:/windows/path/foo & bar.txt")
end
end
describe "when given unc windows path" do
let(:uri) { URI.parse("file:////server/share/windows/path/file.txt") }
it "returns a valid windows unc path" do
- expect(fetcher.fix_windows_path(uri.path)).to eq("//server/share/windows/path/file.txt")
+ expect(fetcher.source_path).to eq("//server/share/windows/path/file.txt")
+ end
+ end
+
+ describe "when given unc windows path with spaces" do
+ let(:uri) { URI.parse(URI.escape("file:////server/share/windows/path/foo & bar.txt")) }
+ it "returns a valid windows unc path" do
+ expect(fetcher.source_path).to eq("//server/share/windows/path/foo & bar.txt")
end
end
end
@@ -73,7 +92,7 @@ describe Chef::Provider::RemoteFile::LocalFile do
it "stages the local file to a temporary file" do
expect(Chef::FileContentManagement::Tempfile).to receive(:new).with(new_resource).and_return(chef_tempfile)
expect(::FileUtils).to receive(:cp).with(uri.path, tempfile.path)
- expect(tempfile).to receive(:close)
+ expect(tempfile).to receive(:close)
result = fetcher.fetch
expect(result).to eq(tempfile)