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
@@ -12,77 +12,100 @@ describe Backup::Notifier::Hipchat do
12
12
  end
13
13
  end
14
14
 
15
+ it 'should be a subclass of Notifier::Base' do
16
+ Backup::Notifier::Hipchat.
17
+ superclass.should == Backup::Notifier::Base
18
+ end
19
+
15
20
  describe '#initialize' do
21
+ after { Backup::Notifier::Hipchat.clear_defaults! }
16
22
 
17
- it 'should set the correct values and defaults' do
18
- notifier.token.should == 'token'
19
- notifier.from.should == 'application'
20
- notifier.rooms_notified.should == ['room1', 'room2']
21
- notifier.notify_users.should == false
22
- notifier.success_color.should == 'yellow'
23
- notifier.warning_color.should == 'yellow'
24
- notifier.failure_color.should == 'yellow'
25
-
26
- notifier.on_success.should == true
27
- notifier.on_warning.should == true
28
- notifier.on_failure.should == true
23
+ it 'should load pre-configured defaults through Base' do
24
+ Backup::Notifier::Hipchat.any_instance.expects(:load_defaults!)
25
+ notifier
29
26
  end
30
27
 
31
- context 'when setting configuration defaults' do
32
- after { Backup::Configuration::Notifier::Hipchat.clear_defaults! }
28
+ it 'should pass the model reference to Base' do
29
+ notifier.instance_variable_get(:@model).should == model
30
+ end
33
31
 
34
- it 'should use the configuration defaults' do
35
- Backup::Configuration::Notifier::Hipchat.defaults do |notifier|
36
- notifier.token = 'old'
37
- notifier.from = 'before'
38
- notifier.success_color = 'green'
32
+ context 'when no pre-configured defaults have been set' do
33
+ it 'should use the values given' do
34
+ notifier.token.should == 'token'
35
+ notifier.from.should == 'application'
36
+ notifier.rooms_notified.should == ['room1', 'room2']
37
+ notifier.notify_users.should == false
38
+ notifier.success_color.should == 'yellow'
39
+ notifier.warning_color.should == 'yellow'
40
+ notifier.failure_color.should == 'yellow'
41
+
42
+ notifier.on_success.should == true
43
+ notifier.on_warning.should == true
44
+ notifier.on_failure.should == true
45
+ end
39
46
 
40
- notifier.on_failure = false
47
+ it 'should use default values if none are given' do
48
+ notifier = Backup::Notifier::Hipchat.new(model)
49
+ notifier.token.should be_nil
50
+ notifier.from.should be_nil
51
+ notifier.rooms_notified.should == []
52
+ notifier.notify_users.should == false
53
+ notifier.success_color.should == 'yellow'
54
+ notifier.warning_color.should == 'yellow'
55
+ notifier.failure_color.should == 'yellow'
56
+
57
+ notifier.on_success.should == true
58
+ notifier.on_warning.should == true
59
+ notifier.on_failure.should == true
60
+ end
61
+ end # context 'when no pre-configured defaults have been set'
62
+
63
+ context 'when pre-configured defaults have been set' do
64
+ before do
65
+ Backup::Notifier::Hipchat.defaults do |n|
66
+ n.token = 'old'
67
+ n.from = 'before'
68
+ n.success_color = 'green'
69
+ n.on_failure = false
41
70
  end
42
- hipchat = Backup::Notifier::Hipchat.new(model)
43
-
44
- hipchat.token.should == 'old'
45
- hipchat.from.should == 'before'
46
- hipchat.rooms_notified.should == []
47
- hipchat.notify_users.should == false
48
- hipchat.success_color.should == 'green'
49
- hipchat.warning_color.should == 'yellow'
50
- hipchat.failure_color.should == 'yellow'
51
-
52
- hipchat.on_success.should == true
53
- hipchat.on_warning.should == true
54
- hipchat.on_failure.should == false
55
71
  end
56
72
 
