backup 3.0.23 → 3.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. data/Gemfile.lock +42 -45
  2. data/Guardfile +7 -4
  3. data/README.md +10 -7
  4. data/backup.gemspec +2 -2
  5. data/lib/backup.rb +27 -97
  6. data/lib/backup/archive.rb +14 -6
  7. data/lib/backup/cli/helpers.rb +52 -49
  8. data/lib/backup/cli/utility.rb +9 -1
  9. data/lib/backup/compressor/base.rb +10 -4
  10. data/lib/backup/compressor/bzip2.rb +22 -26
  11. data/lib/backup/compressor/custom.rb +53 -0
  12. data/lib/backup/compressor/gzip.rb +22 -23
  13. data/lib/backup/compressor/lzma.rb +15 -13
  14. data/lib/backup/compressor/pbzip2.rb +20 -17
  15. data/lib/backup/config.rb +6 -3
  16. data/lib/backup/configuration.rb +33 -0
  17. data/lib/backup/configuration/helpers.rb +114 -28
  18. data/lib/backup/configuration/store.rb +24 -0
  19. data/lib/backup/database/base.rb +0 -6
  20. data/lib/backup/database/mongodb.rb +27 -11
  21. data/lib/backup/database/mysql.rb +19 -14
  22. data/lib/backup/database/postgresql.rb +16 -11
  23. data/lib/backup/database/redis.rb +7 -11
  24. data/lib/backup/database/riak.rb +3 -6
  25. data/lib/backup/dependency.rb +5 -11
  26. data/lib/backup/model.rb +14 -5
  27. data/lib/backup/notifier/campfire.rb +3 -16
  28. data/lib/backup/notifier/hipchat.rb +1 -7
  29. data/lib/backup/notifier/mail.rb +1 -1
  30. data/lib/backup/packager.rb +29 -19
  31. data/lib/backup/pipeline.rb +110 -0
  32. data/lib/backup/storage/dropbox.rb +4 -7
  33. data/lib/backup/syncer/base.rb +8 -4
  34. data/lib/backup/syncer/cloud/base.rb +247 -0
  35. data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
  36. data/lib/backup/syncer/cloud/s3.rb +68 -0
  37. data/lib/backup/syncer/rsync/base.rb +1 -4
  38. data/lib/backup/syncer/rsync/local.rb +9 -5
  39. data/lib/backup/syncer/rsync/pull.rb +1 -1
  40. data/lib/backup/syncer/rsync/push.rb +10 -5
  41. data/lib/backup/version.rb +1 -1
  42. data/spec-live/.gitignore +6 -0
  43. data/spec-live/README +7 -0
  44. data/spec-live/backups/config.rb +153 -0
  45. data/spec-live/backups/config.yml.template +43 -0
  46. data/spec-live/compressor/custom_spec.rb +30 -0
  47. data/spec-live/compressor/gzip_spec.rb +30 -0
  48. data/spec-live/notifier/mail_spec.rb +85 -0
  49. data/spec-live/spec_helper.rb +85 -0
  50. data/spec-live/storage/dropbox_spec.rb +151 -0
  51. data/spec-live/storage/local_spec.rb +83 -0
  52. data/spec-live/storage/scp_spec.rb +193 -0
  53. data/spec-live/syncer/cloud/s3_spec.rb +124 -0
  54. data/spec/archive_spec.rb +86 -31
  55. data/spec/cleaner_spec.rb +8 -0
  56. data/spec/cli/helpers_spec.rb +200 -75
  57. data/spec/cli/utility_spec.rb +11 -3
  58. data/spec/compressor/base_spec.rb +31 -10
  59. data/spec/compressor/bzip2_spec.rb +212 -57
  60. data/spec/compressor/custom_spec.rb +106 -0
  61. data/spec/compressor/gzip_spec.rb +212 -57
  62. data/spec/compressor/lzma_spec.rb +75 -35
  63. data/spec/compressor/pbzip2_spec.rb +93 -52
  64. data/spec/configuration/helpers_spec.rb +406 -0
  65. data/spec/configuration/store_spec.rb +39 -0
  66. data/spec/configuration_spec.rb +62 -0
  67. data/spec/database/base_spec.rb +19 -10
  68. data/spec/database/mongodb_spec.rb +195 -70
  69. data/spec/database/mysql_spec.rb +183 -64
  70. data/spec/database/postgresql_spec.rb +167 -53
  71. data/spec/database/redis_spec.rb +121 -46
  72. data/spec/database/riak_spec.rb +96 -27
  73. data/spec/dependency_spec.rb +2 -0
  74. data/spec/encryptor/base_spec.rb +10 -0
  75. data/spec/encryptor/gpg_spec.rb +29 -13
  76. data/spec/encryptor/open_ssl_spec.rb +40 -21
  77. data/spec/logger_spec.rb +4 -0
  78. data/spec/model_spec.rb +19 -2
  79. data/spec/notifier/base_spec.rb +32 -17
  80. data/spec/notifier/campfire_spec.rb +63 -45
  81. data/spec/notifier/hipchat_spec.rb +79 -56
  82. data/spec/notifier/mail_spec.rb +82 -46
  83. data/spec/notifier/prowl_spec.rb +53 -32
  84. data/spec/notifier/twitter_spec.rb +62 -41
  85. data/spec/packager_spec.rb +95 -36
  86. data/spec/pipeline_spec.rb +259 -0
  87. data/spec/spec_helper.rb +6 -5
  88. data/spec/storage/base_spec.rb +61 -41
  89. data/spec/storage/cloudfiles_spec.rb +69 -45
  90. data/spec/storage/dropbox_spec.rb +158 -36
  91. data/spec/storage/ftp_spec.rb +69 -45
  92. data/spec/storage/local_spec.rb +47 -23
  93. data/spec/storage/ninefold_spec.rb +55 -31
  94. data/spec/storage/rsync_spec.rb +67 -50
  95. data/spec/storage/s3_spec.rb +65 -41
  96. data/spec/storage/scp_spec.rb +65 -41
  97. data/spec/storage/sftp_spec.rb +65 -41
  98. data/spec/syncer/base_spec.rb +91 -4
  99. data/spec/syncer/cloud/base_spec.rb +511 -0
  100. data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
  101. data/spec/syncer/cloud/s3_spec.rb +174 -0
  102. data/spec/syncer/rsync/base_spec.rb +46 -66
  103. data/spec/syncer/rsync/local_spec.rb +55 -26
  104. data/spec/syncer/rsync/pull_spec.rb +15 -4
  105. data/spec/syncer/rsync/push_spec.rb +59 -52
  106. data/templates/cli/utility/compressor/bzip2 +1 -4
  107. data/templates/cli/utility/compressor/custom +11 -0
  108. data/templates/cli/utility/compressor/gzip +1 -4
  109. data/templates/cli/utility/compressor/lzma +3 -0
  110. data/templates/cli/utility/compressor/pbzip2 +3 -0
  111. data/templates/cli/utility/database/mysql +4 -1
  112. data/templates/cli/utility/syncer/cloud_files +17 -19
  113. data/templates/cli/utility/syncer/s3 +18 -20
  114. metadata +38 -92
  115. data/lib/backup/configuration/base.rb +0 -15
  116. data/lib/backup/configuration/compressor/base.rb +0 -9
  117. data/lib/backup/configuration/compressor/bzip2.rb +0 -23
  118. data/lib/backup/configuration/compressor/gzip.rb +0 -23
  119. data/lib/backup/configuration/compressor/lzma.rb +0 -23
  120. data/lib/backup/configuration/compressor/pbzip2.rb +0 -28
  121. data/lib/backup/configuration/database/base.rb +0 -19
  122. data/lib/backup/configuration/database/mongodb.rb +0 -49
  123. data/lib/backup/configuration/database/mysql.rb +0 -42
  124. data/lib/backup/configuration/database/postgresql.rb +0 -41
  125. data/lib/backup/configuration/database/redis.rb +0 -39
  126. data/lib/backup/configuration/database/riak.rb +0 -29
  127. data/lib/backup/configuration/encryptor/base.rb +0 -9
  128. data/lib/backup/configuration/encryptor/gpg.rb +0 -17
  129. data/lib/backup/configuration/encryptor/open_ssl.rb +0 -32
  130. data/lib/backup/configuration/notifier/base.rb +0 -28
  131. data/lib/backup/configuration/notifier/campfire.rb +0 -25
  132. data/lib/backup/configuration/notifier/hipchat.rb +0 -41
  133. data/lib/backup/configuration/notifier/mail.rb +0 -112
  134. data/lib/backup/configuration/notifier/presently.rb +0 -25
  135. data/lib/backup/configuration/notifier/prowl.rb +0 -23
  136. data/lib/backup/configuration/notifier/twitter.rb +0 -21
  137. data/lib/backup/configuration/storage/base.rb +0 -18
  138. data/lib/backup/configuration/storage/cloudfiles.rb +0 -25
  139. data/lib/backup/configuration/storage/dropbox.rb +0 -58
  140. data/lib/backup/configuration/storage/ftp.rb +0 -29
  141. data/lib/backup/configuration/storage/local.rb +0 -17
  142. data/lib/backup/configuration/storage/ninefold.rb +0 -20
  143. data/lib/backup/configuration/storage/rsync.rb +0 -29
  144. data/lib/backup/configuration/storage/s3.rb +0 -25
  145. data/lib/backup/configuration/storage/scp.rb +0 -25
  146. data/lib/backup/configuration/storage/sftp.rb +0 -25
  147. data/lib/backup/configuration/syncer/base.rb +0 -10
  148. data/lib/backup/configuration/syncer/cloud.rb +0 -23
  149. data/lib/backup/configuration/syncer/cloud_files.rb +0 -30
  150. data/lib/backup/configuration/syncer/rsync/base.rb +0 -28
  151. data/lib/backup/configuration/syncer/rsync/local.rb +0 -11
  152. data/lib/backup/configuration/syncer/rsync/pull.rb +0 -11
  153. data/lib/backup/configuration/syncer/rsync/push.rb +0 -31
  154. data/lib/backup/configuration/syncer/s3.rb +0 -23
  155. data/lib/backup/notifier/presently.rb +0 -88
  156. data/lib/backup/syncer/cloud.rb +0 -187
  157. data/lib/backup/syncer/cloud_files.rb +0 -56
  158. data/lib/backup/syncer/s3.rb +0 -47
  159. data/spec/configuration/base_spec.rb +0 -35
  160. data/spec/configuration/compressor/bzip2_spec.rb +0 -29
  161. data/spec/configuration/compressor/gzip_spec.rb +0 -29
  162. data/spec/configuration/compressor/lzma_spec.rb +0 -29
  163. data/spec/configuration/compressor/pbzip2_spec.rb +0 -32
  164. data/spec/configuration/database/base_spec.rb +0 -17
  165. data/spec/configuration/database/mongodb_spec.rb +0 -56
  166. data/spec/configuration/database/mysql_spec.rb +0 -53
  167. data/spec/configuration/database/postgresql_spec.rb +0 -53
  168. data/spec/configuration/database/redis_spec.rb +0 -50
  169. data/spec/configuration/database/riak_spec.rb +0 -35
  170. data/spec/configuration/encryptor/gpg_spec.rb +0 -26
  171. data/spec/configuration/encryptor/open_ssl_spec.rb +0 -35
  172. data/spec/configuration/notifier/base_spec.rb +0 -32
  173. data/spec/configuration/notifier/campfire_spec.rb +0 -32
  174. data/spec/configuration/notifier/hipchat_spec.rb +0 -44
  175. data/spec/configuration/notifier/mail_spec.rb +0 -71
  176. data/spec/configuration/notifier/presently_spec.rb +0 -35
  177. data/spec/configuration/notifier/prowl_spec.rb +0 -29
  178. data/spec/configuration/notifier/twitter_spec.rb +0 -35
  179. data/spec/configuration/storage/cloudfiles_spec.rb +0 -41
  180. data/spec/configuration/storage/dropbox_spec.rb +0 -38
  181. data/spec/configuration/storage/ftp_spec.rb +0 -44
  182. data/spec/configuration/storage/local_spec.rb +0 -29
  183. data/spec/configuration/storage/ninefold_spec.rb +0 -32
  184. data/spec/configuration/storage/rsync_spec.rb +0 -41
  185. data/spec/configuration/storage/s3_spec.rb +0 -38
  186. data/spec/configuration/storage/scp_spec.rb +0 -41
  187. data/spec/configuration/storage/sftp_spec.rb +0 -41
  188. data/spec/configuration/syncer/cloud_files_spec.rb +0 -44
  189. data/spec/configuration/syncer/rsync/base_spec.rb +0 -33
  190. data/spec/configuration/syncer/rsync/local_spec.rb +0 -10
  191. data/spec/configuration/syncer/rsync/pull_spec.rb +0 -10
  192. data/spec/configuration/syncer/rsync/push_spec.rb +0 -43
  193. data/spec/configuration/syncer/s3_spec.rb +0 -38
  194. data/spec/notifier/presently_spec.rb +0 -181
  195. data/spec/syncer/cloud_files_spec.rb +0 -192
  196. data/spec/syncer/s3_spec.rb +0 -192
  197. data/templates/cli/utility/notifier/presently +0 -13
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Storage::Local do
6
- before do
7
- Backup::Configuration::Storage::Local.defaults do |local|
8
- local.path = 'my_backups'
9
- local.keep = 20
10
- end
11
- end
12
- after { Backup::Configuration::Storage::Local.clear_defaults! }
13
-
14
- it 'should set the default local configuration' do
15
- local = Backup::Configuration::Storage::Local
16
- local.path.should == 'my_backups'
17
- local.keep.should == 20
18
- end
19
-
20
- describe '#clear_defaults!' do
21
- it 'should clear all the defaults, resetting them to nil' do
22
- Backup::Configuration::Storage::Local.clear_defaults!
23
-
24
- local = Backup::Configuration::Storage::Local
25
- local.path.should == nil
26
- local.keep.should == nil
27
- end
28
- end
29
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Storage::Ninefold do
6
- before do
7
- Backup::Configuration::Storage::Ninefold.defaults do |nf|
8
- nf.storage_token = 'my_storage_token'
9
- nf.storage_secret = 'my_storage_secret'
10
- nf.path = 'my_backups'
11
- end
12
- end
13
- after { Backup::Configuration::Storage::Ninefold.clear_defaults! }
14
-
15
- it 'should set the default Ninefold configuration' do
16
- ninefold = Backup::Configuration::Storage::Ninefold
17
- ninefold.storage_token.should == 'my_storage_token'
18
- ninefold.storage_secret.should == 'my_storage_secret'
19
- ninefold.path.should == 'my_backups'
20
- end
21
-
22
- describe '#clear_defaults!' do
23
- it 'should clear all the defaults, resetting them to nil' do
24
- Backup::Configuration::Storage::Ninefold.clear_defaults!
25
-
26
- ninefold = Backup::Configuration::Storage::Ninefold
27
- ninefold.storage_token.should == nil
28
- ninefold.storage_secret.should == nil
29
- ninefold.path.should == nil
30
- end
31
- end
32
- end
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Storage::RSync do
6
- before do
7
- Backup::Configuration::Storage::RSync.defaults do |rsync|
8
- rsync.username = 'my_username'
9
- rsync.password = 'my_password'
10
- rsync.ip = '123.45.678.90'
11
- rsync.port = 21
12
- rsync.path = 'my_backups'
13
- rsync.local = true
14
- end
15
- end
16
- after { Backup::Configuration::Storage::RSync.clear_defaults! }
17
-
18
- it 'should set the default rsync configuration' do
19
- rsync = Backup::Configuration::Storage::RSync
20
- rsync.username.should == 'my_username'
21
- rsync.password.should == 'my_password'
22
- rsync.ip.should == '123.45.678.90'
23
- rsync.port.should == 21
24
- rsync.path.should == 'my_backups'
25
- rsync.local.should == true
26
- end
27
-
28
- describe '#clear_defaults!' do
29
- it 'should clear all the defaults, resetting them to nil' do
30
- Backup::Configuration::Storage::RSync.clear_defaults!
31
-
32
- rsync = Backup::Configuration::Storage::RSync
33
- rsync.username.should == nil
34
- rsync.password.should == nil
35
- rsync.ip.should == nil
36
- rsync.port.should == nil
37
- rsync.path.should == nil
38
- rsync.local.should == nil
39
- end
40
- end
41
- end
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Storage::S3 do
6
- before do
7
- Backup::Configuration::Storage::S3.defaults do |s3|
8
- s3.access_key_id = 'my_access_key_id'
9
- s3.secret_access_key = 'my_secret_access_key'
10
- s3.region = 'us-east-1'
11
- s3.bucket = 'my-bucket'
12
- s3.path = 'my_backups'
13
- end
14
- end
15
- after { Backup::Configuration::Storage::S3.clear_defaults! }
16
-
17
- it 'should set the default S3 configuration' do
18
- s3 = Backup::Configuration::Storage::S3
19
- s3.access_key_id.should == 'my_access_key_id'
20
- s3.secret_access_key.should == 'my_secret_access_key'
21
- s3.region.should == 'us-east-1'
22
- s3.bucket.should == 'my-bucket'
23
- s3.path.should == 'my_backups'
24
- end
25
-
26
- describe '#clear_defaults!' do
27
- it 'should clear all the defaults, resetting them to nil' do
28
- Backup::Configuration::Storage::S3.clear_defaults!
29
-
30
- s3 = Backup::Configuration::Storage::S3
31
- s3.access_key_id.should == nil
32
- s3.secret_access_key.should == nil
33
- s3.region.should == nil
34
- s3.bucket.should == nil
35
- s3.path.should == nil
36
- end
37
- end
38
- end
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Storage::SCP do
6
- before do
7
- Backup::Configuration::Storage::SCP.defaults do |scp|
8
- scp.username = 'my_username'
9
- scp.password = 'my_password'
10
- scp.ip = '123.45.678.90'
11
- scp.port = 21
12
- scp.path = 'my_backups'
13
- scp.keep = 20
14
- end
15
- end
16
- after { Backup::Configuration::Storage::SCP.clear_defaults! }
17
-
18
- it 'should set the default scp configuration' do
19
- scp = Backup::Configuration::Storage::SCP
20
- scp.username.should == 'my_username'
21
- scp.password.should == 'my_password'
22
- scp.ip.should == '123.45.678.90'
23
- scp.port.should == 21
24
- scp.path.should == 'my_backups'
25
- scp.keep.should == 20
26
- end
27
-
28
- describe '#clear_defaults!' do
29
- it 'should clear all the defaults, resetting them to nil' do
30
- Backup::Configuration::Storage::SCP.clear_defaults!
31
-
32
- scp = Backup::Configuration::Storage::SCP
33
- scp.username.should == nil
34
- scp.password.should == nil
35
- scp.ip.should == nil
36
- scp.port.should == nil
37
- scp.path.should == nil
38
- scp.keep.should == nil
39
- end
40
- end
41
- end
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Storage::SFTP do
6
- before do
7
- Backup::Configuration::Storage::SFTP.defaults do |sftp|
8
- sftp.username = 'my_username'
9
- sftp.password = 'my_password'
10
- sftp.ip = '123.45.678.90'
11
- sftp.port = 22
12
- sftp.path = 'my_backups'
13
- sftp.keep = 20
14
- end
15
- end
16
- after { Backup::Configuration::Storage::SFTP.clear_defaults! }
17
-
18
- it 'should set the default sftp configuration' do
19
- sftp = Backup::Configuration::Storage::SFTP
20
- sftp.username.should == 'my_username'
21
- sftp.password.should == 'my_password'
22
- sftp.ip.should == '123.45.678.90'
23
- sftp.port.should == 22
24
- sftp.path.should == 'my_backups'
25
- sftp.keep.should == 20
26
- end
27
-
28
- describe '#clear_defaults!' do
29
- it 'should clear all the defaults, resetting them to nil' do
30
- Backup::Configuration::Storage::SFTP.clear_defaults!
31
-
32
- sftp = Backup::Configuration::Storage::SFTP
33
- sftp.username.should == nil
34
- sftp.password.should == nil
35
- sftp.ip.should == nil
36
- sftp.port.should == nil
37
- sftp.path.should == nil
38
- sftp.keep.should == nil
39
- end
40
- end
41
- end
@@ -1,44 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Syncer::CloudFiles do
6
- before do
7
- Backup::Configuration::Syncer::CloudFiles.defaults do |cf|
8
- cf.username = 'my-username'
9
- cf.api_key = 'my-api-key'
10
- cf.container = 'my-container'
11
- cf.auth_url = 'my-auth-url'
12
- cf.servicenet = true
13
- cf.path = '/backups/'
14
- cf.mirror = true
15
- end
16
- end
17
- after { Backup::Configuration::Syncer::CloudFiles.clear_defaults! }
18
-
19
- it 'should set the default cloud files configuration' do
20
- cf = Backup::Configuration::Syncer::CloudFiles
21
- cf.username.should == 'my-username'
22
- cf.api_key.should == 'my-api-key'
23
- cf.container.should == 'my-container'
24
- cf.auth_url.should == 'my-auth-url'
25
- cf.servicenet.should == true
26
- cf.path.should == '/backups/'
27
- cf.mirror.should == true
28
- end
29
-
30
- describe '#clear_defaults!' do
31
- it 'should clear all the defaults, resetting them to nil' do
32
- Backup::Configuration::Syncer::CloudFiles.clear_defaults!
33
-
34
- cf = Backup::Configuration::Syncer::CloudFiles
35
- cf.username.should == nil
36
- cf.api_key.should == nil
37
- cf.container.should == nil
38
- cf.auth_url.should == nil
39
- cf.servicenet.should == nil
40
- cf.path.should == nil
41
- cf.mirror.should == nil
42
- end
43
- end
44
- end
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Syncer::RSync::Base do
6
- before do
7
- Backup::Configuration::Syncer::RSync::Base.defaults do |rsync|
8
- #rsync.directories = 'cannot_have_a_default_value'
9
- rsync.path = '~/backups/'
10
- rsync.mirror = true
11
- rsync.additional_options = []
12
- end
13
- end
14
- after { Backup::Configuration::Syncer::RSync::Base.clear_defaults! }
15
-
16
- it 'should set the default rsync configuration' do
17
- rsync = Backup::Configuration::Syncer::RSync::Base
18
- rsync.path.should == '~/backups/'
19
- rsync.mirror.should == true
20
- rsync.additional_options.should == []
21
- end
22
-
23
- describe '#clear_defaults!' do
24
- it 'should clear all the defaults, resetting them to nil' do
25
- Backup::Configuration::Syncer::RSync::Base.clear_defaults!
26
-
27
- rsync = Backup::Configuration::Syncer::RSync::Base
28
- rsync.path.should == nil
29
- rsync.mirror.should == nil
30
- rsync.additional_options.should == nil
31
- end
32
- end
33
- end
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Syncer::RSync::Local do
6
- it 'should be a subclass of RSync::Base' do
7
- rsync = Backup::Configuration::Syncer::RSync::Local
8
- rsync.superclass.should == Backup::Configuration::Syncer::RSync::Base
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Syncer::RSync::Pull do
6
- it 'should be a subclass of RSync::Push' do
7
- rsync = Backup::Configuration::Syncer::RSync::Pull
8
- rsync.superclass.should == Backup::Configuration::Syncer::RSync::Push
9
- end
10
- end
@@ -1,43 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Syncer::RSync::Push do
6
- before do
7
- Backup::Configuration::Syncer::RSync::Push.defaults do |rsync|
8
- rsync.username = 'my_username'
9
- rsync.password = 'my_password'
10
- rsync.ip = '123.45.678.90'
11
- rsync.port = 22
12
- rsync.compress = true
13
- end
14
- end
15
- after { Backup::Configuration::Syncer::RSync::Push.clear_defaults! }
16
-
17
- it 'should be a subclass of RSync::Base' do
18
- rsync = Backup::Configuration::Syncer::RSync::Push
19
- rsync.superclass.should == Backup::Configuration::Syncer::RSync::Base
20
- end
21
-
22
- it 'should set the default rsync configuration' do
23
- rsync = Backup::Configuration::Syncer::RSync::Push
24
- rsync.username.should == 'my_username'
25
- rsync.password.should == 'my_password'
26
- rsync.ip.should == '123.45.678.90'
27
- rsync.port.should == 22
28
- rsync.compress.should == true
29
- end
30
-
31
- describe '#clear_defaults!' do
32
- it 'should clear all the defaults, resetting them to nil' do
33
- Backup::Configuration::Syncer::RSync::Push.clear_defaults!
34
-
35
- rsync = Backup::Configuration::Syncer::RSync::Push
36
- rsync.username.should == nil
37
- rsync.password.should == nil
38
- rsync.ip.should == nil
39
- rsync.port.should == nil
40
- rsync.compress.should == nil
41
- end
42
- end
43
- end
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Configuration::Syncer::S3 do
6
- before do
7
- Backup::Configuration::Syncer::S3.defaults do |s3|
8
- s3.access_key_id = 'my_access_key_id'
9
- s3.secret_access_key = 'my_secret_access_key'
10
- s3.bucket = 'my-bucket'
11
- s3.path = '/backups/'
12
- s3.mirror = true
13
- end
14
- end
15
- after { Backup::Configuration::Syncer::S3.clear_defaults! }
16
-
17
- it 'should set the default s3 configuration' do
18
- s3 = Backup::Configuration::Syncer::S3
19
- s3.access_key_id.should == 'my_access_key_id'
20
- s3.secret_access_key.should == 'my_secret_access_key'
21
- s3.bucket.should == 'my-bucket'
22
- s3.path.should == '/backups/'
23
- s3.mirror.should == true
24
- end
25
-
26
- describe '#clear_defaults!' do
27
- it 'should clear all the defaults, resetting them to nil' do
28
- Backup::Configuration::Syncer::S3.clear_defaults!
29
-
30
- s3 = Backup::Configuration::Syncer::S3
31
- s3.access_key_id.should == nil
32
- s3.secret_access_key.should == nil
33
- s3.bucket.should == nil
34
- s3.path.should == nil
35
- s3.mirror.should == nil
36
- end
37
- end
38
- end
@@ -1,181 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../spec_helper.rb', __FILE__)
4
-
5
- describe Backup::Notifier::Presently do
6
- let(:model) { Backup::Model.new(:test_trigger, 'test label') }
7
- let(:notifier) do
8
- Backup::Notifier::Presently.new(model) do |presently|
9
- presently.user_name = 'user_name'
10
- presently.subdomain = 'subdomain'
11
- presently.password = 'password'
12
- presently.group_id = 'group_id'
13
- end
14
- end
15
-
16
- describe '#initialize' do
17
- it 'should sets the correct values' do
18
- notifier.user_name.should == 'user_name'
19
- notifier.subdomain.should == 'subdomain'
20
- notifier.password.should == 'password'
21
- notifier.group_id.should == 'group_id'
22
-
23
- notifier.on_success.should == true
24
- notifier.on_warning.should == true
25
- notifier.on_failure.should == true
26
- end
27
-
28
- context 'when using configuration defaults' do
29
- after { Backup::Configuration::Notifier::Presently.clear_defaults! }
30
-
31
- it 'should use the configuration defaults' do
32
- Backup::Configuration::Notifier::Presently.defaults do |presently|
33
- presently.user_name = 'some_user_name'
34
- presently.subdomain = 'some_subdomain'
35
- presently.password = 'some_password'
36
- presently.group_id = 'some_group_id'
37
-
38
- presently.on_success = false
39
- presently.on_warning = false
40
- presently.on_failure = false
41
- end
42
- notifier = Backup::Notifier::Presently.new(model)
43
- notifier.user_name.should == 'some_user_name'
44
- notifier.subdomain.should == 'some_subdomain'
45
- notifier.password.should == 'some_password'
46
- notifier.group_id.should == 'some_group_id'
47
-
48
- notifier.on_success.should == false
49
- notifier.on_warning.should == false
50
- notifier.on_failure.should == false
51
- end
52
-
53
- it 'should override the configuration defaults' do
54
- Backup::Configuration::Notifier::Presently.defaults do |presently|
55
- presently.user_name = 'old_user_name'
56
- presently.subdomain = 'old_subdomain'
57
- presently.password = 'old_password'
58
- presently.group_id = 'old_group_id'
59
-
60
- presently.on_success = true
61
- presently.on_warning = false
62
- presently.on_failure = false
63
- end
64
- notifier = Backup::Notifier::Presently.new(model) do |presently|
65
- presently.user_name = 'new_user_name'
66
- presently.subdomain = 'new_subdomain'
67
- presently.password = 'new_password'
68
- presently.group_id = 'new_group_id'
69
-
70
- presently.on_success = false
71
- presently.on_warning = true
72
- presently.on_failure = true
73
- end
74
-
75
- notifier.user_name.should == 'new_user_name'
76
- notifier.subdomain.should == 'new_subdomain'
77
- notifier.password.should == 'new_password'
78
- notifier.group_id.should == 'new_group_id'
79
-
80
- notifier.on_success.should == false
81
- notifier.on_warning.should == true
82
- notifier.on_failure.should == true
83
- end
84
- end # context 'when using configuration defaults'
85
- end
86
-
87
- describe '#notify!' do
88
- context 'when status is :success' do
89
- it 'should send Success message' do
90
- notifier.expects(:send_message).with(
91
- '[Backup::Success] test label (test_trigger)'
92
- )
93
- notifier.send(:notify!, :success)
94
- end
95
- end
96
-
97
- context 'when status is :warning' do
98
- it 'should send Warning message' do
99
- notifier.expects(:send_message).with(
100
- '[Backup::Warning] test label (test_trigger)'
101
- )
102
- notifier.send(:notify!, :warning)
103
- end
104
- end
105
-
106
- context 'when status is :failure' do
107
- it 'should send Failure message' do
108
- notifier.expects(:send_message).with(
109
- '[Backup::Failure] test label (test_trigger)'
110
- )
111
- notifier.send(:notify!, :failure)
112
- end
113
- end
114
- end # describe '#notify!'
115
-
116
- describe '#send_message' do
117
- it 'should send a message' do
118
- client = mock
119
- Backup::Notifier::Presently::Client.expects(:new).
120
- with('subdomain', 'user_name', 'password', 'group_id').
121
- returns(client)
122
- client.expects(:update).with('a message')
123
-
124
- notifier.send(:send_message, 'a message')
125
- end
126
- end
127
- end
128
-
129
- describe Backup::Notifier::Presently::Client do
130
- let(:client) do
131
- Backup::Notifier::Presently::Client.new(
132
- 'subdomain', 'user_name', 'password', 'group_id'
133
- )
134
- end
135
-
136
- it 'should include HTTParty' do
137
- Backup::Notifier::Presently::Client.
138
- included_modules.should include(HTTParty)
139
- end
140
-
141
- it 'should setup the proper values' do
142
- client.subdomain.should == 'subdomain'
143
- client.user_name.should == 'user_name'
144
- client.password.should == 'password'
145
- client.group_id.should == 'group_id'
146
-
147
- Backup::Notifier::Presently::Client.base_uri.
148
- should == 'https://subdomain.presently.com'
149
- Backup::Notifier::Presently::Client.default_options[:basic_auth].
150
- should == {:username => 'user_name', :password => 'password' }
151
- end
152
-
153
- describe '#update' do
154
- context 'when a group_id is specified' do
155
- it 'should post the given message with the specified group' do
156
- Backup::Notifier::Presently::Client.expects(:post).with(
157
- '/api/twitter/statuses/update.json',
158
- :body => {
159
- :status => 'd @group_id a message',
160
- :source => 'Backup Notifier'
161
- }
162
- )
163
- client.update('a message')
164
- end
165
- end
166
-
167
- context 'when no group_id is specified' do
168
- before { client.group_id = nil }
169
- it 'should just post the given message' do
170
- Backup::Notifier::Presently::Client.expects(:post).with(
171
- '/api/twitter/statuses/update.json',
172
- :body => {
173
- :status => 'a message',
174
- :source => 'Backup Notifier'
175
- }
176
- )
177
- client.update('a message')
178
- end
179
- end
180
- end
181
- end