spec/storage/scp_spec.rb in backup-3.0.23 vs spec/storage/scp_spec.rb in backup-3.0.24
- old
+ new
@@ -11,85 +11,109 @@
scp.ip = '123.45.678.90'
scp.keep = 5
end
end
+ it 'should be a subclass of Storage::Base' do
+ Backup::Storage::SCP.
+ superclass.should == Backup::Storage::Base
+ end
+
describe '#initialize' do
- it 'should set the correct values' do
- storage.username.should == 'my_username'
- storage.password.should == 'my_password'
- storage.ip.should == '123.45.678.90'
- storage.port.should == 22
- storage.path.should == 'backups'
+ after { Backup::Storage::SCP.clear_defaults! }
- storage.storage_id.should be_nil
- storage.keep.should == 5
+ it 'should load pre-configured defaults through Base' do
+ Backup::Storage::SCP.any_instance.expects(:load_defaults!)
+ storage
end
- it 'should set a storage_id if given' do
- scp = Backup::Storage::SCP.new(model, 'my storage_id')
- scp.storage_id.should == 'my storage_id'
+ it 'should pass the model reference to Base' do
+ storage.instance_variable_get(:@model).should == model
end
+ it 'should pass the storage_id to Base' do
+ storage = Backup::Storage::SCP.new(model, 'my_storage_id')
+ storage.storage_id.should == 'my_storage_id'
+ end
+
it 'should remove any preceeding tilde and slash from the path' do
storage = Backup::Storage::SCP.new(model) do |scp|
scp.path = '~/my_backups/path'
end
storage.path.should == 'my_backups/path'
end
- context 'when setting configuration defaults' do
- after { Backup::Configuration::Storage::SCP.clear_defaults! }
+ context 'when no pre-configured defaults have been set' do
+ it 'should use the values given' do
+ storage.username.should == 'my_username'
+ storage.password.should == 'my_password'
+ storage.ip.should == '123.45.678.90'
+ storage.port.should == 22
+ storage.path.should == 'backups'
- it 'should use the configured defaults' do
- Backup::Configuration::Storage::SCP.defaults do |scp|
- scp.username = 'some_username'
- scp.password = 'some_password'
- scp.ip = 'some_ip'
- scp.port = 'some_port'
- scp.path = 'some_path'
- scp.keep = 'some_keep'
+ storage.storage_id.should be_nil
+ storage.keep.should == 5
+ end
+
+ it 'should use default values if none are given' do
+ storage = Backup::Storage::SCP.new(model)
+
+ storage.username.should be_nil
+ storage.password.should be_nil
+ storage.ip.should be_nil
+ storage.port.should == 22
+ storage.path.should == 'backups'
+
+ storage.storage_id.should be_nil
+ storage.keep.should be_nil
+ end
+ end # context 'when no pre-configured defaults have been set'
+
+ context 'when pre-configured defaults have been set' do
+ before do
+ Backup::Storage::SCP.defaults do |s|
+ s.username = 'some_username'
+ s.password = 'some_password'
+ s.ip = 'some_ip'
+ s.port = 'some_port'
+ s.path = 'some_path'
+ s.keep = 'some_keep'
end
+ end
+
+ it 'should use pre-configured defaults' do
storage = Backup::Storage::SCP.new(model)
+
storage.username.should == 'some_username'
storage.password.should == 'some_password'
storage.ip.should == 'some_ip'
storage.port.should == 'some_port'
storage.path.should == 'some_path'
storage.storage_id.should be_nil
storage.keep.should == 'some_keep'
end
- it 'should override the configured defaults' do
- Backup::Configuration::Storage::SCP.defaults do |scp|
- scp.username = 'old_username'
- scp.password = 'old_password'
- scp.ip = 'old_ip'
- scp.port = 'old_port'
- scp.path = 'old_path'
- scp.keep = 'old_keep'
+ it 'should override pre-configured defaults' do
+ storage = Backup::Storage::SCP.new(model) do |s|
+ s.username = 'new_username'
+ s.password = 'new_password'
+ s.ip = 'new_ip'
+ s.port = 'new_port'
+ s.path = 'new_path'
+ s.keep = 'new_keep'
end
- storage = Backup::Storage::SCP.new(model) do |scp|
- scp.username = 'new_username'
- scp.password = 'new_password'
- scp.ip = 'new_ip'
- scp.port = 'new_port'
- scp.path = 'new_path'
- scp.keep = 'new_keep'
- end
storage.username.should == 'new_username'
storage.password.should == 'new_password'
storage.ip.should == 'new_ip'
storage.port.should == 'new_port'
storage.path.should == 'new_path'
storage.storage_id.should be_nil
storage.keep.should == 'new_keep'
end
- end # context 'when setting configuration defaults'
-
+ end # context 'when pre-configured defaults have been set'
end # describe '#initialize'
describe '#connection' do
let(:connection) { mock }
it 'should yield a Net::SSH connection' do