synced_folders/rsync: can exclude files
This commit is contained in:
parent
2e3fcf576c
commit
60f3d224c9
|
@ -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 = [
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue