backup 3.0.20 → 3.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/Gemfile +1 -5
  2. data/Gemfile.lock +46 -50
  3. data/README.md +54 -27
  4. data/lib/backup.rb +16 -39
  5. data/lib/backup/archive.rb +42 -18
  6. data/lib/backup/cleaner.rb +110 -25
  7. data/lib/backup/cli/helpers.rb +17 -32
  8. data/lib/backup/cli/utility.rb +46 -107
  9. data/lib/backup/compressor/base.rb +14 -2
  10. data/lib/backup/compressor/bzip2.rb +10 -24
  11. data/lib/backup/compressor/gzip.rb +10 -24
  12. data/lib/backup/compressor/lzma.rb +10 -23
  13. data/lib/backup/compressor/pbzip2.rb +12 -32
  14. data/lib/backup/config.rb +171 -0
  15. data/lib/backup/configuration/compressor/base.rb +1 -2
  16. data/lib/backup/configuration/compressor/pbzip2.rb +4 -4
  17. data/lib/backup/configuration/database/base.rb +2 -1
  18. data/lib/backup/configuration/database/mongodb.rb +8 -0
  19. data/lib/backup/configuration/database/mysql.rb +4 -0
  20. data/lib/backup/configuration/database/postgresql.rb +4 -0
  21. data/lib/backup/configuration/database/redis.rb +4 -0
  22. data/lib/backup/configuration/database/riak.rb +5 -1
  23. data/lib/backup/configuration/encryptor/base.rb +1 -2
  24. data/lib/backup/configuration/encryptor/open_ssl.rb +1 -1
  25. data/lib/backup/configuration/helpers.rb +7 -2
  26. data/lib/backup/configuration/notifier/base.rb +4 -28
  27. data/lib/backup/configuration/storage/base.rb +1 -1
  28. data/lib/backup/configuration/storage/dropbox.rb +14 -4
  29. data/lib/backup/configuration/syncer/base.rb +10 -0
  30. data/lib/backup/configuration/syncer/rsync/base.rb +28 -0
  31. data/lib/backup/configuration/syncer/rsync/local.rb +11 -0
  32. data/lib/backup/configuration/syncer/rsync/pull.rb +11 -0
  33. data/lib/backup/configuration/syncer/rsync/push.rb +31 -0
  34. data/lib/backup/configuration/syncer/s3.rb +0 -4
  35. data/lib/backup/database/base.rb +25 -7
  36. data/lib/backup/database/mongodb.rb +112 -75
  37. data/lib/backup/database/mysql.rb +54 -29
  38. data/lib/backup/database/postgresql.rb +60 -42
  39. data/lib/backup/database/redis.rb +61 -39
  40. data/lib/backup/database/riak.rb +35 -11
  41. data/lib/backup/dependency.rb +4 -5
  42. data/lib/backup/encryptor/base.rb +13 -1
  43. data/lib/backup/encryptor/gpg.rb +39 -39
  44. data/lib/backup/encryptor/open_ssl.rb +28 -38
  45. data/lib/backup/logger.rb +20 -11
  46. data/lib/backup/model.rb +206 -163
  47. data/lib/backup/notifier/base.rb +27 -25
  48. data/lib/backup/notifier/campfire.rb +7 -13
  49. data/lib/backup/notifier/hipchat.rb +28 -28
  50. data/lib/backup/notifier/mail.rb +24 -26
  51. data/lib/backup/notifier/presently.rb +10 -18
  52. data/lib/backup/notifier/prowl.rb +9 -17
  53. data/lib/backup/notifier/twitter.rb +11 -18
  54. data/lib/backup/package.rb +47 -0
  55. data/lib/backup/packager.rb +81 -16
  56. data/lib/backup/splitter.rb +48 -35
  57. data/lib/backup/storage/base.rb +44 -172
  58. data/lib/backup/storage/cloudfiles.rb +31 -46
  59. data/lib/backup/storage/cycler.rb +117 -0
  60. data/lib/backup/storage/dropbox.rb +92 -76
  61. data/lib/backup/storage/ftp.rb +30 -40
  62. data/lib/backup/storage/local.rb +44 -45
  63. data/lib/backup/storage/ninefold.rb +55 -49
  64. data/lib/backup/storage/rsync.rb +49 -56
  65. data/lib/backup/storage/s3.rb +33 -44
  66. data/lib/backup/storage/scp.rb +21 -48
  67. data/lib/backup/storage/sftp.rb +26 -40
  68. data/lib/backup/syncer/base.rb +7 -0
  69. data/lib/backup/syncer/rsync/base.rb +78 -0
  70. data/lib/backup/syncer/rsync/local.rb +53 -0
  71. data/lib/backup/syncer/rsync/pull.rb +38 -0
  72. data/lib/backup/syncer/rsync/push.rb +113 -0
  73. data/lib/backup/syncer/s3.rb +42 -32
  74. data/lib/backup/version.rb +1 -1
  75. data/spec/archive_spec.rb +235 -69
  76. data/spec/cleaner_spec.rb +304 -0
  77. data/spec/cli/helpers_spec.rb +142 -1
  78. data/spec/cli/utility_spec.rb +338 -13
  79. data/spec/compressor/base_spec.rb +31 -0
  80. data/spec/compressor/bzip2_spec.rb +60 -35
  81. data/spec/compressor/gzip_spec.rb +60 -35
  82. data/spec/compressor/lzma_spec.rb +60 -35
  83. data/spec/compressor/pbzip2_spec.rb +98 -37
  84. data/spec/config_spec.rb +321 -0
  85. data/spec/configuration/base_spec.rb +4 -4
  86. data/spec/configuration/compressor/bzip2_spec.rb +1 -0
  87. data/spec/configuration/compressor/gzip_spec.rb +1 -0
  88. data/spec/configuration/compressor/lzma_spec.rb +1 -0
  89. data/spec/configuration/compressor/pbzip2_spec.rb +32 -0
  90. data/spec/configuration/database/base_spec.rb +2 -1
  91. data/spec/configuration/database/mongodb_spec.rb +26 -16
  92. data/spec/configuration/database/mysql_spec.rb +4 -0
  93. data/spec/configuration/database/postgresql_spec.rb +4 -0
  94. data/spec/configuration/database/redis_spec.rb +4 -0
  95. data/spec/configuration/database/riak_spec.rb +4 -0
  96. data/spec/configuration/encryptor/gpg_spec.rb +1 -0
  97. data/spec/configuration/encryptor/open_ssl_spec.rb +1 -0
  98. data/spec/configuration/notifier/base_spec.rb +32 -0
  99. data/spec/configuration/notifier/campfire_spec.rb +1 -0
  100. data/spec/configuration/notifier/hipchat_spec.rb +1 -0
  101. data/spec/configuration/notifier/mail_spec.rb +1 -0
  102. data/spec/configuration/notifier/presently_spec.rb +1 -0
  103. data/spec/configuration/notifier/prowl_spec.rb +1 -0
  104. data/spec/configuration/notifier/twitter_spec.rb +1 -0
  105. data/spec/configuration/storage/cloudfiles_spec.rb +1 -0
  106. data/spec/configuration/storage/dropbox_spec.rb +4 -3
  107. data/spec/configuration/storage/ftp_spec.rb +1 -0
  108. data/spec/configuration/storage/local_spec.rb +1 -0
  109. data/spec/configuration/storage/ninefold_spec.rb +1 -0
  110. data/spec/configuration/storage/rsync_spec.rb +3 -1
  111. data/spec/configuration/storage/s3_spec.rb +1 -0
  112. data/spec/configuration/storage/scp_spec.rb +1 -0
  113. data/spec/configuration/storage/sftp_spec.rb +1 -0
  114. data/spec/configuration/syncer/rsync/base_spec.rb +33 -0
  115. data/spec/configuration/syncer/rsync/local_spec.rb +10 -0
  116. data/spec/configuration/syncer/rsync/pull_spec.rb +10 -0
  117. data/spec/configuration/syncer/{rsync_spec.rb → rsync/push_spec.rb} +12 -15
  118. data/spec/configuration/syncer/s3_spec.rb +2 -3
  119. data/spec/database/base_spec.rb +35 -20
  120. data/spec/database/mongodb_spec.rb +298 -119
  121. data/spec/database/mysql_spec.rb +147 -72
  122. data/spec/database/postgresql_spec.rb +155 -100
  123. data/spec/database/redis_spec.rb +200 -97
  124. data/spec/database/riak_spec.rb +82 -24
  125. data/spec/dependency_spec.rb +49 -0
  126. data/spec/encryptor/base_spec.rb +30 -0
  127. data/spec/encryptor/gpg_spec.rb +105 -28
  128. data/spec/encryptor/open_ssl_spec.rb +85 -114
  129. data/spec/logger_spec.rb +74 -8
  130. data/spec/model_spec.rb +528 -220
  131. data/spec/notifier/base_spec.rb +89 -0
  132. data/spec/notifier/campfire_spec.rb +147 -119
  133. data/spec/notifier/hipchat_spec.rb +140 -145
  134. data/spec/notifier/mail_spec.rb +190 -248
  135. data/spec/notifier/presently_spec.rb +147 -282
  136. data/spec/notifier/prowl_spec.rb +79 -111
  137. data/spec/notifier/twitter_spec.rb +87 -106
  138. data/spec/package_spec.rb +61 -0
  139. data/spec/packager_spec.rb +154 -0
  140. data/spec/spec_helper.rb +36 -13
  141. data/spec/splitter_spec.rb +90 -41
  142. data/spec/storage/base_spec.rb +95 -239
  143. data/spec/storage/cloudfiles_spec.rb +185 -75
  144. data/spec/storage/cycler_spec.rb +239 -0
  145. data/spec/storage/dropbox_spec.rb +318 -87
  146. data/spec/storage/ftp_spec.rb +165 -152
  147. data/spec/storage/local_spec.rb +206 -54
  148. data/spec/storage/ninefold_spec.rb +264 -128
  149. data/spec/storage/rsync_spec.rb +244 -163
  150. data/spec/storage/s3_spec.rb +175 -64
  151. data/spec/storage/scp_spec.rb +156 -150
  152. data/spec/storage/sftp_spec.rb +153 -135
  153. data/spec/syncer/base_spec.rb +22 -0
  154. data/spec/syncer/rsync/base_spec.rb +118 -0
  155. data/spec/syncer/rsync/local_spec.rb +121 -0
  156. data/spec/syncer/rsync/pull_spec.rb +90 -0
  157. data/spec/syncer/rsync/push_spec.rb +327 -0
  158. data/spec/syncer/s3_spec.rb +180 -91
  159. data/templates/cli/utility/config +1 -1
  160. data/templates/cli/utility/database/mongodb +4 -0
  161. data/templates/cli/utility/database/mysql +3 -0
  162. data/templates/cli/utility/database/postgresql +3 -0
  163. data/templates/cli/utility/database/redis +3 -0
  164. data/templates/cli/utility/database/riak +3 -0
  165. data/templates/cli/utility/storage/dropbox +4 -1
  166. data/templates/cli/utility/syncer/rsync_local +12 -0
  167. data/templates/cli/utility/syncer/{rsync → rsync_pull} +2 -2
  168. data/templates/cli/utility/syncer/rsync_push +17 -0
  169. data/templates/storage/dropbox/authorization_url.erb +1 -1
  170. metadata +42 -17
  171. data/lib/backup/configuration/syncer/rsync.rb +0 -45
  172. data/lib/backup/finder.rb +0 -87
  173. data/lib/backup/storage/object.rb +0 -47
  174. data/lib/backup/syncer/rsync.rb +0 -152
  175. data/spec/backup_spec.rb +0 -11
  176. data/spec/finder_spec.rb +0 -91
  177. data/spec/storage/object_spec.rb +0 -74
  178. data/spec/syncer/rsync_spec.rb +0 -195
