backup 3.0.27 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/LICENSE.md +1 -1
  2. data/README.md +139 -386
  3. data/bin/backup +1 -7
  4. data/lib/backup.rb +3 -9
  5. data/lib/backup/archive.rb +26 -20
  6. data/lib/backup/cleaner.rb +2 -2
  7. data/lib/backup/cli.rb +366 -0
  8. data/lib/backup/compressor/base.rb +2 -2
  9. data/lib/backup/compressor/gzip.rb +35 -1
  10. data/lib/backup/config.rb +1 -2
  11. data/lib/backup/database/base.rb +2 -2
  12. data/lib/backup/database/mongodb.rb +3 -3
  13. data/lib/backup/database/mysql.rb +3 -2
  14. data/lib/backup/database/postgresql.rb +3 -2
  15. data/lib/backup/database/riak.rb +18 -5
  16. data/lib/backup/dependency.rb +144 -93
  17. data/lib/backup/encryptor/base.rb +2 -2
  18. data/lib/backup/logger.rb +108 -110
  19. data/lib/backup/logger/console.rb +51 -0
  20. data/lib/backup/logger/logfile.rb +113 -0
  21. data/lib/backup/logger/syslog.rb +116 -0
  22. data/lib/backup/model.rb +67 -65
  23. data/lib/backup/notifier/base.rb +1 -1
  24. data/lib/backup/notifier/hipchat.rb +1 -1
  25. data/lib/backup/notifier/mail.rb +1 -1
  26. data/lib/backup/notifier/pushover.rb +6 -3
  27. data/lib/backup/packager.rb +4 -4
  28. data/lib/backup/pipeline.rb +17 -3
  29. data/lib/backup/splitter.rb +2 -2
  30. data/lib/backup/storage/base.rb +2 -2
  31. data/lib/backup/storage/cloudfiles.rb +2 -2
  32. data/lib/backup/storage/dropbox.rb +4 -4
  33. data/lib/backup/storage/ftp.rb +2 -2
  34. data/lib/backup/storage/local.rb +2 -2
  35. data/lib/backup/storage/ninefold.rb +2 -2
  36. data/lib/backup/storage/rsync.rb +3 -3
  37. data/lib/backup/storage/s3.rb +2 -2
  38. data/lib/backup/storage/scp.rb +2 -6
  39. data/lib/backup/storage/sftp.rb +2 -5
  40. data/lib/backup/syncer/base.rb +1 -1
  41. data/lib/backup/syncer/cloud/base.rb +15 -8
  42. data/lib/backup/syncer/rsync/local.rb +1 -1
  43. data/lib/backup/syncer/rsync/pull.rb +1 -1
  44. data/lib/backup/syncer/rsync/push.rb +1 -1
  45. data/lib/backup/utilities.rb +211 -0
  46. data/lib/backup/version.rb +1 -1
  47. data/templates/cli/{utility/archive → archive} +4 -8
  48. data/templates/cli/{utility/compressor → compressor}/bzip2 +0 -0
  49. data/templates/cli/{utility/compressor → compressor}/custom +0 -0
  50. data/templates/cli/{utility/compressor → compressor}/gzip +0 -0
  51. data/templates/cli/{utility/compressor → compressor}/lzma +0 -0
  52. data/templates/cli/{utility/compressor → compressor}/pbzip2 +0 -0
  53. data/templates/cli/config +68 -0
  54. data/templates/cli/{utility/database → database}/mongodb +1 -1
  55. data/templates/cli/{utility/database → database}/mysql +1 -1
  56. data/templates/cli/{utility/database → database}/postgresql +1 -1
  57. data/templates/cli/{utility/database → database}/redis +0 -0
  58. data/templates/cli/database/riak +20 -0
  59. data/templates/cli/{utility/encryptor → encryptor}/gpg +0 -0
  60. data/templates/cli/{utility/encryptor → encryptor}/openssl +0 -0
  61. data/templates/cli/{utility/model.erb → model.erb} +4 -4
  62. data/templates/cli/{utility/notifier → notifier}/campfire +0 -0
  63. data/templates/cli/{utility/notifier → notifier}/hipchat +0 -0
  64. data/templates/cli/{utility/notifier → notifier}/mail +0 -0
  65. data/templates/cli/{utility/notifier → notifier}/prowl +0 -0
  66. data/templates/cli/{utility/notifier → notifier}/pushover +0 -0
  67. data/templates/cli/{utility/notifier → notifier}/twitter +0 -0
  68. data/templates/cli/{utility/splitter → splitter} +0 -0
  69. data/templates/cli/{utility/storage → storage}/cloud_files +0 -0
  70. data/templates/cli/{utility/storage → storage}/dropbox +0 -0
  71. data/templates/cli/{utility/storage → storage}/ftp +0 -0
  72. data/templates/cli/{utility/storage → storage}/local +0 -0
  73. data/templates/cli/{utility/storage → storage}/ninefold +0 -0
  74. data/templates/cli/{utility/storage → storage}/rsync +0 -0
  75. data/templates/cli/{utility/storage → storage}/s3 +0 -0
  76. data/templates/cli/{utility/storage → storage}/scp +0 -0
  77. data/templates/cli/{utility/storage → storage}/sftp +0 -0
  78. data/templates/cli/{utility/syncer → syncer}/cloud_files +0 -0
  79. data/templates/cli/{utility/syncer → syncer}/rsync_local +0 -0
  80. data/templates/cli/{utility/syncer → syncer}/rsync_pull +0 -0
  81. data/templates/cli/{utility/syncer → syncer}/rsync_push +0 -0
  82. data/templates/cli/{utility/syncer → syncer}/s3 +0 -0
  83. metadata +55 -131
  84. data/.gitignore +0 -8
  85. data/.travis.yml +0 -10
  86. data/Gemfile +0 -28
  87. data/Guardfile +0 -23
  88. data/backup.gemspec +0 -32
  89. data/lib/backup/cli/helpers.rb +0 -93
  90. data/lib/backup/cli/utility.rb +0 -255
  91. data/spec-live/.gitignore +0 -6
  92. data/spec-live/README +0 -7
  93. data/spec-live/backups/config.rb +0 -83
  94. data/spec-live/backups/config.yml.template +0 -46
  95. data/spec-live/backups/models.rb +0 -184
  96. data/spec-live/compressor/custom_spec.rb +0 -30
  97. data/spec-live/compressor/gzip_spec.rb +0 -30
  98. data/spec-live/encryptor/gpg_keys.rb +0 -239
  99. data/spec-live/encryptor/gpg_spec.rb +0 -287
  100. data/spec-live/notifier/mail_spec.rb +0 -121
  101. data/spec-live/spec_helper.rb +0 -151
  102. data/spec-live/storage/dropbox_spec.rb +0 -151
  103. data/spec-live/storage/local_spec.rb +0 -83
  104. data/spec-live/storage/scp_spec.rb +0 -193
  105. data/spec-live/syncer/cloud/s3_spec.rb +0 -124
  106. data/spec/archive_spec.rb +0 -335
  107. data/spec/cleaner_spec.rb +0 -312
  108. data/spec/cli/helpers_spec.rb +0 -301
  109. data/spec/cli/utility_spec.rb +0 -411
  110. data/spec/compressor/base_spec.rb +0 -52
  111. data/spec/compressor/bzip2_spec.rb +0 -217
  112. data/spec/compressor/custom_spec.rb +0 -106
  113. data/spec/compressor/gzip_spec.rb +0 -217
  114. data/spec/compressor/lzma_spec.rb +0 -123
  115. data/spec/compressor/pbzip2_spec.rb +0 -165
  116. data/spec/config_spec.rb +0 -321
  117. data/spec/configuration/helpers_spec.rb +0 -247
  118. data/spec/configuration/store_spec.rb +0 -39
  119. data/spec/configuration_spec.rb +0 -62
  120. data/spec/database/base_spec.rb +0 -63
  121. data/spec/database/mongodb_spec.rb +0 -510
  122. data/spec/database/mysql_spec.rb +0 -411
  123. data/spec/database/postgresql_spec.rb +0 -353
  124. data/spec/database/redis_spec.rb +0 -334
  125. data/spec/database/riak_spec.rb +0 -176
  126. data/spec/dependency_spec.rb +0 -51
  127. data/spec/encryptor/base_spec.rb +0 -40
  128. data/spec/encryptor/gpg_spec.rb +0 -909
  129. data/spec/encryptor/open_ssl_spec.rb +0 -148
  130. data/spec/errors_spec.rb +0 -306
  131. data/spec/logger_spec.rb +0 -367
  132. data/spec/model_spec.rb +0 -666
  133. data/spec/notifier/base_spec.rb +0 -104
  134. data/spec/notifier/campfire_spec.rb +0 -217
  135. data/spec/notifier/hipchat_spec.rb +0 -211
  136. data/spec/notifier/mail_spec.rb +0 -316
  137. data/spec/notifier/prowl_spec.rb +0 -138
  138. data/spec/notifier/pushover_spec.rb +0 -123
  139. data/spec/notifier/twitter_spec.rb +0 -153
  140. data/spec/package_spec.rb +0 -61
  141. data/spec/packager_spec.rb +0 -213
  142. data/spec/pipeline_spec.rb +0 -259
  143. data/spec/spec_helper.rb +0 -60
  144. data/spec/splitter_spec.rb +0 -120
  145. data/spec/storage/base_spec.rb +0 -166
  146. data/spec/storage/cloudfiles_spec.rb +0 -254
  147. data/spec/storage/cycler_spec.rb +0 -247
  148. data/spec/storage/dropbox_spec.rb +0 -480
  149. data/spec/storage/ftp_spec.rb +0 -271
  150. data/spec/storage/local_spec.rb +0 -259
  151. data/spec/storage/ninefold_spec.rb +0 -343
  152. data/spec/storage/rsync_spec.rb +0 -362
  153. data/spec/storage/s3_spec.rb +0 -245
  154. data/spec/storage/scp_spec.rb +0 -233
  155. data/spec/storage/sftp_spec.rb +0 -244
  156. data/spec/syncer/base_spec.rb +0 -109
  157. data/spec/syncer/cloud/base_spec.rb +0 -515
  158. data/spec/syncer/cloud/cloud_files_spec.rb +0 -181
  159. data/spec/syncer/cloud/s3_spec.rb +0 -174
  160. data/spec/syncer/rsync/base_spec.rb +0 -98
  161. data/spec/syncer/rsync/local_spec.rb +0 -149
  162. data/spec/syncer/rsync/pull_spec.rb +0 -98
  163. data/spec/syncer/rsync/push_spec.rb +0 -333
  164. data/spec/version_spec.rb +0 -21
  165. data/templates/cli/utility/config +0 -32
  166. data/templates/cli/utility/database/riak +0 -11
