Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

106 lines (84 sloc) 2.58 kb
# encoding: utf-8
require File.dirname(__FILE__) + '/../spec_helper'
describe Backup::Storage::Dropbox do
let(:db) do
Backup::Storage::Dropbox.new do |db|
db.email = 'my@email.com'
db.password = 'my_password'
db.api_key = 'my_api_key'
db.api_secret = 'my_secret'
db.keep = 20
db.timeout = 500
end
end
let(:connection) do
c = mock("Dropbox::Session")
db.stubs(:connection).returns(c); c
end
before do
Backup::Configuration::Storage::Dropbox.clear_defaults!
end
it 'should have defined the configuration properly' do
db.email.should == 'my@email.com'
db.password.should == 'my_password'
db.api_key.should == 'my_api_key'
db.api_secret.should == 'my_secret'
db.path.should == 'backups'
db.keep.should == 20
db.timeout.should == 500
end
it 'should overwrite the default timeout' do
db = Backup::Storage::Dropbox.new do |db|
db.timeout = 500
end
db.timeout.should == 500
end
it 'should provide a default timeout' do
db = Backup::Storage::Dropbox.new
db.timeout.should == 300
end
it 'should overwrite the default path' do
db = Backup::Storage::Dropbox.new do |db|
db.path = 'my/backups'
end
db.path.should == 'my/backups'
end
describe '#connection' do
it do
session = mock("Dropbox::Session")
Dropbox::Session.expects(:new).with('my_api_key', 'my_secret').returns(session)
session.expects(:mode=).with(:dropbox)
session.expects(:authorizing_user=).with('my@email.com')
session.expects(:authorizing_password=).with('my_password')
session.expects(:authorize!)
db.send(:connection)
end
end
describe '#transfer!' do
before do
Backup::Logger.stubs(:message)
connection.stubs(:upload)
connection.stubs(:delete)
end
it do
Backup::Logger.expects(:message).with("Backup::Storage::Dropbox started transferring \"#{ Backup::TIME }.#{ Backup::TRIGGER }.tar\".")
db.send(:transfer!)
end
it do
connection.expects(:upload).with(
File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar"),
File.join('backups', Backup::TRIGGER),
:timeout => db.timeout
)
db.send(:transfer!)
end
end
describe '#remove!' do
it do
connection.expects(:delete).with(
File.join('backups', Backup::TRIGGER, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar")
)
db.send(:remove!)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.