backup 3.0.23 → 3.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -5,33 +5,53 @@ require File.expand_path('../../spec_helper.rb', __FILE__)
5
5
  describe Backup::Storage::Base do
6
6
  let(:model) { Backup::Model.new(:test_trigger, 'test label') }
7
7
  let(:package) { mock }
8
- let(:base) { Backup::Storage::Base.new(model) }
8
+ let(:storage) { Backup::Storage::Base.new(model) }
9
+
10
+ it 'should include Configuration::Helpers' do
11
+ Backup::Storage::Base.
12
+ include?(Backup::Configuration::Helpers).should be_true
13
+ end
9
14
 
10
15
  describe '#initialize' do
11
- it 'should set instance variables' do
12
- base.instance_variable_get(:@model).should be(model)
13
- base.instance_variable_defined?(:@storage_id).should be_true
14
- base.instance_variable_get(:@storage_id).should be_nil
15
- base.keep.should be_nil
16
+ after { Backup::Storage::Base.clear_defaults! }
17
+
18
+ it 'should load pre-configured defaults' do
19
+ Backup::Storage::Base.any_instance.expects(:load_defaults!)
20
+ storage
16
21
  end
17
22
 
18
- context 'when given a storage_id' do
19
- it 'should set @storage_id' do
20
- base = Backup::Storage::Base.new(model, 'my storage id')
21
- base.instance_variable_get(:@storage_id).should == 'my storage id'
22
- end
23
+ it 'should set a reference to the model' do
24
+ storage.instance_variable_get(:@model).should == model
25
+ end
26
+
27
+ it 'should set a reference to the storage_id' do
28
+ storage = Backup::Storage::Base.new(model, 'test_id')
29
+ storage.storage_id.should == 'test_id'
23
30
  end
24
31
 
25
- context 'when configuration defaults are set' do
26
- after { Backup::Configuration::Storage::Base.clear_defaults! }
27
- it 'should use the defaults' do
28
- Backup::Configuration::Storage::Base.defaults do |base|
29
- base.keep = 5
32
+ it 'should not require the storage_id' do
33
+ storage.instance_variable_defined?(:@storage_id).should be_true
34
+ storage.storage_id.should be_nil
35
+ end
36
+
37
+ context 'when no pre-configured defaults have been set' do
38
+ it 'should set default values' do
39
+ storage.keep.should be_nil
40
+ storage.storage_id.should be_nil
41
+ end
42
+ end # context 'when no pre-configured defaults have been set'
43
+
44
+ context 'when pre-configured defaults have been set' do
45
+ before do
46
+ Backup::Storage::Base.defaults do |s|
47
+ s.keep = 5
30
48
  end
31
- base = Backup::Storage::Base.new(model)
32
- base.keep.should be(5)
33
49
  end
34
- end
50
+
51
+ it 'should use pre-configured defaults' do
52
+ storage.keep.should be(5)
53
+ end
54
+ end # context 'when pre-configured defaults have been set'
35
55
  end # describe '#initialize'
36
56
 
37
57
  describe '#perform!' do
@@ -41,31 +61,31 @@ describe Backup::Storage::Base do
41
61
 
42
62
  it 'should call #transfer!, then #cycle!' do
43
63
  s = sequence ''
44
- base.expects(:transfer!).in_sequence(s)
45
- base.expects(:cycle!).in_sequence(s)
46
- base.perform!
47
- base.instance_variable_get(:@package).should be(package)
64
+ storage.expects(:transfer!).in_sequence(s)
65
+ storage.expects(:cycle!).in_sequence(s)
66
+ storage.perform!
67
+ storage.instance_variable_get(:@package).should be(package)
48
68
  end
49
69
  end
50
70
 
51
71
  describe '#storage_name' do
52
72
  context 'when given a storage_id' do
53
- before { base.storage_id = 'storage id' }
73
+ before { storage.storage_id = 'storage id' }
54
74
  it 'should return a log-friendly name with the storage_id' do
55
- base.send(:storage_name).should == 'Storage::Base (storage id)'
75
+ storage.send(:storage_name).should == 'Storage::Base (storage id)'
56
76
  end
57
77
  end
58
78
 
59
79
  context 'when not given a storage_id' do
60
80
  it 'should return a log-friendly name without a storage_id' do
61
- base.send(:storage_name).should == 'Storage::Base'
81
+ storage.send(:storage_name).should == 'Storage::Base'
62
82
  end
63
83
  end
64
84
  end
