backup 3.0.19 → 3.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +9 -8
  3. data/Gemfile.lock +19 -1
  4. data/Guardfile +13 -9
  5. data/README.md +93 -31
  6. data/backup.gemspec +3 -3
  7. data/bin/backup +6 -283
  8. data/lib/backup.rb +101 -72
  9. data/lib/backup/archive.rb +21 -9
  10. data/lib/backup/binder.rb +22 -0
  11. data/lib/backup/cleaner.rb +36 -0
  12. data/lib/backup/cli/helpers.rb +103 -0
  13. data/lib/backup/cli/utility.rb +308 -0
  14. data/lib/backup/compressor/base.rb +2 -2
  15. data/lib/backup/compressor/pbzip2.rb +76 -0
  16. data/lib/backup/configuration/compressor/pbzip2.rb +28 -0
  17. data/lib/backup/configuration/database/riak.rb +25 -0
  18. data/lib/backup/configuration/encryptor/open_ssl.rb +6 -0
  19. data/lib/backup/configuration/helpers.rb +5 -18
  20. data/lib/backup/configuration/notifier/base.rb +13 -0
  21. data/lib/backup/configuration/notifier/hipchat.rb +41 -0
  22. data/lib/backup/configuration/notifier/mail.rb +38 -0
  23. data/lib/backup/configuration/notifier/prowl.rb +23 -0
  24. data/lib/backup/configuration/storage/cloudfiles.rb +4 -0
  25. data/lib/backup/configuration/storage/dropbox.rb +8 -4
  26. data/lib/backup/database/base.rb +10 -2
  27. data/lib/backup/database/mongodb.rb +16 -19
  28. data/lib/backup/database/mysql.rb +2 -2
  29. data/lib/backup/database/postgresql.rb +2 -2
  30. data/lib/backup/database/redis.rb +15 -7
  31. data/lib/backup/database/riak.rb +45 -0
  32. data/lib/backup/dependency.rb +21 -7
  33. data/lib/backup/encryptor/base.rb +1 -1
  34. data/lib/backup/encryptor/open_ssl.rb +20 -5
  35. data/lib/backup/errors.rb +124 -0
  36. data/lib/backup/finder.rb +11 -3
  37. data/lib/backup/logger.rb +121 -82
  38. data/lib/backup/model.rb +103 -44
  39. data/lib/backup/notifier/base.rb +50 -0
  40. data/lib/backup/notifier/campfire.rb +32 -52
  41. data/lib/backup/notifier/hipchat.rb +99 -0
  42. data/lib/backup/notifier/mail.rb +100 -61
  43. data/lib/backup/notifier/presently.rb +31 -40
  44. data/lib/backup/notifier/prowl.rb +73 -0
  45. data/lib/backup/notifier/twitter.rb +29 -39
  46. data/lib/backup/packager.rb +25 -0
  47. data/lib/backup/splitter.rb +62 -0
  48. data/lib/backup/storage/base.rb +178 -18
  49. data/lib/backup/storage/cloudfiles.rb +34 -28
  50. data/lib/backup/storage/dropbox.rb +64 -67
  51. data/lib/backup/storage/ftp.rb +48 -40
  52. data/lib/backup/storage/local.rb +33 -28
  53. data/lib/backup/storage/ninefold.rb +40 -26
  54. data/lib/backup/storage/object.rb +8 -6
  55. data/lib/backup/storage/rsync.rb +61 -51
  56. data/lib/backup/storage/s3.rb +29 -27
  57. data/lib/backup/storage/scp.rb +56 -36
  58. data/lib/backup/storage/sftp.rb +49 -33
  59. data/lib/backup/syncer/base.rb +1 -1
  60. data/lib/backup/syncer/rsync.rb +1 -1
  61. data/lib/backup/template.rb +46 -0
  62. data/lib/backup/version.rb +1 -1
  63. data/spec/archive_spec.rb +34 -9
  64. data/spec/backup_spec.rb +1 -1
  65. data/spec/cli/helpers_spec.rb +35 -0
  66. data/spec/cli/utility_spec.rb +38 -0
  67. data/spec/compressor/bzip2_spec.rb +1 -1
  68. data/spec/compressor/gzip_spec.rb +1 -1
  69. data/spec/compressor/lzma_spec.rb +1 -1
  70. data/spec/compressor/pbzip2_spec.rb +63 -0
  71. data/spec/configuration/base_spec.rb +1 -1
  72. data/spec/configuration/compressor/bzip2_spec.rb +1 -1
  73. data/spec/configuration/compressor/gzip_spec.rb +1 -1
  74. data/spec/configuration/compressor/lzma_spec.rb +1 -1
  75. data/spec/configuration/database/base_spec.rb +1 -1
  76. data/spec/configuration/database/mongodb_spec.rb +1 -1
  77. data/spec/configuration/database/mysql_spec.rb +1 -1
  78. data/spec/configuration/database/postgresql_spec.rb +1 -1
  79. data/spec/configuration/database/redis_spec.rb +1 -1
  80. data/spec/configuration/database/riak_spec.rb +31 -0
  81. data/spec/configuration/encryptor/gpg_spec.rb +1 -1
  82. data/spec/configuration/encryptor/open_ssl_spec.rb +4 -1
  83. data/spec/configuration/notifier/campfire_spec.rb +1 -1
  84. data/spec/configuration/notifier/hipchat_spec.rb +43 -0
  85. data/spec/configuration/notifier/mail_spec.rb +34 -22
  86. data/spec/configuration/notifier/presently_spec.rb +1 -1
  87. data/spec/configuration/notifier/prowl_spec.rb +28 -0
  88. data/spec/configuration/notifier/twitter_spec.rb +1 -1
  89. data/spec/configuration/storage/cloudfiles_spec.rb +19 -16
  90. data/spec/configuration/storage/dropbox_spec.rb +1 -1
  91. data/spec/configuration/storage/ftp_spec.rb +1 -1
  92. data/spec/configuration/storage/local_spec.rb +1 -1
  93. data/spec/configuration/storage/ninefold_spec.rb +1 -1
  94. data/spec/configuration/storage/rsync_spec.rb +1 -1
  95. data/spec/configuration/storage/s3_spec.rb +1 -1
  96. data/spec/configuration/storage/scp_spec.rb +1 -1
  97. data/spec/configuration/storage/sftp_spec.rb +1 -1
  98. data/spec/configuration/syncer/rsync_spec.rb +1 -1
  99. data/spec/configuration/syncer/s3_spec.rb +1 -1
  100. data/spec/database/base_spec.rb +10 -1
  101. data/spec/database/mongodb_spec.rb +34 -7
  102. data/spec/database/mysql_spec.rb +8 -7
  103. data/spec/database/postgresql_spec.rb +8 -7
  104. data/spec/database/redis_spec.rb +39 -9
  105. data/spec/database/riak_spec.rb +50 -0
  106. data/spec/encryptor/gpg_spec.rb +1 -1
  107. data/spec/encryptor/open_ssl_spec.rb +77 -20
  108. data/spec/errors_spec.rb +306 -0
  109. data/spec/finder_spec.rb +91 -0
  110. data/spec/logger_spec.rb +254 -33
  111. data/spec/model_spec.rb +120 -15
  112. data/spec/notifier/campfire_spec.rb +127 -52
  113. data/spec/notifier/hipchat_spec.rb +193 -0
  114. data/spec/notifier/mail_spec.rb +290 -74
  115. data/spec/notifier/presently_spec.rb +290 -73
  116. data/spec/notifier/prowl_spec.rb +149 -0
  117. data/spec/notifier/twitter_spec.rb +106 -41
  118. data/spec/spec_helper.rb +8 -2
  119. data/spec/splitter_spec.rb +71 -0
  120. data/spec/storage/base_spec.rb +280 -19
  121. data/spec/storage/cloudfiles_spec.rb +38 -22
  122. data/spec/storage/dropbox_spec.rb +17 -13
  123. data/spec/storage/ftp_spec.rb +145 -55
  124. data/spec/storage/local_spec.rb +6 -6
  125. data/spec/storage/ninefold_spec.rb +70 -29
  126. data/spec/storage/object_spec.rb +44 -44
  127. data/spec/storage/rsync_spec.rb +186 -63
  128. data/spec/storage/s3_spec.rb +23 -24
  129. data/spec/storage/scp_spec.rb +116 -41
  130. data/spec/storage/sftp_spec.rb +124 -46
  131. data/spec/syncer/rsync_spec.rb +3 -3
  132. data/spec/syncer/s3_spec.rb +1 -1
  133. data/spec/version_spec.rb +1 -1
  134. data/templates/cli/utility/archive +13 -0
  135. data/{lib/templates → templates/cli/utility}/compressor/bzip2 +1 -1
  136. data/{lib/templates → templates/cli/utility}/compressor/gzip +1 -1
  137. data/{lib/templates → templates/cli/utility}/compressor/lzma +0 -0
  138. data/templates/cli/utility/compressor/pbzip2 +7 -0
  139. data/templates/cli/utility/config +31 -0
  140. data/{lib/templates → templates/cli/utility}/database/mongodb +1 -1
  141. data/{lib/templates → templates/cli/utility}/database/mysql +1 -1
  142. data/{lib/templates → templates/cli/utility}/database/postgresql +1 -1
  143. data/{lib/templates → templates/cli/utility}/database/redis +1 -1
  144. data/templates/cli/utility/database/riak +8 -0
  145. data/{lib/templates → templates/cli/utility}/encryptor/gpg +1 -1
  146. data/templates/cli/utility/encryptor/openssl +9 -0
  147. data/templates/cli/utility/model.erb +23 -0
  148. data/{lib/templates → templates/cli/utility}/notifier/campfire +2 -1
  149. data/templates/cli/utility/notifier/hipchat +15 -0
  150. data/{lib/templates → templates/cli/utility}/notifier/mail +6 -1
  151. data/{lib/templates → templates/cli/utility}/notifier/presently +1 -0
  152. data/templates/cli/utility/notifier/prowl +11 -0
  153. data/{lib/templates → templates/cli/utility}/notifier/twitter +2 -1
  154. data/templates/cli/utility/splitter +7 -0
  155. data/templates/cli/utility/storage/cloudfiles +12 -0
  156. data/{lib/templates → templates/cli/utility}/storage/dropbox +1 -1
  157. data/{lib/templates → templates/cli/utility}/storage/ftp +0 -0
  158. data/templates/cli/utility/storage/local +7 -0
  159. data/{lib/templates → templates/cli/utility}/storage/ninefold +1 -1
  160. data/templates/cli/utility/storage/rsync +11 -0
  161. data/{lib/templates → templates/cli/utility}/storage/s3 +0 -2
  162. data/templates/cli/utility/storage/scp +11 -0
  163. data/templates/cli/utility/storage/sftp +11 -0
  164. data/{lib/templates → templates/cli/utility}/syncer/rsync +1 -1
  165. data/{lib/templates → templates/cli/utility}/syncer/s3 +1 -1
  166. data/templates/general/links +11 -0
  167. data/templates/general/version.erb +2 -0
  168. data/templates/notifier/mail/failure.erb +9 -0
  169. data/templates/notifier/mail/success.erb +7 -0
  170. data/templates/notifier/mail/warning.erb +9 -0
  171. data/templates/storage/dropbox/authorization_url.erb +6 -0
  172. data/templates/storage/dropbox/authorized.erb +4 -0
  173. data/templates/storage/dropbox/cache_file_written.erb +10 -0
  174. metadata +81 -45
  175. data/lib/backup/cli.rb +0 -110
  176. data/lib/backup/exception/command_failed.rb +0 -8
  177. data/lib/backup/exception/command_not_found.rb +0 -8
  178. data/lib/backup/notifier/binder.rb +0 -32
  179. data/lib/backup/notifier/templates/notify_failure.erb +0 -33
  180. data/lib/backup/notifier/templates/notify_success.erb +0 -16
  181. data/lib/templates/archive +0 -7
  182. data/lib/templates/encryptor/openssl +0 -8
  183. data/lib/templates/readme +0 -15
  184. data/lib/templates/storage/cloudfiles +0 -11
  185. data/lib/templates/storage/local +0 -7
  186. data/lib/templates/storage/rsync +0 -11
  187. data/lib/templates/storage/scp +0 -11
  188. data/lib/templates/storage/sftp +0 -11