57
- it 'should override the configuration defaults' do
58
- Backup::Configuration::Notifier::Hipchat.defaults do |notifier|
59
- notifier.token = 'old'
60
- notifier.from = 'before'
61
- notifier.success_color = 'green'
73
+ it 'should use pre-configured defaults' do
74
+ notifier = Backup::Notifier::Hipchat.new(model)
62
75
 
63
- notifier.on_failure = false
64
- end
65
- hipchat = Backup::Notifier::Hipchat.new(model) do |notifier|
66
- notifier.token = 'new'
67
- notifier.from = 'after'
68
- notifier.failure_color = 'red'
76
+ notifier.token.should == 'old'
77
+ notifier.from.should == 'before'
78
+ notifier.rooms_notified.should == []
79
+ notifier.notify_users.should == false
80
+ notifier.success_color.should == 'green'
81
+ notifier.warning_color.should == 'yellow'
82
+ notifier.failure_color.should == 'yellow'
83
+
84
+ notifier.on_success.should == true
85
+ notifier.on_warning.should == true
86
+ notifier.on_failure.should == false
87
+ end
69
88
 
70
- notifier.on_success = false
71
- notifier.on_failure = true
89
+ it 'should override pre-configured defaults' do
90
+ notifier = Backup::Notifier::Hipchat.new(model) do |n|
91
+ n.token = 'new'
92
+ n.from = 'after'
93
+ n.failure_color = 'red'
94
+ n.on_success = false
95
+ n.on_failure = true
72
96
  end
73
97
 
74
- hipchat.token.should == 'new'
75
- hipchat.from.should == 'after'
76
- hipchat.success_color.should == 'green'
77
- hipchat.warning_color.should == 'yellow'
78
- hipchat.failure_color.should == 'red'
98
+ notifier.token.should == 'new'
99
+ notifier.from.should == 'after'
100
+ notifier.success_color.should == 'green'
101
+ notifier.warning_color.should == 'yellow'
102
+ notifier.failure_color.should == 'red'
79
103
 
80
- hipchat.on_success.should == false
81
- hipchat.on_warning.should == true
82
- hipchat.on_failure.should == true
104
+ notifier.on_success.should == false
105
+ notifier.on_warning.should == true
106
+ notifier.on_failure.should == true
83
107
  end
84
- end # context 'when setting configuration defaults'
85
-
108
+ end # context 'when pre-configured defaults have been set'
86
109
  end # describe '#initialize'
87
110
 
88
111
  describe '#notify!' do
@@ -26,44 +26,86 @@ describe Backup::Notifier::Mail do
26
26
  end
27
27
  end
28
28
 
29
+ it 'should be a subclass of Notifier::Base' do
30
+ Backup::Notifier::Mail.
31
+ superclass.should == Backup::Notifier::Base
32
+ end
33
+
29
34
  describe '#initialize' do
35
+ after { Backup::Notifier::Mail.clear_defaults! }
30
36
 
31
- it 'should set the correct values' do
32
- notifier.delivery_method.should == :smtp
33
- notifier.from.should == 'my.sender.email@gmail.com'
34
- notifier.to.should == 'my.receiver.email@gmail.com'
35
- notifier.address.should == 'smtp.gmail.com'
36
- notifier.port.should == 587
37
- notifier.domain.should == 'your.host.name'
38
- notifier.user_name.should == 'user'
39
- notifier.password.should == 'secret'
40
- notifier.authentication.should == 'plain'
41
- notifier.enable_starttls_auto.should == true
42
-
43
- notifier.sendmail.should == '/path/to/sendmail'
44
- notifier.sendmail_args.should == '-i -t -X/tmp/traffic.log'
45
- notifier.exim.should == '/path/to/exim'
46
- notifier.exim_args.should == '-i -t -X/tmp/traffic.log'
47
-
48
- notifier.mail_folder.should == '/path/to/backup/mails'
49
-
50
- notifier.on_success.should == true
51
- notifier.on_warning.should == true
52
- notifier.on_failure.should == true
37
+ it 'should load pre-configured defaults through Base' do
38
+ Backup::Notifier::Mail.any_instance.expects(:load_defaults!)
39
+ notifier
53
40
  end