65
85
 
66
86
  describe '#local_path' do
67
87
  it 'should return the configured tmp_path' do
68
- base.send(:local_path).should == Backup::Config.tmp_path
88
+ storage.send(:local_path).should == Backup::Config.tmp_path
69
89
  end
70
90
  end
71
91
 
@@ -73,11 +93,11 @@ describe Backup::Storage::Base do
73
93
  before do
74
94
  package.expects(:trigger).returns('test_trigger')
75
95
  package.expects(:time).returns('backup_time')
76
- base.expects(:path).returns('base/remote/path')
96
+ storage.expects(:path).returns('base/remote/path')
77
97
  end
78
98
 
79
99
  it 'should return the remote_path for the given package' do
80
- base.send(:remote_path_for, package).should ==
100
+ storage.send(:remote_path_for, package).should ==
81
101
  File.join('base/remote/path', 'test_trigger', 'backup_time')
82
102
  end
83
103
  end
@@ -98,47 +118,47 @@ describe Backup::Storage::Base do
98
118
  given_block.expects(:got).with(
99
119
  '2011.12.31.11.00.02.backup.tar.enc-ab', 'backup.tar.enc-ab'
100
120
  )
101
- base.send(:files_to_transfer_for, package) do |local_file, remote_file|
121
+ storage.send(:files_to_transfer_for, package) do |local_file, remote_file|
102
122
  given_block.got(local_file, remote_file)
103
123
  end
104
124
  end
105
125
 
106
126
  it 'should have an alias method called #transferred_files_for' do
107
- base.method(:transferred_files_for).should ==
108
- base.method(:files_to_transfer_for)
127
+ storage.method(:transferred_files_for).should ==
128
+ storage.method(:files_to_transfer_for)
109
129
  end
110
130
  end
111
131
 
112
132
  describe '#cycle!' do
113
133
  before do
114
- base.stubs(:storage_name).returns('Storage Name')
115
- base.instance_variable_set(:@package, package)
134
+ storage.stubs(:storage_name).returns('Storage Name')
135
+ storage.instance_variable_set(:@package, package)
116
136
  end
117
137
 
118
138
  context 'when keep is set and > 0' do
119
- before { base.keep = 1 }
139
+ before { storage.keep = 1 }
120
140
  it 'should cycle' do
121
141
  s = sequence ''
122
142
  Backup::Logger.expects(:message).in_sequence(s).
123
143
  with('Storage Name: Cycling Started...')
124
144
  Backup::Storage::Cycler.expects(:cycle!).in_sequence(s).
125
- with(base, package)
145
+ with(storage, package)
126
146
  Backup::Logger.expects(:message).in_sequence(s).
127
147
  with('Storage Name: Cycling Complete!')
128
148
 
129
- base.send(:cycle!)
149
+ storage.send(:cycle!)
130
150
  end
131
151
  end
132
152
 
133
153
  context 'when keep is not set or == 0' do
134
154
  it 'should return nil when not set' do
135
- base.keep = nil
136
- base.send(:cycle!).should be_nil
155
+ storage.keep = nil
156
+ storage.send(:cycle!).should be_nil
137
157
  end
138
158
 
139
159
  it 'should return nil when == 0' do
140
- base.keep = 0
141
- base.send(:cycle!).should be_nil
160
+ storage.keep = 0
161
+ storage.send(:cycle!).should be_nil
142
162
  end
143
163
  end
144
164
  end
@@ -14,38 +14,72 @@ describe Backup::Storage::CloudFiles do
14
14
  end
15
15
  end
16
16
 
17
+ it 'should be a subclass of Storage::Base' do
18
+ Backup::Storage::CloudFiles.
19
+ superclass.should == Backup::Storage::Base
20
+ end
21
+
17
22
  describe '#initialize' do
18
- it 'should set the correct values' do
19
- storage.username.should == 'my_username'
20
- storage.api_key.should == 'my_api_key'
21
- storage.auth_url.should == 'lon.auth.api.rackspacecloud.com'
22
- storage.container.should == 'my_container'
23
- storage.servicenet.should == false
24
- storage.path.should == 'backups'
25
-
26
- storage.storage_id.should be_nil
27
- storage.keep.should == 5
23
+ after { Backup::Storage::CloudFiles.clear_defaults! }
24
+
25
+ it 'should load pre-configured defaults through Base' do
26
+ Backup::Storage::CloudFiles.any_instance.expects(:load_defaults!)
27
+ storage
28
28
  end