@@ -3,18 +3,18 @@
3
3
  require File.expand_path('../../spec_helper.rb', __FILE__)
4
4
 
5
5
  describe Backup::Notifier::Presently do
6
-
7
- describe '#initialize' do
8
- let(:notifier) do
9
- Backup::Notifier::Presently.new do |presently|
10
- presently.user_name = 'user_name'
11
- presently.subdomain = 'subdomain'
12
- presently.password = 'password'
13
- presently.group_id = 'group_id'
14
- end
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'
15
13
  end
14
+ end
16
15
 
17
- it 'sets the correct defaults' do
16
+ describe '#initialize' do
17
+ it 'should sets the correct values' do
18
18
  notifier.user_name.should == 'user_name'
19
19
  notifier.subdomain.should == 'subdomain'
20
20
  notifier.password.should == 'password'
@@ -25,292 +25,157 @@ describe Backup::Notifier::Presently do
25
25
  notifier.on_failure.should == true
26
26
  end
27
27
 
28
- it 'uses and overrides configuration defaults' do
29
- Backup::Configuration::Notifier::Presently.defaults do |notifier|
30
- notifier.user_name = 'old_user_name'
31
- notifier.on_success = false
32
- notifier.on_failure = true
33
- end
34
- presently = Backup::Notifier::Presently.new do |notifier|
35
- notifier.user_name = 'new_user_name'
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
36
51
  end