54
41
 
55
- context 'when using configuration defaults' do
56
- after { Backup::Configuration::Notifier::Mail.clear_defaults! }
42
+ it 'should pass the model reference to Base' do
43
+ notifier.instance_variable_get(:@model).should == model
44
+ end
57
45
 
58
- it 'should use configuration defaults' do
59
- Backup::Configuration::Notifier::Mail.defaults do |mail|
60
- mail.delivery_method = :file
61
- mail.from = 'default.sender@domain.com'
62
- mail.to = 'some.receiver@domain.com'
63
- mail.on_success = false
64
- end
46
+ context 'when no pre-configured defaults have been set' do
47
+ it 'should use the values given' do
48
+ notifier.delivery_method.should == :smtp
49
+ notifier.from.should == 'my.sender.email@gmail.com'
50
+ notifier.to.should == 'my.receiver.email@gmail.com'
51
+ notifier.address.should == 'smtp.gmail.com'
52
+ notifier.port.should == 587
53
+ notifier.domain.should == 'your.host.name'
54
+ notifier.user_name.should == 'user'
55
+ notifier.password.should == 'secret'
56
+ notifier.authentication.should == 'plain'
57
+ notifier.enable_starttls_auto.should == true
58
+
59
+ notifier.sendmail.should == '/path/to/sendmail'
60
+ notifier.sendmail_args.should == '-i -t -X/tmp/traffic.log'
61
+ notifier.exim.should == '/path/to/exim'
62
+ notifier.exim_args.should == '-i -t -X/tmp/traffic.log'
63
+
64
+ notifier.mail_folder.should == '/path/to/backup/mails'
65
+
66
+ notifier.on_success.should == true
67
+ notifier.on_warning.should == true
68
+ notifier.on_failure.should == true
69
+ end
70
+
71
+ it 'should use default values if none are given' do
65
72
  notifier = Backup::Notifier::Mail.new(model)
73
+ notifier.delivery_method.should be_nil
74
+ notifier.from.should be_nil
75
+ notifier.to.should be_nil
76
+ notifier.address.should be_nil
77
+ notifier.port.should be_nil
78
+ notifier.domain.should be_nil
79
+ notifier.user_name.should be_nil
80
+ notifier.password.should be_nil
81
+ notifier.authentication.should be_nil
82
+ notifier.enable_starttls_auto.should be_nil
83
+
84
+ notifier.sendmail.should be_nil
85
+ notifier.sendmail_args.should be_nil
86
+ notifier.exim.should be_nil
87
+ notifier.exim_args.should be_nil
88
+
89
+ notifier.mail_folder.should be_nil
90
+
91
+ notifier.on_success.should == true
92
+ notifier.on_warning.should == true
93
+ notifier.on_failure.should == true
94
+ end
95
+ end # context 'when no pre-configured defaults have been set'
66
96
 
97
+ context 'when pre-configured defaults have been set' do
98
+ before do
99
+ Backup::Notifier::Mail.defaults do |n|
100
+ n.delivery_method = :file
101
+ n.from = 'default.sender@domain.com'
102
+ n.to = 'some.receiver@domain.com'
103
+ n.on_success = false
104
+ end
105
+ end
106
+
107
+ it 'should use pre-configured defaults' do
108
+ notifier = Backup::Notifier::Mail.new(model)
67
109
  notifier.delivery_method.should == :file
68
110
  notifier.from.should == 'default.sender@domain.com'
69
111
  notifier.to.should == 'some.receiver@domain.com'
@@ -87,20 +129,16 @@ describe Backup::Notifier::Mail do
87
129
  notifier.on_failure.should == true
88
130
  end
89
131
 