29
29
 
30
- it 'should set a storage_id if given' do
31
- cf = Backup::Storage::CloudFiles.new(model, 'my storage_id')
32
- cf.storage_id.should == 'my storage_id'
30
+ it 'should pass the model reference to Base' do
31
+ storage.instance_variable_get(:@model).should == model
33
32
  end
34
33
 
35
- context 'when setting configuration defaults' do
36
- after { Backup::Configuration::Storage::CloudFiles.clear_defaults! }
37
-
38
- it 'should use the configured defaults' do
39
- Backup::Configuration::Storage::CloudFiles.defaults do |cf|
40
- cf.username = 'some_username'
41
- cf.api_key = 'some_api_key'
42
- cf.auth_url = 'some_auth_url'
43
- cf.container = 'some_container'
44
- cf.servicenet = true
45
- cf.path = 'some_path'
46
- cf.keep = 15
34
+ it 'should pass the storage_id to Base' do
35
+ storage = Backup::Storage::CloudFiles.new(model, 'my_storage_id')
36
+ storage.storage_id.should == 'my_storage_id'
37
+ end
38
+
39
+ context 'when no pre-configured defaults have been set' do
40
+ it 'should use the values given' do
41
+ storage.username.should == 'my_username'
42
+ storage.api_key.should == 'my_api_key'
43
+ storage.auth_url.should == 'lon.auth.api.rackspacecloud.com'
44
+ storage.container.should == 'my_container'
45
+ storage.servicenet.should == false
46
+ storage.path.should == 'backups'
47
+
48
+ storage.storage_id.should be_nil
49
+ storage.keep.should == 5
50
+ end
51
+
52
+ it 'should use default values if none are given' do
53
+ storage = Backup::Storage::CloudFiles.new(model)
54
+
55
+ storage.username.should be_nil
56
+ storage.api_key.should be_nil
57
+ storage.auth_url.should be_nil
58
+ storage.container.should be_nil
59
+ storage.servicenet.should == false
60
+ storage.path.should == 'backups'
61
+
62
+ storage.storage_id.should be_nil
63
+ storage.keep.should be_nil
64
+ end
65
+ end # context 'when no pre-configured defaults have been set'
66
+
67
+ context 'when pre-configured defaults have been set' do
68
+ before do
69
+ Backup::Storage::CloudFiles.defaults do |s|
70
+ s.username = 'some_username'
71
+ s.api_key = 'some_api_key'
72
+ s.auth_url = 'some_auth_url'
73
+ s.container = 'some_container'
74
+ s.servicenet = true
75
+ s.path = 'some_path'
76
+ s.keep = 15
47
77
  end
78
+ end
79
+
80
+ it 'should use pre-configured defaults' do
48
81
  storage = Backup::Storage::CloudFiles.new(model)
82
+
49
83
  storage.username.should == 'some_username'
50
84
  storage.api_key.should == 'some_api_key'
51
85
  storage.auth_url.should == 'some_auth_url'
@@ -57,24 +91,15 @@ describe Backup::Storage::CloudFiles do
57
91
  storage.keep.should == 15
58
92
  end
59
93
 
60
- it 'should override the configured defaults' do
61
- Backup::Configuration::Storage::CloudFiles.defaults do |cf|
62
- cf.username = 'old_username'
63
- cf.api_key = 'old_api_key'
64
- cf.auth_url = 'old_auth_url'
65
- cf.container = 'old_container'
66
- cf.servicenet = true
67
- cf.path = 'old_path'
68
- cf.keep = 15
69
- end
70
- storage = Backup::Storage::CloudFiles.new(model) do |cf|
71
- cf.username = 'new_username'
72
- cf.api_key = 'new_api_key'
73
- cf.auth_url = 'new_auth_url'
74
- cf.container = 'new_container'
75
- cf.servicenet = false
76
- cf.path = 'new_path'
77
- cf.keep = 10
94
+ it 'should override pre-configured defaults' do
95
+ storage = Backup::Storage::CloudFiles.new(model) do |s|
96
+ s.username = 'new_username'
97
+ s.api_key = 'new_api_key'
98
+ s.auth_url = 'new_auth_url'
99
+ s.container = 'new_container'
100
+ s.servicenet = false
101
+ s.path = 'new_path'
102
+ s.keep = 10
78
103
  end
79
104
 
80
105
  storage.username.should == 'new_username'
@@ -87,8 +112,7 @@ describe Backup::Storage::CloudFiles do
87
112
  storage.storage_id.should be_nil