data/spec/backup_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/spec_helper'
3
+ require File.expand_path('../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup do
6
6
  it do
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::CLI::Helpers do
6
+ let(:helpers) { Module.new.extend(subject) }
7
+
8
+ describe '#raise_if_command_failed!' do
9
+
10
+ it 'returns nil if status exit code is in ignore_exit_codes' do
11
+ process_data = { :status => '3', :ignore_exit_codes => [1,3,5] }
12
+ helpers.raise_if_command_failed!('foo', process_data).should be_nil
13
+ end
14
+
15
+ it 'raises an error with stdout/stderr data' do
16
+ process_data = { :status => '3', :ignore_exit_codes => [2,4,6],
17
+ :stdout => 'stdout data', :stderr => 'stderr data' }
18
+
19
+ expect do
20
+ helpers.raise_if_command_failed!('utility_name', process_data)
21
+ end.to raise_error(
22
+ Backup::Errors::CLI::SystemCallError,
23
+ "CLI::SystemCallError: Failed to run utility_name on #{RUBY_PLATFORM}\n" +
24
+ " The following information should help to determine the problem:\n" +
25
+ " Exit Code: 3\n" +
26
+ " STDERR:\n" +
27
+ " stderr data\n" +
28
+ " STDOUT:\n" +
29
+ " stdout data"
30
+ )
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe 'Backup::CLI::Utility' do
6
+ let(:cli) { Backup::CLI::Utility }
7
+
8
+ describe '#perform' do
9
+
10
+ context 'when errors occur' do
11
+
12
+ before do
13
+ @argv_save = ARGV
14
+ end
15
+
16
+ after do
17
+ ARGV.replace(@argv_save)
18
+ end
19
+
20
+ it 'should log the error and exit' do
21
+ ARGV.replace(['perform', '-t', 'foo'])
22
+ FileUtils.stubs(:mkdir_p).raises(SystemCallError, 'yikes!')
23
+
24
+ Backup::Logger.expects(:error).with do |err|
25
+ err.message.should ==
26
+ "CLIError: SystemCallError: unknown error - yikes!"
27
+ end
28
+
29
+ expect do
30
+ cli.start
31
+ end.to raise_error(SystemExit)
32
+ end
33
+
34
+ end # context 'when errors occur'
35
+
36
+ end # describe '#perform'
37
+
38
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../spec_helper'
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Compressor::Bzip2 do
6
6
  let(:compressor) { Backup::Compressor::Bzip2.new }
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../spec_helper'
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Compressor::Gzip do
6
6
  let(:compressor) { Backup::Compressor::Gzip.new }
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../spec_helper'
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Compressor::Lzma do
6
6
  let(:compressor) { Backup::Compressor::Lzma.new }
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Compressor::Pbzip2 do
6
+ let(:compressor) { Backup::Compressor::Pbzip2.new }
7
+
8
+ before do
9
+ Backup::Model.extension = 'tar'
10
+ end
11
+
12
+ describe 'the options' do
13
+ it do
14
+ compressor.send(:best).should == []
15
+ end
16
+
17
+ it do
18
+ compressor.send(:fast).should == []
19
+ end
20
+
21
+ it do
22
+ compressor.send(:processors).should == []
23
+ end
24
+ end
25
+
26
+ describe '#perform!' do
27
+ before do
28
+ [:run, :utility].each { |method| compressor.stubs(method) }
29
+ end
30
+
31
+ it 'should perform the compression' do
32
+ compressor.expects(:utility).with(:pbzip2).returns(:pbzip2)
33
+ compressor.expects(:run).with("pbzip2 '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
34
+ compressor.perform!
35
+ end
36
+
37
+ it 'should perform the compression with the --best, --fast and -p1 options' do
38
+ compressor = Backup::Compressor::Pbzip2.new do |c|
39
+ c.best = true
40
+ c.fast = true
41
+ c.processors = 1
42
+ end
43
+
44
+ compressor.stubs(:utility).returns(:pbzip2)
45
+ compressor.expects(:run).with("pbzip2 --best --fast -p1 '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
46
+ compressor.perform!
47
+ end
48
+
49
+ it 'should set the class variable @extension (Backup::Model.extension) to .bz2' do
50
+ compressor.stubs(:utility).returns(:pbzip2)
51
+ compressor.expects(:run)
52
+
53
+ Backup::Model.extension.should == 'tar'
54
+ compressor.perform!
55
+ Backup::Model.extension.should == 'tar.bz2'
56
+ end
57
+
58
+ it 'should log' do
59
+ Backup::Logger.expects(:message).with("Backup::Compressor::Pbzip2 started compressing the archive.")
60
+ compressor.perform!
61
+ end
62
+ end
63
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../spec_helper'
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Helpers do
6
6
 
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Compressor::Bzip2 do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Compressor::Gzip do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Compressor::Lzma do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Database::Base do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Database::MongoDB do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Database::MySQL do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Database::PostgreSQL do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Database::Redis do
6
6
  before do
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Database::Riak do
6
+ before do
7
+ Backup::Configuration::Database::Riak.defaults do |db|
8
+ db.name = 'mydb'
9
+ db.node = '/var/lib/redis/db'
10
+ db.cookie = 'mypassword'
11
+ end
12
+ end
13
+
14
+ it 'should set the default Riak configuration' do
15
+ db = Backup::Configuration::Database::Riak
16
+ db.name.should == 'mydb'
17
+ db.node.should == '/var/lib/redis/db'
18
+ db.cookie.should == 'mypassword'
19
+ end
20
+
21
+ describe '#clear_defaults!' do
22
+ it 'should clear all the defaults, resetting them to nil' do
23
+ Backup::Configuration::Database::Riak.clear_defaults!
24
+
25
+ db = Backup::Configuration::Database::Riak
26
+ db.name.should == nil
27
+ db.node.should == nil
28
+ db.cookie.should == nil
29
+ end
30
+ end
31
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Encryptor::GPG do
6
6
  before do
@@ -1,11 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Encryptor::OpenSSL do
6
6
  before do
7
7
  Backup::Configuration::Encryptor::OpenSSL.defaults do |encryptor|
8
8
  encryptor.password = 'my_password'
9
+ encryptor.password_file = nil
9
10
  encryptor.base64 = true
10
11
  encryptor.salt = true
11
12
  end
@@ -14,6 +15,7 @@ describe Backup::Configuration::Encryptor::OpenSSL do
14
15
  it 'should set the default encryptor configuration' do
15
16
  encryptor = Backup::Configuration::Encryptor::OpenSSL
16
17
  encryptor.password.should == 'my_password'
18
+ encryptor.password_file.should == nil
17
19
  encryptor.base64.should == true
18
20
  encryptor.salt.should == true
19
21
  end
@@ -24,6 +26,7 @@ describe Backup::Configuration::Encryptor::OpenSSL do
24
26
 
25
27
  encryptor = Backup::Configuration::Encryptor::OpenSSL
26
28
  encryptor.password.should == nil
29
+ encryptor.password_file.should == nil
27
30
  encryptor.base64.should == nil
28
31
  encryptor.salt.should == nil
29
32
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Notifier::Campfire do
6
6
  before do
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Notifier::Hipchat do
6
+ before do
7
+ Backup::Configuration::Notifier::Hipchat.defaults do |hipchat|
8
+ hipchat.token = 'token'
9
+ hipchat.from = 'DB Backup'
10
+ hipchat.rooms_notified = ['activity']
11
+ hipchat.success_color = 'green'
12
+ hipchat.warning_color = 'yellow'
13
+ hipchat.failure_color = 'red'
14
+ hipchat.notify_users = true
15
+ end
16
+ end
17
+
18
+ it 'should set the default tweet configuration' do
19
+ hipchat = Backup::Configuration::Notifier::Hipchat
20
+ hipchat.token.should == 'token'
21
+ hipchat.from.should == 'DB Backup'
22
+ hipchat.rooms_notified.should == ['activity']
23
+ hipchat.success_color.should == 'green'
24
+ hipchat.warning_color.should == 'yellow'
25
+ hipchat.failure_color.should == 'red'
26
+ hipchat.notify_users.should == true
27
+ end
28
+
29
+ describe '#clear_defaults!' do
30
+ it 'should clear all the defaults, resetting them to nil' do
31
+ Backup::Configuration::Notifier::Hipchat.clear_defaults!
32
+
33
+ hipchat = Backup::Configuration::Notifier::Hipchat
34
+ hipchat.token.should == nil
35
+ hipchat.from.should == nil
36
+ hipchat.rooms_notified.should == nil
37
+ hipchat.success_color.should == nil
38
+ hipchat.warning_color.should == nil
39
+ hipchat.failure_color.should == nil
40
+ hipchat.notify_users.should == nil
41
+ end
42
+ end
43
+ end
@@ -1,10 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Configuration::Notifier::Mail do
6
6
  before do
7
7
  Backup::Configuration::Notifier::Mail.defaults do |mail|
8
+ mail.delivery_method = :file
8
9
  mail.from = 'my.sender.email@gmail.com'
9
10
  mail.to = 'my.receiver.email@gmail.com'
10
11
  mail.address = 'smtp.gmail.com'
@@ -14,22 +15,29 @@ describe Backup::Configuration::Notifier::Mail do
14
15
  mail.password = 'secret'
15
16
  mail.authentication = 'plain'
16
17
  mail.enable_starttls_auto = true
17
- mail.openssl_verify_mode = true
18
+ mail.openssl_verify_mode = 'none'
19
+ mail.sendmail = '/path/to/sendmail'
20
+ mail.sendmail_args = '-i -t -X/tmp/traffic.log'
21
+ mail.mail_folder = '/path/to/backup/mails'
18
22
  end
19
23
  end
20
24
 
21
25
  it 'should set the default Mail configuration' do
22
26
  mail = Backup::Configuration::Notifier::Mail
23
- mail.from.should == 'my.sender.email@gmail.com'
24
- mail.to.should == 'my.receiver.email@gmail.com'
25
- mail.address.should == 'smtp.gmail.com'
26
- mail.port.should == 587
27
- mail.domain.should == 'your.host.name'
28
- mail.user_name.should == 'user'
29
- mail.password.should == 'secret'
30
- mail.authentication.should == 'plain'
31
- mail.enable_starttls_auto.should == true
32
- mail.openssl_verify_mode.should == true
27
+ mail.delivery_method.should == :file
28
+ mail.from.should == 'my.sender.email@gmail.com'
29
+ mail.to.should == 'my.receiver.email@gmail.com'
30
+ mail.address.should == 'smtp.gmail.com'
31
+ mail.port.should == 587
32
+ mail.domain.should == 'your.host.name'
33
+ mail.user_name.should == 'user'
34
+ mail.password.should == 'secret'
35
+ mail.authentication.should == 'plain'
36
+ mail.enable_starttls_auto.should == true
37
+ mail.openssl_verify_mode.should == 'none'
38
+ mail.sendmail.should == '/path/to/sendmail'
39
+ mail.sendmail_args.should == '-i -t -X/tmp/traffic.log'
40
+ mail.mail_folder.should == '/path/to/backup/mails'
33
41
  end
34
42
 
35
43
  describe '#clear_defaults!' do
@@ -37,16 +45,20 @@ describe Backup::Configuration::Notifier::Mail do
37
45
  Backup::Configuration::Notifier::Mail.clear_defaults!
38
46
 
39
47
  mail = Backup::Configuration::Notifier::Mail
40
- mail.from.should == nil
41
- mail.to.should == nil
42
- mail.address.should == nil
43
- mail.port.should == nil
44
- mail.domain.should == nil
45
- mail.user_name.should == nil
46
- mail.password.should == nil
47
- mail.authentication.should == nil
48
- mail.enable_starttls_auto.should == nil
49
- mail.openssl_verify_mode.should == nil
48
+ mail.delivery_method.should == nil
49
+ mail.from.should == nil
50
+ mail.to.should == nil
51
+ mail.address.should == nil
52
+ mail.port.should == nil
53
+ mail.domain.should == nil
54
+ mail.user_name.should == nil
55
+ mail.password.should == nil
56
+ mail.authentication.should == nil
57
+ mail.enable_starttls_auto.should == nil
58
+ mail.openssl_verify_mode.should == nil
59
+ mail.sendmail.should == nil
60
+ mail.sendmail_args.should == nil
61
+ mail.mail_folder.should == nil
50
62
  end
51
63
  end
52
64
  end