37
52
 
38
- presently.user_name.should == 'new_user_name'
39
- presently.on_success.should == false
40
- presently.on_warning.should == true
41
- presently.on_failure.should == true
42
- end
43
-
44
- it 'creates a Presently::Client (using HTTParty)' do
45
- client = notifier.presently_client
46
- client.should be_an_instance_of Backup::Notifier::Presently::Client
47
- client.subdomain.should == notifier.subdomain
48
- client.user_name.should == notifier.user_name
49
- client.password.should == notifier.password
50
- client.group_id.should == notifier.group_id
51
- client.class.base_uri.
52
- should == "https://#{notifier.subdomain}.presently.com"
53
- client.class.default_options.should have_key(:basic_auth)
54
- client.class.default_options[:basic_auth][:username].
55
- should == notifier.user_name
56
- client.class.default_options[:basic_auth][:password].
57
- should == notifier.password
58
- end
59
-
60
- end # describe '#initialize'
61
-
62
- describe '#perform!' do
63
- let(:model) { Backup::Model.new('trigger', 'label') {} }
64
- let(:post_uri) { '/api/twitter/statuses/update.json' }
65
- let(:post_body) { { :status => nil, :source => 'Backup Notifier' } }
66
- let(:message) { '[Backup::%s] label (trigger)' }
67
-
68
- context 'with group_id' do
69
- let(:notifier) do
70
- Backup::Notifier::Presently.new do |presently|
71
- presently.user_name = 'user_name'
72
- presently.subdomain = 'subdomain'
73
- presently.password = 'password'
74
- presently.group_id = 'group_id'
75
- end
76
- end
77
- let(:client) { notifier.presently_client }
78
-
79
- before do
80
- notifier.on_success = false
81
- notifier.on_warning = false
82
- notifier.on_failure = false
83
- end
84
-
85
- context 'success' do
86
-
87
- context 'when on_success is true' do
88
- before { notifier.on_success = true }
89
-
90
- it 'sends success message' do
91
- notifier.expects(:log!)
92
- status = message % 'Success'
93
- client.class.expects(:post).with(
94
- post_uri, :body => post_body.merge(
95
- { :status => "d @#{notifier.group_id} %s" % status }
96
- )
97
- )
98
-
99
- notifier.perform!(model)
100
- end
101
- end
102
-
103
- context 'when on_success is false' do
104
- it 'sends no message' do
105
- notifier.expects(:log!).never
106
- notifier.expects(:notify!).never
107
- client.expects(:update).never
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'
108
59
 