88
113
  storage.keep.should == 10
89
114
  end
90
- end # context 'when setting configuration defaults'
91
-
115
+ end # context 'when pre-configured defaults have been set'
92
116
  end # describe '#initialize'
93
117
 
94
118
  describe '#provider' do
@@ -12,34 +12,65 @@ describe Backup::Storage::Dropbox do
12
12
  end
13
13
  end
14
14
 
15
+ it 'should be a subclass of Storage::Base' do
16
+ Backup::Storage::Dropbox.
17
+ superclass.should == Backup::Storage::Base
18
+ end
19
+
15
20
  describe '#initialize' do
16
- it 'should set the correct values' do
17
- storage.api_key.should == 'my_api_key'
18
- storage.api_secret.should == 'my_api_secret'
19
- storage.access_type.should == :app_folder
20
- storage.path.should == 'backups'
21
-
22
- storage.storage_id.should be_nil
23
- storage.keep.should == 5
21
+ after { Backup::Storage::Dropbox.clear_defaults! }
22
+
23
+ it 'should load pre-configured defaults through Base' do
24
+ Backup::Storage::Dropbox.any_instance.expects(:load_defaults!)
25
+ storage
26
+ end
27
+
28
+ it 'should pass the model reference to Base' do
29
+ storage.instance_variable_get(:@model).should == model
24
30
  end
25
31
 
26
- it 'should set a storage_id if given' do
27
- db = Backup::Storage::Dropbox.new(model, 'my storage_id')
28
- db.storage_id.should == 'my storage_id'
32
+ it 'should pass the storage_id to Base' do
33
+ storage = Backup::Storage::Dropbox.new(model, 'my_storage_id')
34
+ storage.storage_id.should == 'my_storage_id'
29
35
  end
30
36
 
31
- context 'when setting configuration defaults' do
32
- after { Backup::Configuration::Storage::Dropbox.clear_defaults! }
37
+ context 'when no pre-configured defaults have been set' do
38
+ it 'should use the values given' do
39
+ storage.api_key.should == 'my_api_key'
40
+ storage.api_secret.should == 'my_api_secret'
41
+ storage.access_type.should == :app_folder
42
+ storage.path.should == 'backups'
33
43
 
34
- it 'should use the configured defaults' do
35
- Backup::Configuration::Storage::Dropbox.defaults do |db|
36
- db.api_key = 'some_api_key'
37
- db.api_secret = 'some_api_secret'
38
- db.access_type = 'some_access_type'
39
- db.path = 'some_path'
40
- db.keep = 15
44
+ storage.storage_id.should be_nil
45
+ storage.keep.should == 5
46
+ end
47
+
48
+ it 'should use default values if none are given' do
49
+ storage = Backup::Storage::Dropbox.new(model)
50
+ storage.api_key.should be_nil
51
+ storage.api_secret.should be_nil
52
+ storage.access_type.should == :app_folder
53
+ storage.path.should == 'backups'
54
+
55
+ storage.storage_id.should be_nil
56
+ storage.keep.should be_nil
57
+ end
58
+ end # context 'when no pre-configured defaults have been set'
59
+
60
+ context 'when pre-configured defaults have been set' do
61
+ before do
62
+ Backup::Storage::Dropbox.defaults do |s|
63
+ s.api_key = 'some_api_key'
64
+ s.api_secret = 'some_api_secret'
65
+ s.access_type = 'some_access_type'
66
+ s.path = 'some_path'
67
+ s.keep = 15
41
68
  end
69
+ end
70
+
71
+ it 'should use pre-configured defaults' do
42
72
  storage = Backup::Storage::Dropbox.new(model)
73
+
43
74
  storage.api_key.should == 'some_api_key'
44
75
  storage.api_secret.should == 'some_api_secret'
45
76
  storage.access_type.should == 'some_access_type'
@@ -49,20 +80,13 @@ describe Backup::Storage::Dropbox do
49
80
  storage.keep.should == 15
50
81
  end
51
82
 