90
- it 'should override configuration defaults' do
91
- Backup::Configuration::Notifier::Mail.defaults do |mail|
92
- mail.from = 'old.sender@domain.com'
93
- mail.to = 'old.receiver@domain.com'
94
- mail.port = 123
95
- mail.on_success = false
96
- end
97
- notifier = Backup::Notifier::Mail.new(model) do |mail|
98
- mail.from = 'new.sender@domain.com'
99
- mail.to = 'new.receiver@domain.com'
100
- mail.on_warning = false
132
+ it 'should override pre-configured defaults' do
133
+ notifier = Backup::Notifier::Mail.new(model) do |n|
134
+ n.delivery_method = :sendmail
135
+ n.from = 'new.sender@domain.com'
136
+ n.to = 'new.receiver@domain.com'
137
+ n.port = 123
138
+ n.on_warning = false
101
139
  end
102
140
 
103
- notifier.delivery_method.should be_nil
141
+ notifier.delivery_method.should == :sendmail
104
142
  notifier.from.should == 'new.sender@domain.com'
105
143
  notifier.to.should == 'new.receiver@domain.com'
106
144
  notifier.port.should == 123
@@ -109,9 +147,7 @@ describe Backup::Notifier::Mail do
109
147
  notifier.on_warning.should == false
110
148
  notifier.on_failure.should == true
111
149
  end
112
-
113
- end # context 'when using configuration defaults'
114
-
150
+ end # context 'when pre-configured defaults have been set'
115
151
  end # describe '#initialize'
116
152
 
117
153
  describe '#notify!' do
@@ -11,28 +11,57 @@ describe Backup::Notifier::Prowl do
11
11
  end
12
12
  end
13
13
 
14
+ it 'should be a subclass of Notifier::Base' do
15
+ Backup::Notifier::Prowl.
16
+ superclass.should == Backup::Notifier::Base
17
+ end
18
+
14
19
  describe '#initialize' do
15
- it 'should sets the correct values' do
16
- notifier.application.should == 'application'
17
- notifier.api_key.should == 'api_key'
20
+ after { Backup::Notifier::Prowl.clear_defaults! }
18
21
 
19
- notifier.on_success.should == true
20
- notifier.on_warning.should == true
21
- notifier.on_failure.should == true
22
+ it 'should load pre-configured defaults through Base' do
23
+ Backup::Notifier::Prowl.any_instance.expects(:load_defaults!)
24
+ notifier
22
25
  end
23
26
 
24
- context 'when using configuration defaults' do
25
- after { Backup::Configuration::Notifier::Prowl.clear_defaults! }
27
+ it 'should pass the model reference to Base' do
28
+ notifier.instance_variable_get(:@model).should == model
29
+ end
30
+
31
+ context 'when no pre-configured defaults have been set' do
32
+ it 'should use the values given' do
33
+ notifier.application.should == 'application'
34
+ notifier.api_key.should == 'api_key'
35
+
36
+ notifier.on_success.should == true
37
+ notifier.on_warning.should == true
38
+ notifier.on_failure.should == true
39
+ end
26
40
 
27
- it 'should use the configuration defaults' do
28
- Backup::Configuration::Notifier::Prowl.defaults do |prowl|
29
- prowl.application = 'default_app'
30
- prowl.api_key = 'default_api_key'
41
+ it 'should use default values if none are given' do
42
+ notifier = Backup::Notifier::Prowl.new(model)
43
+ notifier.application.should be_nil
44
+ notifier.api_key.should be_nil
31
45
 
32
- prowl.on_success = false
33
- prowl.on_warning = false
34
- prowl.on_failure = false
46
+ notifier.on_success.should == true
47
+ notifier.on_warning.should == true
48
+ notifier.on_failure.should == true
49
+ end
50
+ end # context 'when no pre-configured defaults have been set'
51
+
52
+ context 'when pre-configured defaults have been set' do
53
+ before do
54
+ Backup::Notifier::Prowl.defaults do |n|
55
+ n.application = 'default_app'
56
+ n.api_key = 'default_api_key'
57
+
58
+ n.on_success = false
59
+ n.on_warning = false
60
+ n.on_failure = false
35
61
  end
