backup 3.0.23 → 3.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +42 -45
- data/Guardfile +7 -4
- data/README.md +10 -7
- data/backup.gemspec +2 -2
- data/lib/backup.rb +27 -97
- data/lib/backup/archive.rb +14 -6
- data/lib/backup/cli/helpers.rb +52 -49
- data/lib/backup/cli/utility.rb +9 -1
- data/lib/backup/compressor/base.rb +10 -4
- data/lib/backup/compressor/bzip2.rb +22 -26
- data/lib/backup/compressor/custom.rb +53 -0
- data/lib/backup/compressor/gzip.rb +22 -23
- data/lib/backup/compressor/lzma.rb +15 -13
- data/lib/backup/compressor/pbzip2.rb +20 -17
- data/lib/backup/config.rb +6 -3
- data/lib/backup/configuration.rb +33 -0
- data/lib/backup/configuration/helpers.rb +114 -28
- data/lib/backup/configuration/store.rb +24 -0
- data/lib/backup/database/base.rb +0 -6
- data/lib/backup/database/mongodb.rb +27 -11
- data/lib/backup/database/mysql.rb +19 -14
- data/lib/backup/database/postgresql.rb +16 -11
- data/lib/backup/database/redis.rb +7 -11
- data/lib/backup/database/riak.rb +3 -6
- data/lib/backup/dependency.rb +5 -11
- data/lib/backup/model.rb +14 -5
- data/lib/backup/notifier/campfire.rb +3 -16
- data/lib/backup/notifier/hipchat.rb +1 -7
- data/lib/backup/notifier/mail.rb +1 -1
- data/lib/backup/packager.rb +29 -19
- data/lib/backup/pipeline.rb +110 -0
- data/lib/backup/storage/dropbox.rb +4 -7
- data/lib/backup/syncer/base.rb +8 -4
- data/lib/backup/syncer/cloud/base.rb +247 -0
- data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
- data/lib/backup/syncer/cloud/s3.rb +68 -0
- data/lib/backup/syncer/rsync/base.rb +1 -4
- data/lib/backup/syncer/rsync/local.rb +9 -5
- data/lib/backup/syncer/rsync/pull.rb +1 -1
- data/lib/backup/syncer/rsync/push.rb +10 -5
- data/lib/backup/version.rb +1 -1
- data/spec-live/.gitignore +6 -0
- data/spec-live/README +7 -0
- data/spec-live/backups/config.rb +153 -0
- data/spec-live/backups/config.yml.template +43 -0
- data/spec-live/compressor/custom_spec.rb +30 -0
- data/spec-live/compressor/gzip_spec.rb +30 -0
- data/spec-live/notifier/mail_spec.rb +85 -0
- data/spec-live/spec_helper.rb +85 -0
- data/spec-live/storage/dropbox_spec.rb +151 -0
- data/spec-live/storage/local_spec.rb +83 -0
- data/spec-live/storage/scp_spec.rb +193 -0
- data/spec-live/syncer/cloud/s3_spec.rb +124 -0
- data/spec/archive_spec.rb +86 -31
- data/spec/cleaner_spec.rb +8 -0
- data/spec/cli/helpers_spec.rb +200 -75
- data/spec/cli/utility_spec.rb +11 -3
- data/spec/compressor/base_spec.rb +31 -10
- data/spec/compressor/bzip2_spec.rb +212 -57
- data/spec/compressor/custom_spec.rb +106 -0
- data/spec/compressor/gzip_spec.rb +212 -57
- data/spec/compressor/lzma_spec.rb +75 -35
- data/spec/compressor/pbzip2_spec.rb +93 -52
- data/spec/configuration/helpers_spec.rb +406 -0
- data/spec/configuration/store_spec.rb +39 -0
- data/spec/configuration_spec.rb +62 -0
- data/spec/database/base_spec.rb +19 -10
- data/spec/database/mongodb_spec.rb +195 -70
- data/spec/database/mysql_spec.rb +183 -64
- data/spec/database/postgresql_spec.rb +167 -53
- data/spec/database/redis_spec.rb +121 -46
- data/spec/database/riak_spec.rb +96 -27
- data/spec/dependency_spec.rb +2 -0
- data/spec/encryptor/base_spec.rb +10 -0
- data/spec/encryptor/gpg_spec.rb +29 -13
- data/spec/encryptor/open_ssl_spec.rb +40 -21
- data/spec/logger_spec.rb +4 -0
- data/spec/model_spec.rb +19 -2
- data/spec/notifier/base_spec.rb +32 -17
- data/spec/notifier/campfire_spec.rb +63 -45
- data/spec/notifier/hipchat_spec.rb +79 -56
- data/spec/notifier/mail_spec.rb +82 -46
- data/spec/notifier/prowl_spec.rb +53 -32
- data/spec/notifier/twitter_spec.rb +62 -41
- data/spec/packager_spec.rb +95 -36
- data/spec/pipeline_spec.rb +259 -0
- data/spec/spec_helper.rb +6 -5
- data/spec/storage/base_spec.rb +61 -41
- data/spec/storage/cloudfiles_spec.rb +69 -45
- data/spec/storage/dropbox_spec.rb +158 -36
- data/spec/storage/ftp_spec.rb +69 -45
- data/spec/storage/local_spec.rb +47 -23
- data/spec/storage/ninefold_spec.rb +55 -31
- data/spec/storage/rsync_spec.rb +67 -50
- data/spec/storage/s3_spec.rb +65 -41
- data/spec/storage/scp_spec.rb +65 -41
- data/spec/storage/sftp_spec.rb +65 -41
- data/spec/syncer/base_spec.rb +91 -4
- data/spec/syncer/cloud/base_spec.rb +511 -0
- data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
- data/spec/syncer/cloud/s3_spec.rb +174 -0
- data/spec/syncer/rsync/base_spec.rb +46 -66
- data/spec/syncer/rsync/local_spec.rb +55 -26
- data/spec/syncer/rsync/pull_spec.rb +15 -4
- data/spec/syncer/rsync/push_spec.rb +59 -52
- data/templates/cli/utility/compressor/bzip2 +1 -4
- data/templates/cli/utility/compressor/custom +11 -0
- data/templates/cli/utility/compressor/gzip +1 -4
- data/templates/cli/utility/compressor/lzma +3 -0
- data/templates/cli/utility/compressor/pbzip2 +3 -0
- data/templates/cli/utility/database/mysql +4 -1
- data/templates/cli/utility/syncer/cloud_files +17 -19
- data/templates/cli/utility/syncer/s3 +18 -20
- metadata +38 -92
- data/lib/backup/configuration/base.rb +0 -15
- data/lib/backup/configuration/compressor/base.rb +0 -9
- data/lib/backup/configuration/compressor/bzip2.rb +0 -23
- data/lib/backup/configuration/compressor/gzip.rb +0 -23
- data/lib/backup/configuration/compressor/lzma.rb +0 -23
- data/lib/backup/configuration/compressor/pbzip2.rb +0 -28
- data/lib/backup/configuration/database/base.rb +0 -19
- data/lib/backup/configuration/database/mongodb.rb +0 -49
- data/lib/backup/configuration/database/mysql.rb +0 -42
- data/lib/backup/configuration/database/postgresql.rb +0 -41
- data/lib/backup/configuration/database/redis.rb +0 -39
- data/lib/backup/configuration/database/riak.rb +0 -29
- data/lib/backup/configuration/encryptor/base.rb +0 -9
- data/lib/backup/configuration/encryptor/gpg.rb +0 -17
- data/lib/backup/configuration/encryptor/open_ssl.rb +0 -32
- data/lib/backup/configuration/notifier/base.rb +0 -28
- data/lib/backup/configuration/notifier/campfire.rb +0 -25
- data/lib/backup/configuration/notifier/hipchat.rb +0 -41
- data/lib/backup/configuration/notifier/mail.rb +0 -112
- data/lib/backup/configuration/notifier/presently.rb +0 -25
- data/lib/backup/configuration/notifier/prowl.rb +0 -23
- data/lib/backup/configuration/notifier/twitter.rb +0 -21
- data/lib/backup/configuration/storage/base.rb +0 -18
- data/lib/backup/configuration/storage/cloudfiles.rb +0 -25
- data/lib/backup/configuration/storage/dropbox.rb +0 -58
- data/lib/backup/configuration/storage/ftp.rb +0 -29
- data/lib/backup/configuration/storage/local.rb +0 -17
- data/lib/backup/configuration/storage/ninefold.rb +0 -20
- data/lib/backup/configuration/storage/rsync.rb +0 -29
- data/lib/backup/configuration/storage/s3.rb +0 -25
- data/lib/backup/configuration/storage/scp.rb +0 -25
- data/lib/backup/configuration/storage/sftp.rb +0 -25
- data/lib/backup/configuration/syncer/base.rb +0 -10
- data/lib/backup/configuration/syncer/cloud.rb +0 -23
- data/lib/backup/configuration/syncer/cloud_files.rb +0 -30
- data/lib/backup/configuration/syncer/rsync/base.rb +0 -28
- data/lib/backup/configuration/syncer/rsync/local.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/pull.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/push.rb +0 -31
- data/lib/backup/configuration/syncer/s3.rb +0 -23
- data/lib/backup/notifier/presently.rb +0 -88
- data/lib/backup/syncer/cloud.rb +0 -187
- data/lib/backup/syncer/cloud_files.rb +0 -56
- data/lib/backup/syncer/s3.rb +0 -47
- data/spec/configuration/base_spec.rb +0 -35
- data/spec/configuration/compressor/bzip2_spec.rb +0 -29
- data/spec/configuration/compressor/gzip_spec.rb +0 -29
- data/spec/configuration/compressor/lzma_spec.rb +0 -29
- data/spec/configuration/compressor/pbzip2_spec.rb +0 -32
- data/spec/configuration/database/base_spec.rb +0 -17
- data/spec/configuration/database/mongodb_spec.rb +0 -56
- data/spec/configuration/database/mysql_spec.rb +0 -53
- data/spec/configuration/database/postgresql_spec.rb +0 -53
- data/spec/configuration/database/redis_spec.rb +0 -50
- data/spec/configuration/database/riak_spec.rb +0 -35
- data/spec/configuration/encryptor/gpg_spec.rb +0 -26
- data/spec/configuration/encryptor/open_ssl_spec.rb +0 -35
- data/spec/configuration/notifier/base_spec.rb +0 -32
- data/spec/configuration/notifier/campfire_spec.rb +0 -32
- data/spec/configuration/notifier/hipchat_spec.rb +0 -44
- data/spec/configuration/notifier/mail_spec.rb +0 -71
- data/spec/configuration/notifier/presently_spec.rb +0 -35
- data/spec/configuration/notifier/prowl_spec.rb +0 -29
- data/spec/configuration/notifier/twitter_spec.rb +0 -35
- data/spec/configuration/storage/cloudfiles_spec.rb +0 -41
- data/spec/configuration/storage/dropbox_spec.rb +0 -38
- data/spec/configuration/storage/ftp_spec.rb +0 -44
- data/spec/configuration/storage/local_spec.rb +0 -29
- data/spec/configuration/storage/ninefold_spec.rb +0 -32
- data/spec/configuration/storage/rsync_spec.rb +0 -41
- data/spec/configuration/storage/s3_spec.rb +0 -38
- data/spec/configuration/storage/scp_spec.rb +0 -41
- data/spec/configuration/storage/sftp_spec.rb +0 -41
- data/spec/configuration/syncer/cloud_files_spec.rb +0 -44
- data/spec/configuration/syncer/rsync/base_spec.rb +0 -33
- data/spec/configuration/syncer/rsync/local_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/pull_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/push_spec.rb +0 -43
- data/spec/configuration/syncer/s3_spec.rb +0 -38
- data/spec/notifier/presently_spec.rb +0 -181
- data/spec/syncer/cloud_files_spec.rb +0 -192
- data/spec/syncer/s3_spec.rb +0 -192
- data/templates/cli/utility/notifier/presently +0 -13
data/spec/database/riak_spec.rb
CHANGED
|
@@ -13,48 +13,81 @@ describe Backup::Database::Riak do
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
it 'should be a subclass of Database::Base' do
|
|
17
|
+
Backup::Database::Riak.superclass.
|
|
18
|
+
should == Backup::Database::Base
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
describe '#initialize' do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
db
|
|
21
|
-
db.riak_admin_utility.should == '/path/to/riak-admin'
|
|
22
|
+
|
|
23
|
+
it 'should load pre-configured defaults through Base' do
|
|
24
|
+
Backup::Database::Riak.any_instance.expects(:load_defaults!)
|
|
25
|
+
db
|
|
22
26
|
end
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
it 'should pass the model reference to Base' do
|
|
29
|
+
db.instance_variable_get(:@model).should == model
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'when no pre-configured defaults have been set' do
|
|
33
|
+
context 'when options are specified' do
|
|
34
|
+
it 'should use the given values' do
|
|
35
|
+
db.name.should == 'mydatabase'
|
|
36
|
+
db.node.should == 'riak@localhost'
|
|
37
|
+
db.cookie.should == 'riak'
|
|
38
|
+
db.riak_admin_utility.should == '/path/to/riak-admin'
|
|
39
|
+
end
|
|
28
40
|
end
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
context 'when options are not specified' do
|
|
43
|
+
before do
|
|
44
|
+
Backup::Database::Riak.any_instance.expects(:utility).
|
|
45
|
+
with('riak-admin').returns('/real/riak-admin')
|
|
46
|
+
end
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
db.cookie.should be_nil
|
|
36
|
-
db.riak_admin_utility.should == '/real/riak-admin'
|
|
37
|
-
end
|
|
38
|
-
end
|
|
48
|
+
it 'should provide default values' do
|
|
49
|
+
db = Backup::Database::Riak.new(model)
|
|
39
50
|
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
db.name.should be_nil
|
|
52
|
+
db.node.should be_nil
|
|
53
|
+
db.cookie.should be_nil
|
|
54
|
+
db.riak_admin_utility.should == '/real/riak-admin'
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end # context 'when no pre-configured defaults have been set'
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
|
|
59
|
+
context 'when pre-configured defaults have been set' do
|
|
60
|
+
before do
|
|
61
|
+
Backup::Database::Riak.defaults do |db|
|
|
45
62
|
db.name = 'db_name'
|
|
46
63
|
db.node = 'db_node'
|
|
47
64
|
db.cookie = 'db_cookie'
|
|
48
65
|
db.riak_admin_utility = '/default/path/to/riak-admin'
|
|
49
66
|
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
after { Backup::Database::Riak.clear_defaults! }
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
71
|
+
context 'when options are specified' do
|
|
72
|
+
it 'should override the pre-configured defaults' do
|
|
73
|
+
db.name.should == 'mydatabase'
|
|
74
|
+
db.node.should == 'riak@localhost'
|
|
75
|
+
db.cookie.should == 'riak'
|
|
76
|
+
db.riak_admin_utility.should == '/path/to/riak-admin'
|
|
77
|
+
end
|
|
56
78
|
end
|
|
57
|
-
|
|
79
|
+
|
|
80
|
+
context 'when options are not specified' do
|
|
81
|
+
it 'should use the pre-configured defaults' do
|
|
82
|
+
db = Backup::Database::Riak.new(model)
|
|
83
|
+
|
|
84
|
+
db.name.should == 'db_name'
|
|
85
|
+
db.node.should == 'db_node'
|
|
86
|
+
db.cookie.should == 'db_cookie'
|
|
87
|
+
db.riak_admin_utility.should == '/default/path/to/riak-admin'
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end # context 'when no pre-configured defaults have been set'
|
|
58
91
|
end # describe '#initialize'
|
|
59
92
|
|
|
60
93
|
describe '#perform!' do
|
|
@@ -105,4 +138,40 @@ describe Backup::Database::Riak do
|
|
|
105
138
|
end
|
|
106
139
|
end
|
|
107
140
|
|
|
141
|
+
describe 'deprecations' do
|
|
142
|
+
after do
|
|
143
|
+
Backup::Database::Riak.clear_defaults!
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
describe '#utility_path' do
|
|
147
|
+
before do
|
|
148
|
+
Backup::Database::Riak.any_instance.stubs(:utility)
|
|
149
|
+
Backup::Logger.expects(:warn).with(
|
|
150
|
+
instance_of(Backup::Errors::ConfigurationError)
|
|
151
|
+
)
|
|
152
|
+
Backup::Logger.expects(:warn).with(
|
|
153
|
+
"Backup::Database::Riak.riak_admin_utility is being set to 'foo'"
|
|
154
|
+
)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
context 'when set directly' do
|
|
158
|
+
it 'should issue a deprecation warning and set the replacement value' do
|
|
159
|
+
riak = Backup::Database::Riak.new(model) do |db|
|
|
160
|
+
db.utility_path = 'foo'
|
|
161
|
+
end
|
|
162
|
+
riak.riak_admin_utility.should == 'foo'
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
context 'when set as a default' do
|
|
167
|
+
it 'should issue a deprecation warning and set the replacement value' do
|
|
168
|
+
riak = Backup::Database::Riak.defaults do |db|
|
|
169
|
+
db.utility_path = 'foo'
|
|
170
|
+
end
|
|
171
|
+
riak = Backup::Database::Riak.new(model)
|
|
172
|
+
riak.riak_admin_utility.should == 'foo'
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end # describe '#utility_path'
|
|
176
|
+
end
|
|
108
177
|
end
|
data/spec/dependency_spec.rb
CHANGED
data/spec/encryptor/base_spec.rb
CHANGED
|
@@ -5,6 +5,16 @@ require File.expand_path('../../spec_helper.rb', __FILE__)
|
|
|
5
5
|
describe Backup::Encryptor::Base do
|
|
6
6
|
let(:base) { Backup::Encryptor::Base.new }
|
|
7
7
|
|
|
8
|
+
it 'should include CLI::Helpers' do
|
|
9
|
+
Backup::Encryptor::Base.
|
|
10
|
+
include?(Backup::CLI::Helpers).should be_true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should include Configuration::Helpers' do
|
|
14
|
+
Backup::Encryptor::Base.
|
|
15
|
+
include?(Backup::Configuration::Helpers).should be_true
|
|
16
|
+
end
|
|
17
|
+
|
|
8
18
|
describe '#initialize' do
|
|
9
19
|
it 'should load defaults' do
|
|
10
20
|
Backup::Encryptor::Base.any_instance.expects(:load_defaults!)
|
data/spec/encryptor/gpg_spec.rb
CHANGED
|
@@ -9,30 +9,46 @@ describe Backup::Encryptor::GPG do
|
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
it 'should be a subclass of Encryptor::Base' do
|
|
13
|
+
Backup::Encryptor::GPG.
|
|
14
|
+
superclass.should == Backup::Encryptor::Base
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
describe '#initialize' do
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
after { Backup::Encryptor::GPG.clear_defaults! }
|
|
19
|
+
|
|
20
|
+
it 'should load pre-configured defaults' do
|
|
21
|
+
Backup::Encryptor::GPG.any_instance.expects(:load_defaults!)
|
|
22
|
+
encryptor
|
|
15
23
|
end
|
|
16
24
|
|
|
17
|
-
context 'when
|
|
18
|
-
it 'should use
|
|
25
|
+
context 'when no pre-configured defaults have been set' do
|
|
26
|
+
it 'should use the values given' do
|
|
27
|
+
encryptor.key.should == 'gpg_key'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should use default values if none are given' do
|
|
19
31
|
encryptor = Backup::Encryptor::GPG.new
|
|
20
32
|
encryptor.key.should be_nil
|
|
21
33
|
end
|
|
22
|
-
end
|
|
34
|
+
end # context 'when no pre-configured defaults have been set'
|
|
23
35
|
|
|
24
|
-
context 'when
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Backup::Configuration::Encryptor::GPG.defaults do |encryptor|
|
|
29
|
-
encryptor.key = 'my_key'
|
|
36
|
+
context 'when pre-configured defaults have been set' do
|
|
37
|
+
before do
|
|
38
|
+
Backup::Encryptor::GPG.defaults do |e|
|
|
39
|
+
e.key = 'default_key'
|
|
30
40
|
end
|
|
41
|
+
end
|
|
31
42
|
|
|
43
|
+
it 'should use pre-configured defaults' do
|
|
32
44
|
encryptor = Backup::Encryptor::GPG.new
|
|
33
|
-
encryptor.key.should == '
|
|
45
|
+
encryptor.key.should == 'default_key'
|
|
34
46
|
end
|
|
35
|
-
|
|
47
|
+
|
|
48
|
+
it 'should override pre-configured defaults' do
|
|
49
|
+
encryptor.key.should == 'gpg_key'
|
|
50
|
+
end
|
|
51
|
+
end # context 'when pre-configured defaults have been set'
|
|
36
52
|
end # describe '#initialize'
|
|
37
53
|
|
|
38
54
|
describe '#encrypt_with' do
|
|
@@ -12,42 +12,61 @@ describe Backup::Encryptor::OpenSSL do
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
it 'should be a subclass of Encryptor::Base' do
|
|
16
|
+
Backup::Encryptor::OpenSSL.
|
|
17
|
+
superclass.should == Backup::Encryptor::Base
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
describe '#initialize' do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
encryptor
|
|
21
|
+
after { Backup::Encryptor::OpenSSL.clear_defaults! }
|
|
22
|
+
|
|
23
|
+
it 'should load pre-configured defaults' do
|
|
24
|
+
Backup::Encryptor::OpenSSL.any_instance.expects(:load_defaults!)
|
|
25
|
+
encryptor
|
|
21
26
|
end
|
|
22
27
|
|
|
23
|
-
context 'when
|
|
24
|
-
it 'should use
|
|
28
|
+
context 'when no pre-configured defaults have been set' do
|
|
29
|
+
it 'should use the values given' do
|
|
30
|
+
encryptor.password.should == 'mypassword'
|
|
31
|
+
encryptor.password_file.should == '/my/password/file'
|
|
32
|
+
encryptor.base64.should == true
|
|
33
|
+
encryptor.salt.should == true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should use default values if none are given' do
|
|
25
37
|
encryptor = Backup::Encryptor::OpenSSL.new
|
|
26
38
|
encryptor.password.should be_nil
|
|
27
39
|
encryptor.password_file.should be_nil
|
|
28
40
|
encryptor.base64.should be_false
|
|
29
41
|
encryptor.salt.should be_true
|
|
30
42
|
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'when
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
encryptor.base64 = true
|
|
41
|
-
encryptor.salt = true
|
|
43
|
+
end # context 'when no pre-configured defaults have been set'
|
|
44
|
+
|
|
45
|
+
context 'when pre-configured defaults have been set' do
|
|
46
|
+
before do
|
|
47
|
+
Backup::Encryptor::OpenSSL.defaults do |e|
|
|
48
|
+
e.password = 'default_password'
|
|
49
|
+
e.password_file = '/default/password/file'
|
|
50
|
+
e.base64 = 'default_base64'
|
|
51
|
+
e.salt = 'default_salt'
|
|
42
52
|
end
|
|
53
|
+
end
|
|
43
54
|
|
|
55
|
+
it 'should use pre-configured defaults' do
|
|
44
56
|
encryptor = Backup::Encryptor::OpenSSL.new
|
|
45
|
-
encryptor.password
|
|
46
|
-
encryptor.password_file
|
|
57
|
+
encryptor.password = 'default_password'
|
|
58
|
+
encryptor.password_file = '/default/password/file'
|
|
59
|
+
encryptor.base64 = 'default_base64'
|
|
60
|
+
encryptor.salt = 'default_salt'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'should override pre-configured defaults' do
|
|
64
|
+
encryptor.password.should == 'mypassword'
|
|
65
|
+
encryptor.password_file.should == '/my/password/file'
|
|
47
66
|
encryptor.base64.should == true
|
|
48
67
|
encryptor.salt.should == true
|
|
49
68
|
end
|
|
50
|
-
end
|
|
69
|
+
end # context 'when pre-configured defaults have been set'
|
|
51
70
|
end # describe '#initialize'
|
|
52
71
|
|
|
53
72
|
describe '#encrypt_with' do
|
data/spec/logger_spec.rb
CHANGED
data/spec/model_spec.rb
CHANGED
|
@@ -209,10 +209,25 @@ describe 'Backup::Model' do
|
|
|
209
209
|
end
|
|
210
210
|
end
|
|
211
211
|
|
|
212
|
-
it 'should warn user of change from RSync to RSync::
|
|
212
|
+
it 'should warn user of change from RSync to RSync::Push' do
|
|
213
213
|
Backup::Logger.expects(:warn)
|
|
214
214
|
model.sync_with('Backup::Config::RSync')
|
|
215
|
-
model.syncers.first.should
|
|
215
|
+
model.syncers.first.should
|
|
216
|
+
be_an_instance_of Backup::Syncer::RSync::Push
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it 'should warn user of change from S3 to Cloud::S3' do
|
|
220
|
+
Backup::Logger.expects(:warn)
|
|
221
|
+
model.sync_with('Backup::Config::S3')
|
|
222
|
+
model.syncers.first.should
|
|
223
|
+
be_an_instance_of Backup::Syncer::Cloud::S3
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it 'should warn user of change from CloudFiles to Cloud::CloudFiles' do
|
|
227
|
+
Backup::Logger.expects(:warn)
|
|
228
|
+
model.sync_with('Backup::Config::CloudFiles')
|
|
229
|
+
model.syncers.first.should
|
|
230
|
+
be_an_instance_of Backup::Syncer::Cloud::CloudFiles
|
|
216
231
|
end
|
|
217
232
|
end
|
|
218
233
|
|
|
@@ -327,6 +342,8 @@ describe 'Backup::Model' do
|
|
|
327
342
|
Timecop.freeze(Time.now)
|
|
328
343
|
started_at = Time.now
|
|
329
344
|
time = started_at.strftime("%Y.%m.%d.%H.%M.%S")
|
|
345
|
+
model.expects(:log!).with(:started)
|
|
346
|
+
model.expects(:log!).with(:finished)
|
|
330
347
|
|
|
331
348
|
model.perform!
|
|
332
349
|
model.time.should == time
|
data/spec/notifier/base_spec.rb
CHANGED
|
@@ -6,31 +6,46 @@ describe 'Backup::Notifier::Base' do
|
|
|
6
6
|
let(:model) { Backup::Model.new(:test_trigger, 'test label') }
|
|
7
7
|
let(:notifier) { Backup::Notifier::Base.new(model) }
|
|
8
8
|
|
|
9
|
+
it 'should include Configuration::Helpers' do
|
|
10
|
+
Backup::Notifier::Base.
|
|
11
|
+
include?(Backup::Configuration::Helpers).should be_true
|
|
12
|
+
end
|
|
13
|
+
|
|
9
14
|
describe '#initialize' do
|
|
15
|
+
after { Backup::Notifier::Base.clear_defaults! }
|
|
10
16
|
|
|
11
|
-
it
|
|
12
|
-
|
|
13
|
-
notifier
|
|
14
|
-
notifier.on_failure.should == true
|
|
17
|
+
it 'should load pre-configured defaults' do
|
|
18
|
+
Backup::Notifier::Base.any_instance.expects(:load_defaults!)
|
|
19
|
+
notifier
|
|
15
20
|
end
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
it 'should set a reference to the model' do
|
|
23
|
+
notifier.instance_variable_get(:@model).should == model
|
|
24
|
+
end
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
context 'when no pre-configured defaults have been set' do
|
|
27
|
+
it 'should set default values' do
|
|
28
|
+
notifier.on_success.should == true
|
|
29
|
+
notifier.on_warning.should == true
|
|
30
|
+
notifier.on_failure.should == true
|
|
31
|
+
end
|
|
32
|
+
end # context 'when no pre-configured defaults have been set'
|
|
33
|
+
|
|
34
|
+
context 'when pre-configured defaults have been set' do
|
|
35
|
+
before do
|
|
36
|
+
Backup::Notifier::Base.defaults do |n|
|
|
37
|
+
n.on_success = false
|
|
38
|
+
n.on_warning = false
|
|
39
|
+
n.on_failure = false
|
|
25
40
|
end
|
|
26
|
-
|
|
27
|
-
base = Backup::Notifier::Base.new(model)
|
|
28
|
-
base.on_success.should == false
|
|
29
|
-
base.on_warning.should == false
|
|
30
|
-
base.on_failure.should == false
|
|
31
41
|
end
|
|
32
|
-
end
|
|
33
42
|
|
|
43
|
+
it 'should use pre-configured defaults' do
|
|
44
|
+
notifier.on_success.should be_false
|
|
45
|
+
notifier.on_warning.should be_false
|
|
46
|
+
notifier.on_failure.should be_false
|
|
47
|
+
end
|
|
48
|
+
end # context 'when pre-configured defaults have been set'
|
|
34
49
|
end # describe '#initialize'
|
|
35
50
|
|
|
36
51
|
describe '#perform!' do
|
|
@@ -12,30 +12,60 @@ describe Backup::Notifier::Campfire do
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
it 'should be a subclass of Notifier::Base' do
|
|
16
|
+
Backup::Notifier::Campfire.
|
|
17
|
+
superclass.should == Backup::Notifier::Base
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
describe '#initialize' do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
notifier.on_success.should == true
|
|
22
|
-
notifier.on_warning.should == true
|
|
23
|
-
notifier.on_failure.should == true
|
|
21
|
+
after { Backup::Notifier::Campfire.clear_defaults! }
|
|
22
|
+
|
|
23
|
+
it 'should load pre-configured defaults through Base' do
|
|
24
|
+
Backup::Notifier::Campfire.any_instance.expects(:load_defaults!)
|
|
25
|
+
notifier
|
|
24
26
|
end
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
it 'should pass the model reference to Base' do
|
|
29
|
+
notifier.instance_variable_get(:@model).should == model
|
|
30
|
+
end
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
context 'when no pre-configured defaults have been set' do
|
|
33
|
+
it 'should use the values given' do
|
|
34
|
+
notifier.api_token.should == 'token'
|
|
35
|
+
notifier.subdomain.should == 'subdomain'
|
|
36
|
+
notifier.room_id.should == 'room_id'
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
notifier.on_success.should == true
|
|
39
|
+
notifier.on_warning.should == true
|
|
40
|
+
notifier.on_failure.should == true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should use default values if none are given' do
|
|
44
|
+
notifier = Backup::Notifier::Campfire.new(model)
|
|
45
|
+
notifier.api_token.should be_nil
|
|
46
|
+
notifier.subdomain.should be_nil
|
|
47
|
+
notifier.room_id.should be_nil
|
|
48
|
+
|
|
49
|
+
notifier.on_success.should == true
|
|
50
|
+
notifier.on_warning.should == true
|
|
51
|
+
notifier.on_failure.should == true
|
|
52
|
+
end
|
|
53
|
+
end # context 'when no pre-configured defaults have been set'
|
|
54
|
+
|
|
55
|
+
context 'when pre-configured defaults have been set' do
|
|
56
|
+
before do
|
|
57
|
+
Backup::Notifier::Campfire.defaults do |n|
|
|
58
|
+
n.api_token = 'some_token'
|
|
59
|
+
n.subdomain = 'some_subdomain'
|
|
60
|
+
n.room_id = 'some_room_id'
|
|
61
|
+
|
|
62
|
+
n.on_success = false
|
|
63
|
+
n.on_warning = false
|
|
64
|
+
n.on_failure = false
|
|
38
65
|
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should use pre-configured defaults' do
|
|
39
69
|
notifier = Backup::Notifier::Campfire.new(model)
|
|
40
70
|
notifier.api_token.should == 'some_token'
|
|
41
71
|
notifier.subdomain.should == 'some_subdomain'
|
|
@@ -46,24 +76,15 @@ describe Backup::Notifier::Campfire do
|
|
|
46
76
|
notifier.on_failure.should == false
|
|
47
77
|
end
|
|
48
78
|
|
|
49
|
-
it 'should override
|
|
50
|
-
Backup::
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
it 'should override pre-configured defaults' do
|
|
80
|
+
notifier = Backup::Notifier::Campfire.new(model) do |n|
|
|
81
|
+
n.api_token = 'new_token'
|
|
82
|
+
n.subdomain = 'new_subdomain'
|
|
83
|
+
n.room_id = 'new_room_id'
|
|
54
84
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
notifier = Backup::Notifier::Campfire.new(model) do |campfire|
|
|
60
|
-
campfire.api_token = 'new_token'
|
|
61
|
-
campfire.subdomain = 'new_subdomain'
|
|
62
|
-
campfire.room_id = 'new_room_id'
|
|
63
|
-
|
|
64
|
-
campfire.on_success = false
|
|
65
|
-
campfire.on_warning = true
|
|
66
|
-
campfire.on_failure = true
|
|
85
|
+
n.on_success = false
|
|
86
|
+
n.on_warning = true
|
|
87
|
+
n.on_failure = true
|
|
67
88
|
end
|
|
68
89
|
|
|
69
90
|
notifier.api_token.should == 'new_token'
|
|
@@ -74,8 +95,8 @@ describe Backup::Notifier::Campfire do
|
|
|
74
95
|
notifier.on_warning.should == true
|
|
75
96
|
notifier.on_failure.should == true
|
|
76
97
|
end
|
|
77
|
-
end # context 'when
|
|
78
|
-
end
|
|
98
|
+
end # context 'when pre-configured defaults have been set'
|
|
99
|
+
end # describe '#initialize'
|
|
79
100
|
|
|
80
101
|
describe '#notify!' do
|
|
81
102
|
context 'when status is :success' do
|
|
@@ -163,14 +184,11 @@ describe 'Backup::Notifier::Campfire::Room' do
|
|
|
163
184
|
|
|
164
185
|
describe '#send_message' do
|
|
165
186
|
it 'should pass a JSON formatted HTTParty.post to #post' do
|
|
166
|
-
room.expects(:post).with(
|
|
167
|
-
{
|
|
168
|
-
:body =>
|
|
169
|
-
:message => {
|
|
170
|
-
|
|
171
|
-
:type => 'Textmessage'
|
|
172
|
-
}
|
|
173
|
-
}.to_json
|
|
187
|
+
room.expects(:post).with(
|
|
188
|
+
'speak', {
|
|
189
|
+
:body => MultiJson.encode(
|
|
190
|
+
{ :message => { :body => 'a message', :type => 'Textmessage' } }
|
|
191
|
+
)
|
|
174
192
|
}
|
|
175
193
|
)
|
|
176
194
|
room.send(:send_message, 'a message')
|