52
- it 'should override the configured defaults' do
53
- Backup::Configuration::Storage::Dropbox.defaults do |db|
54
- db.api_key = 'old_api_key'
55
- db.api_secret = 'old_api_secret'
56
- db.access_type = 'old_access_type'
57
- db.path = 'old_path'
58
- db.keep = 15
59
- end
60
- storage = Backup::Storage::Dropbox.new(model) do |db|
61
- db.api_key = 'new_api_key'
62
- db.api_secret = 'new_api_secret'
63
- db.access_type = 'new_access_type'
64
- db.path = 'new_path'
65
- db.keep = 10
83
+ it 'should override pre-configured defaults' do
84
+ storage = Backup::Storage::Dropbox.new(model) do |s|
85
+ s.api_key = 'new_api_key'
86
+ s.api_secret = 'new_api_secret'
87
+ s.access_type = 'new_access_type'
88
+ s.path = 'new_path'
89
+ s.keep = 10
66
90
  end
67
91
 
68
92
  storage.api_key.should == 'new_api_key'
@@ -73,8 +97,7 @@ describe Backup::Storage::Dropbox do
73
97
  storage.storage_id.should be_nil
74
98
  storage.keep.should == 10
75
99
  end
76
- end # context 'when setting configuration defaults'
77
-
100
+ end # context 'when pre-configured defaults have been set'
78
101
  end # describe '#initialize'
79
102
 
80
103
  describe '#connection' do
@@ -367,4 +390,103 @@ describe Backup::Storage::Dropbox do
367
390
  end
368
391
  end
369
392
 
393
+ describe 'deprecations' do
394
+ after do
395
+ Backup::Storage::Dropbox.clear_defaults!
396
+ end
397
+
398
+ describe '#email' do
399
+ context 'when set directly' do
400
+ it 'should issue a deprecation warning' do
401
+ Backup::Logger.expects(:warn).with do |err|
402
+ err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
403
+ " Backup::Storage::Dropbox.email has been deprecated " +
404
+ "as of backup v.3.0.17"
405
+ end
406
+
407
+ Backup::Storage::Dropbox.new(model) do |storage|
408
+ storage.email = 'foo'
409
+ end
410
+ end
411
+ end
412
+
413
+ context 'when set as a default' do
414
+ it 'should issue a deprecation warning' do
415
+ Backup::Logger.expects(:warn).with do |err|
416
+ err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
417
+ " Backup::Storage::Dropbox.email has been deprecated " +
418
+ "as of backup v.3.0.17"
419
+ end
420
+
421
+ Backup::Storage::Dropbox.defaults do |storage|
422
+ storage.email = 'foo'
423
+ end
424
+ Backup::Storage::Dropbox.new(model)
425
+ end
426
+ end
427
+ end
428
+
429
+ describe '#password' do
430
+ context 'when set directly' do
431
+ it 'should issue a deprecation warning' do
432
+ Backup::Logger.expects(:warn).with do |err|
433
+ err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
434
+ " Backup::Storage::Dropbox.password has been deprecated " +
435
+ "as of backup v.3.0.17"
436
+ end
437
+
438
+ Backup::Storage::Dropbox.new(model) do |storage|
439
+ storage.password = 'foo'
440
+ end
441
+ end
442
+ end
443
+
444
+ context 'when set as a default' do
445
+ it 'should issue a deprecation warning' do
446
+ Backup::Logger.expects(:warn).with do |err|
447
+ err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
448
+ " Backup::Storage::Dropbox.password has been deprecated " +
449
+ "as of backup v.3.0.17"
450
+ end
451
+
452
+ Backup::Storage::Dropbox.defaults do |storage|
453
+ storage.password = 'foo'
454
+ end
455
+ Backup::Storage::Dropbox.new(model)
456
+ end
457
+ end
458
+ end
459
+
460
+ describe '#timeout' do
461
+ context 'when set directly' do
462
+ it 'should issue a deprecation warning' do
463
+ Backup::Logger.expects(:warn).with do |err|
464
+ err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
465
+ " Backup::Storage::Dropbox.timeout has been deprecated " +
466
+ "as of backup v.3.0.21"
467
+ end
468
+
469
+ Backup::Storage::Dropbox.new(model) do |storage|
470
+ storage.timeout = 'foo'
471
+ end
472
+ end
473
+ end
474
+
475
+ context 'when set as a default' do
476
+ it 'should issue a deprecation warning' do
477
+ Backup::Logger.expects(:warn).with do |err|
478
+ err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
479
+ " Backup::Storage::Dropbox.timeout has been deprecated " +
480
+ "as of backup v.3.0.21"
481
+ end
482
+
483
+ Backup::Storage::Dropbox.defaults do |storage|
484
+ storage.timeout = 'foo'
485
+ end
486
+ Backup::Storage::Dropbox.new(model)
487
+ end
488
+ end
489
+ end
490
+ end
491
+
370
492
  end