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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
require 'spec_helper'
require 'rsync'
describe Rsync do
context 'with configurations' do
before do
Rsync.configure do |config|
config.host = 'root@127.0.0.1'
end
end
it "should respond to host" do
Rsync.should respond_to(:host)
Rsync.host.should == 'root@127.0.0.1'
end
describe "run" do
it "prepend the host to the destination" do
Rsync::Command.stub(:run)
Rsync.run('/foo1', '/foo2', ["-a"])
Rsync::Command.should have_received(:run).with('/foo1', 'root@127.0.0.1:/foo2', ["-a"])
end
end
end
around(:each) do |example|
TempDir.create do |src, dest|
@src = src
@dest = dest
example.run
end
end
it "should work" do
@src.mkdir("blah")
Rsync.run(@src.path + "/", @dest.path, ["-a"])
@dest.should eql(@src)
end
it "should dry run" do
@src.mkdir("blah")
Rsync.run(@src.path + "/", @dest.path, ["-a", "-n"])
@dest.should_not eql(@src)
end
it "should list changes" do
@src.mkdir("blah")
result = Rsync.run(@src.path + "/", @dest.path, ["-a"])
result.should be_success
result.changes.length.should eql(1)
@dest.should eql(@src)
end
end
|