backup 3.0.23 → 3.0.24
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -12,77 +12,100 @@ describe Backup::Notifier::Hipchat do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
it 'should be a subclass of Notifier::Base' do
|
16
|
+
Backup::Notifier::Hipchat.
|
17
|
+
superclass.should == Backup::Notifier::Base
|
18
|
+
end
|
19
|
+
|
15
20
|
describe '#initialize' do
|
21
|
+
after { Backup::Notifier::Hipchat.clear_defaults! }
|
16
22
|
|
17
|
-
it 'should
|
18
|
-
|
19
|
-
notifier
|
20
|
-
notifier.rooms_notified.should == ['room1', 'room2']
|
21
|
-
notifier.notify_users.should == false
|
22
|
-
notifier.success_color.should == 'yellow'
|
23
|
-
notifier.warning_color.should == 'yellow'
|
24
|
-
notifier.failure_color.should == 'yellow'
|
25
|
-
|
26
|
-
notifier.on_success.should == true
|
27
|
-
notifier.on_warning.should == true
|
28
|
-
notifier.on_failure.should == true
|
23
|
+
it 'should load pre-configured defaults through Base' do
|
24
|
+
Backup::Notifier::Hipchat.any_instance.expects(:load_defaults!)
|
25
|
+
notifier
|
29
26
|
end
|
30
27
|
|
31
|
-
|
32
|
-
|
28
|
+
it 'should pass the model reference to Base' do
|
29
|
+
notifier.instance_variable_get(:@model).should == model
|
30
|
+
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
context 'when no pre-configured defaults have been set' do
|
33
|
+
it 'should use the values given' do
|
34
|
+
notifier.token.should == 'token'
|
35
|
+
notifier.from.should == 'application'
|
36
|
+
notifier.rooms_notified.should == ['room1', 'room2']
|
37
|
+
notifier.notify_users.should == false
|
38
|
+
notifier.success_color.should == 'yellow'
|
39
|
+
notifier.warning_color.should == 'yellow'
|
40
|
+
notifier.failure_color.should == 'yellow'
|
41
|
+
|
42
|
+
notifier.on_success.should == true
|
43
|
+
notifier.on_warning.should == true
|
44
|
+
notifier.on_failure.should == true
|
45
|
+
end
|
39
46
|
|
40
|
-
|
47
|
+
it 'should use default values if none are given' do
|
48
|
+
notifier = Backup::Notifier::Hipchat.new(model)
|
49
|
+
notifier.token.should be_nil
|
50
|
+
notifier.from.should be_nil
|
51
|
+
notifier.rooms_notified.should == []
|
52
|
+
notifier.notify_users.should == false
|
53
|
+
notifier.success_color.should == 'yellow'
|
54
|
+
notifier.warning_color.should == 'yellow'
|
55
|
+
notifier.failure_color.should == 'yellow'
|
56
|
+
|
57
|
+
notifier.on_success.should == true
|
58
|
+
notifier.on_warning.should == true
|
59
|
+
notifier.on_failure.should == true
|
60
|
+
end
|
61
|
+
end # context 'when no pre-configured defaults have been set'
|
62
|
+
|
63
|
+
context 'when pre-configured defaults have been set' do
|
64
|
+
before do
|
65
|
+
Backup::Notifier::Hipchat.defaults do |n|
|
66
|
+
n.token = 'old'
|
67
|
+
n.from = 'before'
|
68
|
+
n.success_color = 'green'
|
69
|
+
n.on_failure = false
|
41
70
|
end
|
42
|
-
hipchat = Backup::Notifier::Hipchat.new(model)
|
43
|
-
|
44
|
-
hipchat.token.should == 'old'
|
45
|
-
hipchat.from.should == 'before'
|
46
|
-
hipchat.rooms_notified.should == []
|
47
|
-
hipchat.notify_users.should == false
|
48
|
-
hipchat.success_color.should == 'green'
|
49
|
-
hipchat.warning_color.should == 'yellow'
|
50
|
-
hipchat.failure_color.should == 'yellow'
|
51
|
-
|
52
|
-
hipchat.on_success.should == true
|
53
|
-
hipchat.on_warning.should == true
|
54
|
-
hipchat.on_failure.should == false
|
55
71
|
end
|
56
72
|
|
57
|
-
it 'should
|
58
|
-
Backup::
|
59
|
-
notifier.token = 'old'
|
60
|
-
notifier.from = 'before'
|
61
|
-
notifier.success_color = 'green'
|
73
|
+
it 'should use pre-configured defaults' do
|
74
|
+
notifier = Backup::Notifier::Hipchat.new(model)
|
62
75
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
76
|
+
notifier.token.should == 'old'
|
77
|
+
notifier.from.should == 'before'
|
78
|
+
notifier.rooms_notified.should == []
|
79
|
+
notifier.notify_users.should == false
|
80
|
+
notifier.success_color.should == 'green'
|
81
|
+
notifier.warning_color.should == 'yellow'
|
82
|
+
notifier.failure_color.should == 'yellow'
|
83
|
+
|
84
|
+
notifier.on_success.should == true
|
85
|
+
notifier.on_warning.should == true
|
86
|
+
notifier.on_failure.should == false
|
87
|
+
end
|
69
88
|
|
70
|
-
|
71
|
-
|
89
|
+
it 'should override pre-configured defaults' do
|
90
|
+
notifier = Backup::Notifier::Hipchat.new(model) do |n|
|
91
|
+
n.token = 'new'
|
92
|
+
n.from = 'after'
|
93
|
+
n.failure_color = 'red'
|
94
|
+
n.on_success = false
|
95
|
+
n.on_failure = true
|
72
96
|
end
|
73
97
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
98
|
+
notifier.token.should == 'new'
|
99
|
+
notifier.from.should == 'after'
|
100
|
+
notifier.success_color.should == 'green'
|
101
|
+
notifier.warning_color.should == 'yellow'
|
102
|
+
notifier.failure_color.should == 'red'
|
79
103
|
|
80
|
-
|
81
|
-
|
82
|
-
|
104
|
+
notifier.on_success.should == false
|
105
|
+
notifier.on_warning.should == true
|
106
|
+
notifier.on_failure.should == true
|
83
107
|
end
|
84
|
-
end # context 'when
|
85
|
-
|
108
|
+
end # context 'when pre-configured defaults have been set'
|
86
109
|
end # describe '#initialize'
|
87
110
|
|
88
111
|
describe '#notify!' do
|
data/spec/notifier/mail_spec.rb
CHANGED
@@ -26,44 +26,86 @@ describe Backup::Notifier::Mail do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
it 'should be a subclass of Notifier::Base' do
|
30
|
+
Backup::Notifier::Mail.
|
31
|
+
superclass.should == Backup::Notifier::Base
|
32
|
+
end
|
33
|
+
|
29
34
|
describe '#initialize' do
|
35
|
+
after { Backup::Notifier::Mail.clear_defaults! }
|
30
36
|
|
31
|
-
it 'should
|
32
|
-
|
33
|
-
notifier
|
34
|
-
notifier.to.should == 'my.receiver.email@gmail.com'
|
35
|
-
notifier.address.should == 'smtp.gmail.com'
|
36
|
-
notifier.port.should == 587
|
37
|
-
notifier.domain.should == 'your.host.name'
|
38
|
-
notifier.user_name.should == 'user'
|
39
|
-
notifier.password.should == 'secret'
|
40
|
-
notifier.authentication.should == 'plain'
|
41
|
-
notifier.enable_starttls_auto.should == true
|
42
|
-
|
43
|
-
notifier.sendmail.should == '/path/to/sendmail'
|
44
|
-
notifier.sendmail_args.should == '-i -t -X/tmp/traffic.log'
|
45
|
-
notifier.exim.should == '/path/to/exim'
|
46
|
-
notifier.exim_args.should == '-i -t -X/tmp/traffic.log'
|
47
|
-
|
48
|
-
notifier.mail_folder.should == '/path/to/backup/mails'
|
49
|
-
|
50
|
-
notifier.on_success.should == true
|
51
|
-
notifier.on_warning.should == true
|
52
|
-
notifier.on_failure.should == true
|
37
|
+
it 'should load pre-configured defaults through Base' do
|
38
|
+
Backup::Notifier::Mail.any_instance.expects(:load_defaults!)
|
39
|
+
notifier
|
53
40
|
end
|
54
41
|
|
55
|
-
|
56
|
-
|
42
|
+
it 'should pass the model reference to Base' do
|
43
|
+
notifier.instance_variable_get(:@model).should == model
|
44
|
+
end
|
57
45
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
46
|
+
context 'when no pre-configured defaults have been set' do
|
47
|
+
it 'should use the values given' do
|
48
|
+
notifier.delivery_method.should == :smtp
|
49
|
+
notifier.from.should == 'my.sender.email@gmail.com'
|
50
|
+
notifier.to.should == 'my.receiver.email@gmail.com'
|
51
|
+
notifier.address.should == 'smtp.gmail.com'
|
52
|
+
notifier.port.should == 587
|
53
|
+
notifier.domain.should == 'your.host.name'
|
54
|
+
notifier.user_name.should == 'user'
|
55
|
+
notifier.password.should == 'secret'
|
56
|
+
notifier.authentication.should == 'plain'
|
57
|
+
notifier.enable_starttls_auto.should == true
|
58
|
+
|
59
|
+
notifier.sendmail.should == '/path/to/sendmail'
|
60
|
+
notifier.sendmail_args.should == '-i -t -X/tmp/traffic.log'
|
61
|
+
notifier.exim.should == '/path/to/exim'
|
62
|
+
notifier.exim_args.should == '-i -t -X/tmp/traffic.log'
|
63
|
+
|
64
|
+
notifier.mail_folder.should == '/path/to/backup/mails'
|
65
|
+
|
66
|
+
notifier.on_success.should == true
|
67
|
+
notifier.on_warning.should == true
|
68
|
+
notifier.on_failure.should == true
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should use default values if none are given' do
|
65
72
|
notifier = Backup::Notifier::Mail.new(model)
|
73
|
+
notifier.delivery_method.should be_nil
|
74
|
+
notifier.from.should be_nil
|
75
|
+
notifier.to.should be_nil
|
76
|
+
notifier.address.should be_nil
|
77
|
+
notifier.port.should be_nil
|
78
|
+
notifier.domain.should be_nil
|
79
|
+
notifier.user_name.should be_nil
|
80
|
+
notifier.password.should be_nil
|
81
|
+
notifier.authentication.should be_nil
|
82
|
+
notifier.enable_starttls_auto.should be_nil
|
83
|
+
|
84
|
+
notifier.sendmail.should be_nil
|
85
|
+
notifier.sendmail_args.should be_nil
|
86
|
+
notifier.exim.should be_nil
|
87
|
+
notifier.exim_args.should be_nil
|
88
|
+
|
89
|
+
notifier.mail_folder.should be_nil
|
90
|
+
|
91
|
+
notifier.on_success.should == true
|
92
|
+
notifier.on_warning.should == true
|
93
|
+
notifier.on_failure.should == true
|
94
|
+
end
|
95
|
+
end # context 'when no pre-configured defaults have been set'
|
66
96
|
|
97
|
+
context 'when pre-configured defaults have been set' do
|
98
|
+
before do
|
99
|
+
Backup::Notifier::Mail.defaults do |n|
|
100
|
+
n.delivery_method = :file
|
101
|
+
n.from = 'default.sender@domain.com'
|
102
|
+
n.to = 'some.receiver@domain.com'
|
103
|
+
n.on_success = false
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should use pre-configured defaults' do
|
108
|
+
notifier = Backup::Notifier::Mail.new(model)
|
67
109
|
notifier.delivery_method.should == :file
|
68
110
|
notifier.from.should == 'default.sender@domain.com'
|
69
111
|
notifier.to.should == 'some.receiver@domain.com'
|
@@ -87,20 +129,16 @@ describe Backup::Notifier::Mail do
|
|
87
129
|
notifier.on_failure.should == true
|
88
130
|
end
|
89
131
|
|
90
|
-
it 'should override
|
91
|
-
Backup::
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
notifier = Backup::Notifier::Mail.new(model) do |mail|
|
98
|
-
mail.from = 'new.sender@domain.com'
|
99
|
-
mail.to = 'new.receiver@domain.com'
|
100
|
-
mail.on_warning = false
|
132
|
+
it 'should override pre-configured defaults' do
|
133
|
+
notifier = Backup::Notifier::Mail.new(model) do |n|
|
134
|
+
n.delivery_method = :sendmail
|
135
|
+
n.from = 'new.sender@domain.com'
|
136
|
+
n.to = 'new.receiver@domain.com'
|
137
|
+
n.port = 123
|
138
|
+
n.on_warning = false
|
101
139
|
end
|
102
140
|
|
103
|
-
notifier.delivery_method.should
|
141
|
+
notifier.delivery_method.should == :sendmail
|
104
142
|
notifier.from.should == 'new.sender@domain.com'
|
105
143
|
notifier.to.should == 'new.receiver@domain.com'
|
106
144
|
notifier.port.should == 123
|
@@ -109,9 +147,7 @@ describe Backup::Notifier::Mail do
|
|
109
147
|
notifier.on_warning.should == false
|
110
148
|
notifier.on_failure.should == true
|
111
149
|
end
|
112
|
-
|
113
|
-
end # context 'when using configuration defaults'
|
114
|
-
|
150
|
+
end # context 'when pre-configured defaults have been set'
|
115
151
|
end # describe '#initialize'
|
116
152
|
|
117
153
|
describe '#notify!' do
|
data/spec/notifier/prowl_spec.rb
CHANGED
@@ -11,28 +11,57 @@ describe Backup::Notifier::Prowl do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
it 'should be a subclass of Notifier::Base' do
|
15
|
+
Backup::Notifier::Prowl.
|
16
|
+
superclass.should == Backup::Notifier::Base
|
17
|
+
end
|
18
|
+
|
14
19
|
describe '#initialize' do
|
15
|
-
|
16
|
-
notifier.application.should == 'application'
|
17
|
-
notifier.api_key.should == 'api_key'
|
20
|
+
after { Backup::Notifier::Prowl.clear_defaults! }
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
notifier
|
22
|
+
it 'should load pre-configured defaults through Base' do
|
23
|
+
Backup::Notifier::Prowl.any_instance.expects(:load_defaults!)
|
24
|
+
notifier
|
22
25
|
end
|
23
26
|
|
24
|
-
|
25
|
-
|
27
|
+
it 'should pass the model reference to Base' do
|
28
|
+
notifier.instance_variable_get(:@model).should == model
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when no pre-configured defaults have been set' do
|
32
|
+
it 'should use the values given' do
|
33
|
+
notifier.application.should == 'application'
|
34
|
+
notifier.api_key.should == 'api_key'
|
35
|
+
|
36
|
+
notifier.on_success.should == true
|
37
|
+
notifier.on_warning.should == true
|
38
|
+
notifier.on_failure.should == true
|
39
|
+
end
|
26
40
|
|
27
|
-
it 'should use
|
28
|
-
Backup::
|
29
|
-
|
30
|
-
|
41
|
+
it 'should use default values if none are given' do
|
42
|
+
notifier = Backup::Notifier::Prowl.new(model)
|
43
|
+
notifier.application.should be_nil
|
44
|
+
notifier.api_key.should be_nil
|
31
45
|
|
32
|
-
|
33
|
-
|
34
|
-
|
46
|
+
notifier.on_success.should == true
|
47
|
+
notifier.on_warning.should == true
|
48
|
+
notifier.on_failure.should == true
|
49
|
+
end
|
50
|
+
end # context 'when no pre-configured defaults have been set'
|
51
|
+
|
52
|
+
context 'when pre-configured defaults have been set' do
|
53
|
+
before do
|
54
|
+
Backup::Notifier::Prowl.defaults do |n|
|
55
|
+
n.application = 'default_app'
|
56
|
+
n.api_key = 'default_api_key'
|
57
|
+
|
58
|
+
n.on_success = false
|
59
|
+
n.on_warning = false
|
60
|
+
n.on_failure = false
|
35
61
|
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should use pre-configured defaults' do
|
36
65
|
notifier = Backup::Notifier::Prowl.new(model)
|
37
66
|
notifier.application.should == 'default_app'
|
38
67
|
notifier.api_key.should == 'default_api_key'
|
@@ -42,22 +71,14 @@ describe Backup::Notifier::Prowl do
|
|
42
71
|
notifier.on_failure.should == false
|
43
72
|
end
|
44
73
|
|
45
|
-
it 'should override
|
46
|
-
Backup::
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
prowl.on_success = true
|
51
|
-
prowl.on_warning = false
|
52
|
-
prowl.on_failure = false
|
53
|
-
end
|
54
|
-
notifier = Backup::Notifier::Prowl.new(model) do |prowl|
|
55
|
-
prowl.application = 'new_app'
|
56
|
-
prowl.api_key = 'new_api_key'
|
74
|
+
it 'should override pre-configured defaults' do
|
75
|
+
notifier = Backup::Notifier::Prowl.new(model) do |n|
|
76
|
+
n.application = 'new_app'
|
77
|
+
n.api_key = 'new_api_key'
|
57
78
|
|
58
|
-
|
59
|
-
|
60
|
-
|
79
|
+
n.on_success = false
|
80
|
+
n.on_warning = true
|
81
|
+
n.on_failure = true
|
61
82
|
end
|
62
83
|
|
63
84
|
notifier.application.should == 'new_app'
|
@@ -67,8 +88,8 @@ describe Backup::Notifier::Prowl do
|
|
67
88
|
notifier.on_warning.should == true
|
68
89
|
notifier.on_failure.should == true
|
69
90
|
end
|
70
|
-
end # context 'when
|
71
|
-
end
|
91
|
+
end # context 'when pre-configured defaults have been set'
|
92
|
+
end # describe '#initialize'
|
72
93
|
|
73
94
|
describe '#notify!' do
|
74
95
|
context 'when status is :success' do
|
@@ -13,32 +13,63 @@ describe Backup::Notifier::Twitter do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'should be a subclass of Notifier::Base' do
|
17
|
+
Backup::Notifier::Twitter.
|
18
|
+
superclass.should == Backup::Notifier::Base
|
19
|
+
end
|
20
|
+
|
16
21
|
describe '#initialize' do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
notifier
|
22
|
-
|
23
|
-
notifier.on_success.should == true
|
24
|
-
notifier.on_warning.should == true
|
25
|
-
notifier.on_failure.should == true
|
22
|
+
after { Backup::Notifier::Twitter.clear_defaults! }
|
23
|
+
|
24
|
+
it 'should load pre-configured defaults through Base' do
|
25
|
+
Backup::Notifier::Twitter.any_instance.expects(:load_defaults!)
|
26
|
+
notifier
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
it 'should pass the model reference to Base' do
|
30
|
+
notifier.instance_variable_get(:@model).should == model
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
context 'when no pre-configured defaults have been set' do
|
34
|
+
it 'should use the values given' do
|
35
|
+
notifier.consumer_key.should == 'consumer_key'
|
36
|
+
notifier.consumer_secret.should == 'consumer_secret'
|
37
|
+
notifier.oauth_token.should == 'oauth_token'
|
38
|
+
notifier.oauth_token_secret.should == 'oauth_token_secret'
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
notifier.on_success.should == true
|
41
|
+
notifier.on_warning.should == true
|
42
|
+
notifier.on_failure.should == true
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should use default values if none are given' do
|
46
|
+
notifier = Backup::Notifier::Twitter.new(model)
|
47
|
+
notifier.consumer_key.should be_nil
|
48
|
+
notifier.consumer_secret.should be_nil
|
49
|
+
notifier.oauth_token.should be_nil
|
50
|
+
notifier.oauth_token_secret.should be_nil
|
51
|
+
|
52
|
+
notifier.on_success.should == true
|
53
|
+
notifier.on_warning.should == true
|
54
|
+
notifier.on_failure.should == true
|
55
|
+
end
|
56
|
+
end # context 'when no pre-configured defaults have been set'
|
57
|
+
|
58
|
+
context 'when pre-configured defaults have been set' do
|
59
|
+
before do
|
60
|
+
Backup::Notifier::Twitter.defaults do |n|
|
61
|
+
n.consumer_key = 'some_consumer_key'
|
62
|
+
n.consumer_secret = 'some_consumer_secret'
|
63
|
+
n.oauth_token = 'some_oauth_token'
|
64
|
+
n.oauth_token_secret = 'some_oauth_token_secret'
|
65
|
+
|
66
|
+
n.on_success = false
|
67
|
+
n.on_warning = false
|
68
|
+
n.on_failure = false
|
41
69
|
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should use pre-configured defaults' do
|
42
73
|
notifier = Backup::Notifier::Twitter.new(model)
|
43
74
|
notifier.consumer_key.should == 'some_consumer_key'
|
44
75
|
notifier.consumer_secret.should == 'some_consumer_secret'
|
@@ -50,26 +81,16 @@ describe Backup::Notifier::Twitter do
|
|
50
81
|
notifier.on_failure.should == false
|
51
82
|
end
|
52
83
|
|
53
|
-
it 'should override
|
54
|
-
Backup::
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
84
|
+
it 'should override pre-configured defaults' do
|
85
|
+
notifier = Backup::Notifier::Twitter.new(model) do |n|
|
86
|
+
n.consumer_key = 'new_consumer_key'
|
87
|
+
n.consumer_secret = 'new_consumer_secret'
|
88
|
+
n.oauth_token = 'new_oauth_token'
|
89
|
+
n.oauth_token_secret = 'new_oauth_token_secret'
|
59
90
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
notifier = Backup::Notifier::Twitter.new(model) do |twitter|
|
65
|
-
twitter.consumer_key = 'new_consumer_key'
|
66
|
-
twitter.consumer_secret = 'new_consumer_secret'
|
67
|
-
twitter.oauth_token = 'new_oauth_token'
|
68
|
-
twitter.oauth_token_secret = 'new_oauth_token_secret'
|
69
|
-
|
70
|
-
twitter.on_success = false
|
71
|
-
twitter.on_warning = true
|
72
|
-
twitter.on_failure = true
|
91
|
+
n.on_success = false
|
92
|
+
n.on_warning = true
|
93
|
+
n.on_failure = true
|
73
94
|
end
|
74
95
|
|
75
96
|
notifier.consumer_key.should == 'new_consumer_key'
|
@@ -81,8 +102,8 @@ describe Backup::Notifier::Twitter do
|
|
81
102
|
notifier.on_warning.should == true
|
82
103
|
notifier.on_failure.should == true
|
83
104
|
end
|
84
|
-
end # context 'when
|
85
|
-
end
|
105
|
+
end # context 'when pre-configured defaults have been set'
|
106
|
+
end # describe '#initialize'
|
86
107
|
|
87
108
|
describe '#notify!' do
|
88
109
|
context 'when status is :success' do
|