62
+ end
63
+
64
+ it 'should use pre-configured defaults' do
36
65
  notifier = Backup::Notifier::Prowl.new(model)
37
66
  notifier.application.should == 'default_app'
38
67
  notifier.api_key.should == 'default_api_key'
@@ -42,22 +71,14 @@ describe Backup::Notifier::Prowl do
42
71
  notifier.on_failure.should == false
43
72
  end
44
73
 
45
- it 'should override the configuration defaults' do
46
- Backup::Configuration::Notifier::Prowl.defaults do |prowl|
47
- prowl.application = 'old_app'
48
- prowl.api_key = 'old_api_key'
49
-
50
- prowl.on_success = true
51
- prowl.on_warning = false
52
- prowl.on_failure = false
53
- end
54
- notifier = Backup::Notifier::Prowl.new(model) do |prowl|
55
- prowl.application = 'new_app'
56
- prowl.api_key = 'new_api_key'
74
+ it 'should override pre-configured defaults' do
75
+ notifier = Backup::Notifier::Prowl.new(model) do |n|
76
+ n.application = 'new_app'
77
+ n.api_key = 'new_api_key'
57
78
 
58
- prowl.on_success = false
59
- prowl.on_warning = true
60
- prowl.on_failure = true
79
+ n.on_success = false
80
+ n.on_warning = true
81
+ n.on_failure = true
61
82
  end
62
83
 
63
84
  notifier.application.should == 'new_app'
@@ -67,8 +88,8 @@ describe Backup::Notifier::Prowl do
67
88
  notifier.on_warning.should == true
68
89
  notifier.on_failure.should == true
69
90
  end
70
- end # context 'when using configuration defaults'
71
- end
91
+ end # context 'when pre-configured defaults have been set'
92
+ end # describe '#initialize'
72
93
 
73
94
  describe '#notify!' do
74
95
  context 'when status is :success' do
@@ -13,32 +13,63 @@ describe Backup::Notifier::Twitter do
13
13
  end
14
14
  end
15
15
 
16
+ it 'should be a subclass of Notifier::Base' do
17
+ Backup::Notifier::Twitter.
18
+ superclass.should == Backup::Notifier::Base
19
+ end
20
+
16
21
  describe '#initialize' do
17
- it 'should sets the correct values' do
18
- notifier.consumer_key.should == 'consumer_key'
19
- notifier.consumer_secret.should == 'consumer_secret'
20
- notifier.oauth_token.should == 'oauth_token'
21
- notifier.oauth_token_secret.should == 'oauth_token_secret'
22
-
23
- notifier.on_success.should == true
24
- notifier.on_warning.should == true
25
- notifier.on_failure.should == true
22
+ after { Backup::Notifier::Twitter.clear_defaults! }
23
+
24
+ it 'should load pre-configured defaults through Base' do
25
+ Backup::Notifier::Twitter.any_instance.expects(:load_defaults!)
26
+ notifier
26
27
  end
27
28
 
28
- context 'when using configuration defaults' do
29
- after { Backup::Configuration::Notifier::Twitter.clear_defaults! }
29
+ it 'should pass the model reference to Base' do
30
+ notifier.instance_variable_get(:@model).should == model
31
+ end
30
32
 
31
- it 'should use the configuration defaults' do
32
- Backup::Configuration::Notifier::Twitter.defaults do |twitter|
33
- twitter.consumer_key = 'some_consumer_key'
34
- twitter.consumer_secret = 'some_consumer_secret'
35
- twitter.oauth_token = 'some_oauth_token'
36
- twitter.oauth_token_secret = 'some_oauth_token_secret'
33
+ context 'when no pre-configured defaults have been set' do
34
+ it 'should use the values given' do
35
+ notifier.consumer_key.should == 'consumer_key'
36
+ notifier.consumer_secret.should == 'consumer_secret'
37
+ notifier.oauth_token.should == 'oauth_token'
38
+ notifier.oauth_token_secret.should == 'oauth_token_secret'
37
39
 