109
- notifier.perform!(model)
110
- end
60
+ presently.on_success = true
61
+ presently.on_warning = false
62
+ presently.on_failure = false
111
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'
112
69
 
113
- end # context 'success'
114
-
115
- context 'warning' do
116
- before { Backup::Logger.stubs(:has_warnings?).returns(true) }
117
-
118
- context 'when on_success is true' do
119
- before { notifier.on_success = true }
120
-
121
- it 'sends warning message' do
122
- notifier.expects(:log!)
123
- status = message % 'Warning'
124
- client.class.expects(:post).with(
125
- post_uri, :body => post_body.merge(
126
- { :status => "d @#{notifier.group_id} %s" % status }
127
- )
128
- )
129
-
130
- notifier.perform!(model)
131
- end
132
- end
133
-
134
- context 'when on_warning is true' do
135
- before { notifier.on_warning = true }
136
-
137
- it 'sends warning message' do
138
- notifier.expects(:log!)
139
- status = message % 'Warning'
140
- client.class.expects(:post).with(
141
- post_uri, :body => post_body.merge(
142
- { :status => "d @#{notifier.group_id} %s" % status }
143
- )
144
- )
145
-
146
- notifier.perform!(model)
147
- end
148
- end
149
-
150
- context 'when on_success and on_warning are false' do
151
- it 'sends no message' do
152
- notifier.expects(:log!).never
153
- notifier.expects(:notify!).never
154
- client.expects(:update).never
155
-
156
- notifier.perform!(model)
157
- end
158
- end
159
-
160
- end # context 'warning'
161
-
162
- context 'failure' do
163
-
164
- context 'when on_failure is true' do
165
- before { notifier.on_failure = true }
166
-
167
- it 'sends failure message' do
168
- notifier.expects(:log!)
169
- status = message % 'Failure'
170
- client.class.expects(:post).with(
171
- post_uri, :body => post_body.merge(
172
- { :status => "d @#{notifier.group_id} %s" % status }
173
- )
174
- )
175
-
176
- notifier.perform!(model, Exception.new)
177
- end
178
- end
179
-
180
- context 'when on_failure is false' do
181
- it 'sends no message' do
182
- notifier.expects(:log!).never
183
- notifier.expects(:notify!).never
184
- client.expects(:update).never
185
-
186
- notifier.perform!(model, Exception.new)
187
- end
70
+ presently.on_success = false
71
+ presently.on_warning = true
72
+ presently.on_failure = true
188
73
  end