@@ -1,316 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Notifier::Mail do
6
- let(:model) { Backup::Model.new(:test_trigger, 'test label') }
7
- let(:notifier) do
8
- Backup::Notifier::Mail.new(model) do |mail|
9
- mail.delivery_method = :smtp
10
- mail.from = 'my.sender.email@gmail.com'
11
- mail.to = 'my.receiver.email@gmail.com'
12
- mail.address = 'smtp.gmail.com'
13
- mail.port = 587
14
- mail.domain = 'your.host.name'
15
- mail.user_name = 'user'
16
- mail.password = 'secret'
17
- mail.authentication = 'plain'
18
- mail.enable_starttls_auto = true
19
-
20
- mail.sendmail = '/path/to/sendmail'
21
- mail.sendmail_args = '-i -t -X/tmp/traffic.log'
22
- mail.exim = '/path/to/exim'
23
- mail.exim_args = '-i -t -X/tmp/traffic.log'
24
-
25
- mail.mail_folder = '/path/to/backup/mails'
26
- end
27
- end
28
-
29
- it 'should be a subclass of Notifier::Base' do
30
- Backup::Notifier::Mail.
31
- superclass.should == Backup::Notifier::Base
32
- end
33
-
34
- describe '#initialize' do
35
- after { Backup::Notifier::Mail.clear_defaults! }
36
-
37
- it 'should load pre-configured defaults through Base' do
38
- Backup::Notifier::Mail.any_instance.expects(:load_defaults!)
39
- notifier
40
- end
41
-
42
- it 'should pass the model reference to Base' do
43
- notifier.instance_variable_get(:@model).should == model
44
- end
45
-
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
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'
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)
109
- notifier.delivery_method.should == :file
110
- notifier.from.should == 'default.sender@domain.com'
111
- notifier.to.should == 'some.receiver@domain.com'
112
- notifier.address.should be_nil
113
- notifier.port.should be_nil
114
- notifier.domain.should be_nil
115
- notifier.user_name.should be_nil
116
- notifier.password.should be_nil
117
- notifier.authentication.should be_nil
118
- notifier.enable_starttls_auto.should be_nil
119
-
120
- notifier.sendmail.should be_nil
121
- notifier.sendmail_args.should be_nil
122
- notifier.exim.should be_nil
123
- notifier.exim_args.should be_nil
124
-
125
- notifier.mail_folder.should be_nil
126
-
127
- notifier.on_success.should == false
128
- notifier.on_warning.should == true
129
- notifier.on_failure.should == true
130
- end
131
-
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
139
- end
140
-
141
- notifier.delivery_method.should == :sendmail
142
- notifier.from.should == 'new.sender@domain.com'
143
- notifier.to.should == 'new.receiver@domain.com'
144
- notifier.port.should == 123
145
-
146
- notifier.on_success.should == false
147
- notifier.on_warning.should == false
148
- notifier.on_failure.should == true
149
- end
150
- end # context 'when pre-configured defaults have been set'
151
- end # describe '#initialize'
152
-
153
- describe '#notify!' do
154
- let(:template) { mock }
155
- let(:message) { '[Backup::%s] test label (test_trigger)' }
156
-
157
- before do
158
- notifier.instance_variable_set(:@template, template)
159
- notifier.delivery_method = :test
160
- ::Mail::TestMailer.deliveries.clear
161
- end
162
-
163
- context 'when status is :success' do
164
- it 'should send a Success email with no attachments' do
165
- template.expects(:result).
166
- with('notifier/mail/success.erb').
167
- returns('message body')
168
-
169
- notifier.send(:notify!, :success)
170
-
171
- sent_message = ::Mail::TestMailer.deliveries.first
172
- sent_message.subject.should == message % 'Success'
173
- sent_message.multipart?.should be_false
174
- sent_message.body.should == 'message body'
175
- sent_message.has_attachments?.should be_false
176
- end
177
- end
178
-
179
- context 'when status is :warning' do
180
- before do
181
- Backup::Logger.stubs(:has_warnings?).returns(true)
182
- Backup::Logger.stubs(:messages).returns(['line 1', 'line 2', 'line 3'])
183
- end
184
-
185
- it 'should send a Warning email with an attached log' do
186
- template.expects(:result).
187
- with('notifier/mail/warning.erb').
188
- returns('message body')
189
-
190
- notifier.send(:notify!, :warning)
191
-
192
- sent_message = ::Mail::TestMailer.deliveries.first
193
- sent_message.subject.should == message % 'Warning'
194
- sent_message.body.multipart?.should be_true
195
- sent_message.text_part.decoded.should == 'message body'
196
- sent_message.attachments["#{model.time}.#{model.trigger}.log"].
197
- read.should == "line 1\nline 2\nline 3"
198
- end
199
- end
200
-
201
- context 'when status is :failure' do
202
- before do
203
- Backup::Logger.stubs(:messages).returns(['line 1', 'line 2', 'line 3'])
204
- end
205
-
206
- it 'should send a Failure email with an attached log' do
207
- template.expects(:result).
208
- with('notifier/mail/failure.erb').
209
- returns('message body')
210
-
211
- notifier.send(:notify!, :failure)
212
-
213
- sent_message = ::Mail::TestMailer.deliveries.first
214
- sent_message.subject.should == message % 'Failure'
215
- sent_message.body.multipart?.should be_true
216
- sent_message.text_part.decoded.should == 'message body'
217
- sent_message.attachments["#{model.time}.#{model.trigger}.log"].
218
- read.should == "line 1\nline 2\nline 3"
219
- end
220
- end
221
- end # describe '#notify!'
222
-
223
- describe '#new_email' do
224
- context 'when no delivery_method is set' do
225
- before { notifier.delivery_method = nil }
226
- it 'should default to :smtp' do
227
- email = notifier.send(:new_email)
228
- email.should be_an_instance_of ::Mail::Message
229
- email.delivery_method.should be_an_instance_of ::Mail::SMTP
230
- end
231
- end
232
-
233
- context 'when delivery_method is :smtp' do
234
- before { notifier.delivery_method = :smtp }
235
-
236
- it 'should return an email using SMTP' do
237
- email = notifier.send(:new_email)
238
- email.delivery_method.should be_an_instance_of ::Mail::SMTP
239
- end
240
-
241
- it 'should set the proper options' do
242
- email = notifier.send(:new_email)
243
-
244
- email.to.should == ['my.receiver.email@gmail.com']
245
- email.from.should == ['my.sender.email@gmail.com']
246
-
247
- settings = email.delivery_method.settings
248
- settings[:address].should == 'smtp.gmail.com'
249
- settings[:port].should == 587
250
- settings[:domain].should == 'your.host.name'
251
- settings[:user_name].should == 'user'
252
- settings[:password].should == 'secret'
253
- settings[:authentication].should == 'plain'
254
- settings[:enable_starttls_auto].should == true
255
- settings[:openssl_verify_mode].should be_nil
256
- end
257
- end
258
-
259
- context 'when delivery_method is :sendmail' do
260
- before { notifier.delivery_method = :sendmail }
261
- it 'should return an email using Sendmail' do
262
- email = notifier.send(:new_email)
263
- email.delivery_method.should be_an_instance_of ::Mail::Sendmail
264
- end
265
-
266
- it 'should set the proper options' do
267
- email = notifier.send(:new_email)
268
-
269
- email.to.should == ['my.receiver.email@gmail.com']
270
- email.from.should == ['my.sender.email@gmail.com']
271
-
272
- settings = email.delivery_method.settings
273
- settings[:location].should == '/path/to/sendmail'
274
- settings[:arguments].should == '-i -t -X/tmp/traffic.log'
275
- end
276
- end
277
-
278
- context 'when delivery_method is :exim' do
279
- before { notifier.delivery_method = :exim }
280
- it 'should return an email using Exim' do
281
- email = notifier.send(:new_email)
282
- email.delivery_method.should be_an_instance_of ::Mail::Exim
283
- end
284
-
285
- it 'should set the proper options' do
286
- email = notifier.send(:new_email)
287
-
288
- email.to.should == ['my.receiver.email@gmail.com']
289
- email.from.should == ['my.sender.email@gmail.com']
290
-
291
- settings = email.delivery_method.settings
292
- settings[:location].should == '/path/to/exim'
293
- settings[:arguments].should == '-i -t -X/tmp/traffic.log'
294
- end
295
- end
296
-
297
- context 'when delivery_method is :file' do
298
- before { notifier.delivery_method = :file }
299
- it 'should return an email using FileDelievery' do
300
- email = notifier.send(:new_email)
301
- email.delivery_method.should be_an_instance_of ::Mail::FileDelivery
302
- end
303
-
304
- it 'should set the proper options' do
305
- email = notifier.send(:new_email)
306
-
307
- email.to.should == ['my.receiver.email@gmail.com']
308
- email.from.should == ['my.sender.email@gmail.com']
309
-
310
- settings = email.delivery_method.settings
311
- settings[:location].should == '/path/to/backup/mails'
312
- end
313
- end
314
- end # describe '#new_email'
315
-
316
- end
@@ -1,138 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Notifier::Prowl do
6
- let(:model) { Backup::Model.new(:test_trigger, 'test label') }
7
- let(:notifier) do
8
- Backup::Notifier::Prowl.new(model) do |prowl|
9
- prowl.application = 'application'
10
- prowl.api_key = 'api_key'
11
- end
12
- end
13
-
14
- it 'should be a subclass of Notifier::Base' do
15
- Backup::Notifier::Prowl.
16
- superclass.should == Backup::Notifier::Base
17
- end
18
-
19
- describe '#initialize' do
20
- after { Backup::Notifier::Prowl.clear_defaults! }
21
-
22
- it 'should load pre-configured defaults through Base' do
23
- Backup::Notifier::Prowl.any_instance.expects(:load_defaults!)
24
- notifier
25
- end
26
-
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
40
-
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
45
-
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
61
- end
62
- end
63
-
64
- it 'should use pre-configured defaults' do
65
- notifier = Backup::Notifier::Prowl.new(model)
66
- notifier.application.should == 'default_app'
67
- notifier.api_key.should == 'default_api_key'
68
-
69
- notifier.on_success.should == false
70
- notifier.on_warning.should == false
71
- notifier.on_failure.should == false
72
- end
73
-
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'
78
-
79
- n.on_success = false
80
- n.on_warning = true
81
- n.on_failure = true
82
- end
83
-
84
- notifier.application.should == 'new_app'
85
- notifier.api_key.should == 'new_api_key'
86
-
87
- notifier.on_success.should == false
88
- notifier.on_warning.should == true
89
- notifier.on_failure.should == true
90
- end
91
- end # context 'when pre-configured defaults have been set'
92
- end # describe '#initialize'
93
-
94
- describe '#notify!' do
95
- context 'when status is :success' do
96
- it 'should send Success message' do
97
- notifier.expects(:send_message).with(
98
- '[Backup::Success]'
99
- )
100
- notifier.send(:notify!, :success)
101
- end
102
- end
103
-
104
- context 'when status is :warning' do
105
- it 'should send Warning message' do
106
- notifier.expects(:send_message).with(
107
- '[Backup::Warning]'
108
- )
109
- notifier.send(:notify!, :warning)
110
- end
111
- end
112
-
113
- context 'when status is :failure' do
114
- it 'should send Failure message' do
115
- notifier.expects(:send_message).with(
116
- '[Backup::Failure]'
117
- )
118
- notifier.send(:notify!, :failure)
119
- end
120
- end
121
- end # describe '#notify!'
122
-
123
- describe '#send_message' do
124
- it 'should send the given message' do
125
- client = mock
126
- Prowler.expects(:new).with(
127
- :application => 'application', :api_key => 'api_key'
128
- ).returns(client)
129
- client.expects(:notify).with(
130
- 'a message',
131
- 'test label (test_trigger)'
132
- )
133
-
134
- notifier.send(:send_message, 'a message')
135
- end
136
- end
137
-
138
- end