Permalink
Browse files

Syncer::RSync acceptance specs

  • Loading branch information...
1 parent 3186923 commit 53b361d1068458cbe3d33fd0565dd62a3845ff21 Brian D. Burns committed Apr 3, 2013
@@ -0,0 +1,51 @@
+# encoding: utf-8
+
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+module Backup
+describe Syncer::RSync::Local do
+
+ specify 'single directory' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Local do |rsync|
+ rsync.path = '~/Storage'
+ rsync.directories do |dirs|
+ dirs.add '~/test_data'
+ end
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/test_data') ).
+ to eq( dir_contents('~/test_data') )
+ end
+
+ specify 'multiple directories' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Local do |rsync|
+ rsync.path = '~/Storage'
+ rsync.directories do |dirs|
+ dirs.add '~/test_data/dir_a'
+ dirs.add '~/test_data/dir_b'
+ dirs.add '~/test_data/dir_c'
+ end
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/dir_a') ).
+ to eq( dir_contents('~/test_data/dir_a') )
+ expect( dir_contents('~/Storage/dir_b') ).
+ to eq( dir_contents('~/test_data/dir_b') )
+ expect( dir_contents('~/Storage/dir_c') ).
+ to eq( dir_contents('~/test_data/dir_c') )
+ end
+
+end
+end
@@ -0,0 +1,170 @@
+# encoding: utf-8
+
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+module Backup
+describe Syncer::RSync::Pull do
+
+ context 'using :ssh mode' do
+ specify 'single directory' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Pull do |rsync|
+ rsync.host = 'localhost'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/test_data') ).
+ to eq( dir_contents('~/test_data') )
+ end
+
+ specify 'multiple directories' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Pull do |rsync|
+ rsync.host = 'localhost'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data/dir_a'
+ dirs.add '~/test_data/dir_b'
+ dirs.add '~/test_data/dir_c'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/dir_a') ).
+ to eq( dir_contents('~/test_data/dir_a') )
+ expect( dir_contents('~/Storage/dir_b') ).
+ to eq( dir_contents('~/test_data/dir_b') )
+ expect( dir_contents('~/Storage/dir_c') ).
+ to eq( dir_contents('~/test_data/dir_c') )
+ end
+ end # context 'using :ssh mode'
+
+ context 'using :ssh_daemon mode' do
+ specify 'single directory' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Pull do |rsync|
+ rsync.mode = :ssh_daemon
+ rsync.host = 'localhost'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add 'ssh-daemon-module/test_data'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/test_data') ).
+ to eq( dir_contents('~/test_data') )
+ end
+
+ specify 'multiple directories' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Pull do |rsync|
+ rsync.mode = :ssh_daemon
+ rsync.host = 'localhost'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add 'ssh-daemon-module/test_data/dir_a'
+ dirs.add 'ssh-daemon-module/test_data/dir_b'
+ dirs.add 'ssh-daemon-module/test_data/dir_c'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/dir_a') ).
+ to eq( dir_contents('~/test_data/dir_a') )
+ expect( dir_contents('~/Storage/dir_b') ).
+ to eq( dir_contents('~/test_data/dir_b') )
+ expect( dir_contents('~/Storage/dir_c') ).
+ to eq( dir_contents('~/test_data/dir_c') )
+ end
+ end # context 'using :ssh_daemon mode'
+
+ context 'using :rsync_daemon mode' do
+ specify 'single directory' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Pull do |rsync|
+ rsync.mode = :rsync_daemon
+ rsync.host = 'localhost'
+ rsync.rsync_password = 'daemon-password'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add 'rsync-daemon-module/test_data'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/test_data') ).
+ to eq( dir_contents('~/test_data') )
+ end
+
+ specify 'multiple directories' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Pull do |rsync|
+ rsync.mode = :rsync_daemon
+ rsync.host = 'localhost'
+ rsync.rsync_password = 'daemon-password'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add 'rsync-daemon-module/test_data/dir_a'
+ dirs.add 'rsync-daemon-module/test_data/dir_b'
+ dirs.add 'rsync-daemon-module/test_data/dir_c'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/dir_a') ).
+ to eq( dir_contents('~/test_data/dir_a') )
+ expect( dir_contents('~/Storage/dir_b') ).
+ to eq( dir_contents('~/test_data/dir_b') )
+ expect( dir_contents('~/Storage/dir_c') ).
+ to eq( dir_contents('~/test_data/dir_c') )
+ end
+ end # context 'using :rsync_daemon mode'
+end
+end
@@ -0,0 +1,171 @@
+# encoding: utf-8
+
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+module Backup
+describe Syncer::RSync::Push do
+
+ context 'using :ssh mode' do
+ specify 'single directory' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Push do |rsync|
+ rsync.host = 'localhost'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/test_data') ).
+ to eq( dir_contents('~/test_data') )
+ end
+
+ specify 'multiple directories' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Push do |rsync|
+ rsync.host = 'localhost'
+ rsync.path = '~/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data/dir_a'
+ dirs.add '~/test_data/dir_b'
+ dirs.add '~/test_data/dir_c'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/dir_a') ).
+ to eq( dir_contents('~/test_data/dir_a') )
+ expect( dir_contents('~/Storage/dir_b') ).
+ to eq( dir_contents('~/test_data/dir_b') )
+ expect( dir_contents('~/Storage/dir_c') ).
+ to eq( dir_contents('~/test_data/dir_c') )
+ end
+ end # context 'using :ssh mode'
+
+ context 'using :ssh_daemon mode' do
+ specify 'single directory' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Push do |rsync|
+ rsync.mode = :ssh_daemon
+ rsync.host = 'localhost'
+ rsync.path = 'ssh-daemon-module/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/test_data') ).
+ to eq( dir_contents('~/test_data') )
+ end
+
+ specify 'multiple directories' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Push do |rsync|
+ rsync.mode = :ssh_daemon
+ rsync.host = 'localhost'
+ rsync.path = 'ssh-daemon-module/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data/dir_a'
+ dirs.add '~/test_data/dir_b'
+ dirs.add '~/test_data/dir_c'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/dir_a') ).
+ to eq( dir_contents('~/test_data/dir_a') )
+ expect( dir_contents('~/Storage/dir_b') ).
+ to eq( dir_contents('~/test_data/dir_b') )
+ expect( dir_contents('~/Storage/dir_c') ).
+ to eq( dir_contents('~/test_data/dir_c') )
+ end
+ end # context 'using :ssh_daemon mode'
+
+ context 'using :rsync_daemon mode' do
+ specify 'single directory' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Push do |rsync|
+ rsync.mode = :rsync_daemon
+ rsync.host = 'localhost'
+ rsync.rsync_password = 'daemon-password'
+ rsync.path = 'rsync-daemon-module/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/test_data') ).
+ to eq( dir_contents('~/test_data') )
+ end
+
+ specify 'multiple directories' do
+ create_model :my_backup, <<-EOS
+ Backup::Model.new(:my_backup, 'a description') do
+ sync_with RSync::Push do |rsync|
+ rsync.mode = :rsync_daemon
+ rsync.host = 'localhost'
+ rsync.rsync_password = 'daemon-password'
+ rsync.path = 'rsync-daemon-module/Storage'
+
+ rsync.directories do |dirs|
+ dirs.add '~/test_data/dir_a'
+ dirs.add '~/test_data/dir_b'
+ dirs.add '~/test_data/dir_c'
+ end
+
+ rsync.additional_rsync_options = '-vv'
+ end
+ end
+ EOS
+
+ backup_perform :my_backup
+
+ expect( dir_contents('~/Storage/dir_a') ).
+ to eq( dir_contents('~/test_data/dir_a') )
+ expect( dir_contents('~/Storage/dir_b') ).
+ to eq( dir_contents('~/test_data/dir_b') )
+ expect( dir_contents('~/Storage/dir_c') ).
+ to eq( dir_contents('~/test_data/dir_c') )
+ end
+ end # context 'using :rsync_daemon mode'
+
+end
+end
Oops, something went wrong.

0 comments on commit 53b361d

Please sign in to comment.