38
- twitter.on_success = false
39
- twitter.on_warning = false
40
- twitter.on_failure = false
40
+ notifier.on_success.should == true
41
+ notifier.on_warning.should == true
42
+ notifier.on_failure.should == true
43
+ end
44
+
45
+ it 'should use default values if none are given' do
46
+ notifier = Backup::Notifier::Twitter.new(model)
47
+ notifier.consumer_key.should be_nil
48
+ notifier.consumer_secret.should be_nil
49
+ notifier.oauth_token.should be_nil
50
+ notifier.oauth_token_secret.should be_nil
51
+
52
+ notifier.on_success.should == true
53
+ notifier.on_warning.should == true
54
+ notifier.on_failure.should == true
55
+ end
56
+ end # context 'when no pre-configured defaults have been set'
57
+
58
+ context 'when pre-configured defaults have been set' do
59
+ before do
60
+ Backup::Notifier::Twitter.defaults do |n|
61
+ n.consumer_key = 'some_consumer_key'
62
+ n.consumer_secret = 'some_consumer_secret'
63
+ n.oauth_token = 'some_oauth_token'
64
+ n.oauth_token_secret = 'some_oauth_token_secret'
65
+
66
+ n.on_success = false
67
+ n.on_warning = false
68
+ n.on_failure = false
41
69
  end
70
+ end
71
+
72
+ it 'should use pre-configured defaults' do
42
73
  notifier = Backup::Notifier::Twitter.new(model)
43
74
  notifier.consumer_key.should == 'some_consumer_key'
44
75
  notifier.consumer_secret.should == 'some_consumer_secret'
@@ -50,26 +81,16 @@ describe Backup::Notifier::Twitter do
50
81
  notifier.on_failure.should == false
51
82
  end
52
83
 
53
- it 'should override the configuration defaults' do
54
- Backup::Configuration::Notifier::Twitter.defaults do |twitter|
55
- twitter.consumer_key = 'old_consumer_key'
56
- twitter.consumer_secret = 'old_consumer_secret'
57
- twitter.oauth_token = 'old_oauth_token'
58
- twitter.oauth_token_secret = 'old_oauth_token_secret'
84
+ it 'should override pre-configured defaults' do
85
+ notifier = Backup::Notifier::Twitter.new(model) do |n|
86
+ n.consumer_key = 'new_consumer_key'
87
+ n.consumer_secret = 'new_consumer_secret'
88
+ n.oauth_token = 'new_oauth_token'
89
+ n.oauth_token_secret = 'new_oauth_token_secret'
59
90
 
60
- twitter.on_success = true
61
- twitter.on_warning = false
62
- twitter.on_failure = false
63
- end
64
- notifier = Backup::Notifier::Twitter.new(model) do |twitter|
65
- twitter.consumer_key = 'new_consumer_key'
66
- twitter.consumer_secret = 'new_consumer_secret'
67
- twitter.oauth_token = 'new_oauth_token'
68
- twitter.oauth_token_secret = 'new_oauth_token_secret'
69
-
70
- twitter.on_success = false
71
- twitter.on_warning = true
72
- twitter.on_failure = true
91
+ n.on_success = false
92
+ n.on_warning = true
93
+ n.on_failure = true
73
94
  end
74
95
 
75
96
  notifier.consumer_key.should == 'new_consumer_key'
@@ -81,8 +102,8 @@ describe Backup::Notifier::Twitter do
81
102
  notifier.on_warning.should == true
82
103
  notifier.on_failure.should == true
83
104
  end
84
- end # context 'when using configuration defaults'
85
- end
105
+ end # context 'when pre-configured defaults have been set'
106
+ end # describe '#initialize'
86
107
 
87
108
  describe '#notify!' do
88
109
  context 'when status is :success' do