189
74
 
190
- end # context 'failure'
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'
191
79
 
192
- end # context 'with group_id'
193
-
194
- context 'without group_id' do
195
- let(:notifier) do
196
- Backup::Notifier::Presently.new do |presently|
197
- presently.user_name = 'user_name'
198
- presently.subdomain = 'subdomain'
199
- presently.password = 'password'
200
- presently.group_id = nil
201
- end
80
+ notifier.on_success.should == false
81
+ notifier.on_warning.should == true
82
+ notifier.on_failure.should == true
202
83
  end
203
- let(:client) { notifier.presently_client }
204
-
205
- before do
206
- notifier.on_success = false
207
- notifier.on_warning = false
208
- notifier.on_failure = false
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)
209
94
  end
95
+ end
210
96
 
211
- context 'success' do
212
-
213
- context 'when on_success is true' do
214
- before { notifier.on_success = true }
215
-
216
- it 'sends success message' do
217
- notifier.expects(:log!)
218
- client.class.expects(:post).with(
219
- post_uri, :body => post_body.merge(
220
- { :status => message % 'Success' }
221
- )
222
- )
223
-
224
- notifier.perform!(model)
225
- end
226
- end
227
-
228
- context 'when on_success is false' do
229
- it 'sends no message' do
230
- notifier.expects(:log!).never
231
- notifier.expects(:notify!).never
232
- client.expects(:update).never
233
-
234
- notifier.perform!(model)
235
- end
236
- end
237
-
238
- end # context 'success'
239
-
240
- context 'warning' do
241
- before { Backup::Logger.stubs(:has_warnings?).returns(true) }
242
-
243
- context 'when on_success is true' do
244
- before { notifier.on_success = true }
245
-
246
- it 'sends warning message' do
247
- notifier.expects(:log!)
248
- client.class.expects(:post).with(
249
- post_uri, :body => post_body.merge(
250
- { :status => message % 'Warning' }
251
- )
252
- )
253
-
254
- notifier.perform!(model)
255
- end
256
- end
257
-
258
- context 'when on_warning is true' do
259
- before { notifier.on_warning = true }
260
-
261
- it 'sends warning message' do
262
- notifier.expects(:log!)
263
- client.class.expects(:post).with(
264
- post_uri, :body => post_body.merge(
265
- { :status => message % 'Warning' }
266
- )
267
- )
268
-
269
- notifier.perform!(model)
270
- end
271
- end
272
-
273
- context 'when on_success and on_warning are false' do
274
- it 'sends no message' do
275
- notifier.expects(:log!).never
276
- notifier.expects(:notify!).never
277
- client.expects(:update).never
278
-
279
- notifier.perform!(model)
280
- end
281
- end
282
-
283
- end # context 'warning'
284
-
285
- context 'failure' do
286
-
287
- context 'when on_failure is true' do
288
- before { notifier.on_failure = true }
289
-
290
- it 'sends failure message' do
291
- notifier.expects(:log!)
292
- client.class.expects(:post).with(
293
- post_uri, :body => post_body.merge(
294
- { :status => message % 'Failure' }
295
- )
296
- )
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
297
105
 
298
- notifier.perform!(model, Exception.new)
299
- end
300
- end
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!'
301
115
 
302
- context 'when on_failure is false' do
303
- it 'sends no message' do
304
- notifier.expects(:log!).never
305
- notifier.expects(:notify!).never
306
- client.expects(:update).never
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')
307
123
 
308
- notifier.perform!(model, Exception.new)
309
- end
310
- end
124
+ notifier.send(:send_message, 'a message')
125
+ end
126
+ end
127
+ end
311
128
 
312
- end # context 'failure'
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
313
166
 
314
- end # context 'without group_id'
315
- end # describe '#perform!'
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
316
181
  end