synced_folders/rsync: can exclude files

This commit is contained in:
Mitchell Hashimoto 2014-01-10 18:01:38 -08:00
parent 2e3fcf576c
commit 60f3d224c9
2 changed files with 32 additions and 1 deletions

View File

@ -49,8 +49,9 @@ module VagrantPlugins
# Exclude some files by default, and any that might be configured # Exclude some files by default, and any that might be configured
# by the user. # by the user.
# TODO(mitchellh): allow the user to configure it
excludes = ['.vagrant/'] excludes = ['.vagrant/']
excludes += Array(opts[:exclude]) if opts[:exclude]
excludes.uniq!
# Build up the actual command to execute # Build up the actual command to execute
command = [ command = [

View File

@ -107,5 +107,35 @@ describe VagrantPlugins::SyncedFolderRSync::SyncedFolder do
subject.rsync_single(machine, ssh_info, opts) subject.rsync_single(machine, ssh_info, opts)
end end
context "excluding files" do
it "excludes files if given as a string" do
opts[:exclude] = "foo"
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
index = args.find_index("foo")
expect(index).to be > 0
expect(args[index-1]).to eql("--exclude")
end
subject.rsync_single(machine, ssh_info, opts)
end
it "excludes multiple files" do
opts[:exclude] = ["foo", "bar"]
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
index = args.find_index("foo")
expect(index).to be > 0
expect(args[index-1]).to eql("--exclude")
index = args.find_index("bar")
expect(index).to be > 0
expect(args[index-1]).to eql("--exclude")
end
subject.rsync_single(machine, ssh_info, opts)
end
end
end end
end end