rapns_rails_2 3.5.1 → 3.6.1
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.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/lib/rapns/daemon/gcm/delivery.rb +4 -3
- data/lib/rapns/version.rb +1 -1
- metadata +46 -163
- data/config/database.yml +0 -44
- data/spec/support/cert_with_password.pem +0 -90
- data/spec/support/cert_without_password.pem +0 -59
- data/spec/support/simplecov_helper.rb +0 -13
- data/spec/support/simplecov_quality_formatter.rb +0 -8
- data/spec/tmp/.gitkeep +0 -0
- data/spec/unit/apns/app_spec.rb +0 -29
- data/spec/unit/apns/feedback_spec.rb +0 -9
- data/spec/unit/apns/notification_spec.rb +0 -215
- data/spec/unit/apns_feedback_spec.rb +0 -21
- data/spec/unit/app_spec.rb +0 -16
- data/spec/unit/configuration_spec.rb +0 -55
- data/spec/unit/daemon/apns/app_runner_spec.rb +0 -45
- data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +0 -11
- data/spec/unit/daemon/apns/connection_spec.rb +0 -287
- data/spec/unit/daemon/apns/delivery_handler_spec.rb +0 -59
- data/spec/unit/daemon/apns/delivery_spec.rb +0 -101
- data/spec/unit/daemon/apns/disconnection_error_spec.rb +0 -18
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +0 -134
- data/spec/unit/daemon/app_runner_shared.rb +0 -83
- data/spec/unit/daemon/app_runner_spec.rb +0 -170
- data/spec/unit/daemon/batch_spec.rb +0 -219
- data/spec/unit/daemon/delivery_error_spec.rb +0 -13
- data/spec/unit/daemon/delivery_handler_collection_spec.rb +0 -37
- data/spec/unit/daemon/delivery_handler_shared.rb +0 -45
- data/spec/unit/daemon/feeder_spec.rb +0 -89
- data/spec/unit/daemon/gcm/app_runner_spec.rb +0 -19
- data/spec/unit/daemon/gcm/delivery_handler_spec.rb +0 -44
- data/spec/unit/daemon/gcm/delivery_spec.rb +0 -289
- data/spec/unit/daemon/interruptible_sleep_spec.rb +0 -68
- data/spec/unit/daemon/reflectable_spec.rb +0 -27
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +0 -114
- data/spec/unit/daemon/store/active_record_spec.rb +0 -281
- data/spec/unit/daemon_spec.rb +0 -157
- data/spec/unit/deprecatable_spec.rb +0 -32
- data/spec/unit/deprecation_spec.rb +0 -15
- data/spec/unit/embed_spec.rb +0 -50
- data/spec/unit/gcm/app_spec.rb +0 -4
- data/spec/unit/gcm/notification_spec.rb +0 -52
- data/spec/unit/logger_spec.rb +0 -180
- data/spec/unit/notification_shared.rb +0 -45
- data/spec/unit/notification_spec.rb +0 -4
- data/spec/unit/notifier_spec.rb +0 -52
- data/spec/unit/push_spec.rb +0 -44
- data/spec/unit/rapns_spec.rb +0 -9
- data/spec/unit/reflection_spec.rb +0 -30
- data/spec/unit/upgraded_spec.rb +0 -40
- data/spec/unit_spec_helper.rb +0 -137
@@ -1,281 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
require 'rapns/daemon/store/active_record'
|
3
|
-
|
4
|
-
describe Rapns::Daemon::Store::ActiveRecord do
|
5
|
-
let(:app) { Rapns::Apns::App.create!(:name => 'my_app', :environment => 'development', :certificate => TEST_CERT) }
|
6
|
-
let(:notification) { Rapns::Apns::Notification.create!(:device_token => "a" * 256, :app => app) }
|
7
|
-
let(:store) { Rapns::Daemon::Store::ActiveRecord.new }
|
8
|
-
let(:now) { Time.now.utc }
|
9
|
-
|
10
|
-
before { Time.stub(:now => now) }
|
11
|
-
|
12
|
-
it 'reconnects after daemonize' do
|
13
|
-
store.should_receive(:reconnect_database)
|
14
|
-
store.after_daemonize
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'deliverable_notifications' do
|
18
|
-
it 'checks for new notifications with the ability to reconnect the database' do
|
19
|
-
store.should_receive(:with_database_reconnect_and_retry)
|
20
|
-
store.deliverable_notifications(app)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'loads notifications in batches' do
|
24
|
-
Rapns.config.batch_size = 5000
|
25
|
-
Rapns.config.push = false
|
26
|
-
relation = double.as_null_object
|
27
|
-
relation.should_receive(:find).with(:all, :limit => 5000)
|
28
|
-
Rapns::Notification.stub(:ready_for_delivery => relation)
|
29
|
-
store.deliverable_notifications([app])
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'does not load notification in batches if in push mode' do
|
33
|
-
Rapns.config.push = true
|
34
|
-
relation = double.as_null_object
|
35
|
-
relation.should_not_receive(:limit)
|
36
|
-
Rapns::Notification.stub(:ready_for_delivery => relation)
|
37
|
-
store.deliverable_notifications([app])
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'loads an undelivered notification without deliver_after set' do
|
41
|
-
notification.update_attributes!(:delivered => false, :deliver_after => nil)
|
42
|
-
store.deliverable_notifications([app]).should == [notification]
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'loads an notification with a deliver_after time in the past' do
|
46
|
-
notification.update_attributes!(:delivered => false, :deliver_after => 1.hour.ago)
|
47
|
-
store.deliverable_notifications([app]).should == [notification]
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'does not load an notification with a deliver_after time in the future' do
|
51
|
-
notification.update_attributes!(:delivered => false, :deliver_after => 1.hour.from_now)
|
52
|
-
store.deliverable_notifications([app]).should be_empty
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'does not load a previously delivered notification' do
|
56
|
-
notification.update_attributes!(:delivered => true, :delivered_at => Time.now)
|
57
|
-
store.deliverable_notifications([app]).should be_empty
|
58
|
-
end
|
59
|
-
|
60
|
-
it "does not enqueue a notification that has previously failed delivery" do
|
61
|
-
notification.update_attributes!(:delivered => false, :failed => true)
|
62
|
-
store.deliverable_notifications([app]).should be_empty
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'does not load notifications for apps that are still processing the previous batch' do
|
66
|
-
notification
|
67
|
-
store.deliverable_notifications([]).should be_empty
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'mark_retryable' do
|
72
|
-
it 'increments the retry count' do
|
73
|
-
expect do
|
74
|
-
store.mark_retryable(notification, now)
|
75
|
-
end.to change(notification, :retries).by(1)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'sets the deliver after timestamp' do
|
79
|
-
deliver_after = now + 10.seconds
|
80
|
-
expect do
|
81
|
-
store.mark_retryable(notification, deliver_after)
|
82
|
-
end.to change(notification, :deliver_after).to(deliver_after)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'saves the notification without validation' do
|
86
|
-
notification.should_receive(:save).with(false)
|
87
|
-
store.mark_retryable(notification, now)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe 'mark_batch_retryable' do
|
92
|
-
let(:deliver_after) { now + 10.seconds }
|
93
|
-
|
94
|
-
it 'sets the attributes on the object for use in reflections' do
|
95
|
-
store.mark_batch_retryable([notification], deliver_after)
|
96
|
-
notification.deliver_after.should == deliver_after
|
97
|
-
notification.retries.should == 1
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'increments the retired count' do
|
101
|
-
expect do
|
102
|
-
store.mark_batch_retryable([notification], deliver_after)
|
103
|
-
notification.reload
|
104
|
-
end.to change(notification, :retries).by(1)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'sets the deliver after timestamp' do
|
108
|
-
expect do
|
109
|
-
store.mark_batch_retryable([notification], deliver_after)
|
110
|
-
notification.reload
|
111
|
-
end.to change { notification.deliver_after.try(:utc).to_s }.to(deliver_after.utc.to_s)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe 'mark_delivered' do
|
116
|
-
it 'marks the notification as delivered' do
|
117
|
-
expect do
|
118
|
-
store.mark_delivered(notification)
|
119
|
-
end.to change(notification, :delivered).to(true)
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'sets the time the notification was delivered' do
|
123
|
-
expect do
|
124
|
-
store.mark_delivered(notification)
|
125
|
-
notification.reload
|
126
|
-
end.to change { notification.delivered_at.try(:utc).to_s }.to(now.to_s)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'saves the notification without validation' do
|
130
|
-
notification.should_receive(:save).with(false)
|
131
|
-
store.mark_delivered(notification)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe 'mark_batch_delivered' do
|
136
|
-
it 'sets the attributes on the object for use in reflections' do
|
137
|
-
store.mark_batch_delivered([notification])
|
138
|
-
notification.delivered_at.should == now
|
139
|
-
notification.delivered.should be_true
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'marks the notifications as delivered' do
|
143
|
-
expect do
|
144
|
-
store.mark_batch_delivered([notification])
|
145
|
-
notification.reload
|
146
|
-
end.to change(notification, :delivered).to(true)
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'sets the time the notifications were delivered' do
|
150
|
-
expect do
|
151
|
-
store.mark_batch_delivered([notification])
|
152
|
-
notification.reload
|
153
|
-
end.to change { notification.delivered_at.try(:utc).to_s }.to(now.to_s)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe 'mark_failed' do
|
158
|
-
it 'marks the notification as not delivered' do
|
159
|
-
store.mark_failed(notification, nil, '')
|
160
|
-
notification.delivered.should be_false
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'marks the notification as failed' do
|
164
|
-
expect do
|
165
|
-
store.mark_failed(notification, nil, '')
|
166
|
-
notification.reload
|
167
|
-
end.to change(notification, :failed).to(true)
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'sets the time the notification delivery failed' do
|
171
|
-
expect do
|
172
|
-
store.mark_failed(notification, nil, '')
|
173
|
-
notification.reload
|
174
|
-
end.to change { notification.failed_at.try(:utc).to_s }.to(now.to_s)
|
175
|
-
end
|
176
|
-
|
177
|
-
it 'sets the error code' do
|
178
|
-
expect do
|
179
|
-
store.mark_failed(notification, 42, '')
|
180
|
-
end.to change(notification, :error_code).to(42)
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'sets the error description' do
|
184
|
-
expect do
|
185
|
-
store.mark_failed(notification, 42, 'Weeee')
|
186
|
-
end.to change(notification, :error_description).to('Weeee')
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'saves the notification without validation' do
|
190
|
-
notification.should_receive(:save).with(false)
|
191
|
-
store.mark_failed(notification, nil, '')
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
describe 'mark_batch_failed' do
|
196
|
-
it 'sets the attributes on the object for use in reflections' do
|
197
|
-
store.mark_batch_failed([notification], 123, 'an error')
|
198
|
-
notification.failed_at.should == now
|
199
|
-
notification.delivered_at.should be_nil
|
200
|
-
notification.delivered.should be_false
|
201
|
-
notification.failed.should be_true
|
202
|
-
notification.error_code.should == 123
|
203
|
-
notification.error_description.should == 'an error'
|
204
|
-
end
|
205
|
-
|
206
|
-
it 'marks the notification as not delivered' do
|
207
|
-
store.mark_batch_failed([notification], nil, '')
|
208
|
-
notification.reload
|
209
|
-
notification.delivered.should be_false
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'marks the notification as failed' do
|
213
|
-
expect do
|
214
|
-
store.mark_batch_failed([notification], nil, '')
|
215
|
-
notification.reload
|
216
|
-
end.to change(notification, :failed).to(true)
|
217
|
-
end
|
218
|
-
|
219
|
-
it 'sets the time the notification delivery failed' do
|
220
|
-
expect do
|
221
|
-
store.mark_batch_failed([notification], nil, '')
|
222
|
-
notification.reload
|
223
|
-
end.to change { notification.failed_at.try(:utc).to_s }.to(now.to_s)
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'sets the error code' do
|
227
|
-
expect do
|
228
|
-
store.mark_batch_failed([notification], 42, '')
|
229
|
-
notification.reload
|
230
|
-
end.to change(notification, :error_code).to(42)
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'sets the error description' do
|
234
|
-
expect do
|
235
|
-
store.mark_batch_failed([notification], 42, 'Weeee')
|
236
|
-
notification.reload
|
237
|
-
end.to change(notification, :error_description).to('Weeee')
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe 'create_apns_feedback' do
|
242
|
-
it 'creates the Feedback record' do
|
243
|
-
Rapns::Apns::Feedback.should_receive(:create!).with(
|
244
|
-
:failed_at => now, :device_token => 'ab' * 32, :app => app)
|
245
|
-
store.create_apns_feedback(now, 'ab' * 32, app)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
describe 'create_gcm_notification' do
|
250
|
-
let(:data) { { :data => true } }
|
251
|
-
let(:attributes) { { :device_token => 'ab' * 32 } }
|
252
|
-
let(:registration_ids) { ['123', '456'] }
|
253
|
-
let(:deliver_after) { now + 10.seconds }
|
254
|
-
let(:args) { [attributes, data, registration_ids, deliver_after, app] }
|
255
|
-
|
256
|
-
it 'sets the given attributes' do
|
257
|
-
new_notification = store.create_gcm_notification(*args)
|
258
|
-
new_notification.device_token.should == 'ab' * 32
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'sets the given data' do
|
262
|
-
new_notification = store.create_gcm_notification(*args)
|
263
|
-
new_notification.data['data'].should be_true
|
264
|
-
end
|
265
|
-
|
266
|
-
it 'sets the given registration IDs' do
|
267
|
-
new_notification = store.create_gcm_notification(*args)
|
268
|
-
new_notification.registration_ids.should == registration_ids
|
269
|
-
end
|
270
|
-
|
271
|
-
it 'sets the deliver_after timestamp' do
|
272
|
-
new_notification = store.create_gcm_notification(*args)
|
273
|
-
new_notification.deliver_after.to_s.should == deliver_after.to_s
|
274
|
-
end
|
275
|
-
|
276
|
-
it 'saves the new notification' do
|
277
|
-
new_notification = store.create_gcm_notification(*args)
|
278
|
-
new_notification.new_record?.should be_false
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
data/spec/unit/daemon_spec.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
require 'rapns/daemon/store/active_record'
|
3
|
-
|
4
|
-
describe Rapns::Daemon, "when starting" do
|
5
|
-
module Rails; end
|
6
|
-
|
7
|
-
let(:certificate) { double }
|
8
|
-
let(:password) { double }
|
9
|
-
let(:config) { double(:pid_file => nil, :airbrake_notify => false,
|
10
|
-
:foreground => true, :embedded => false, :push => false,
|
11
|
-
:store => :active_record, :logger => nil) }
|
12
|
-
let(:logger) { double(:logger, :info => nil, :error => nil, :warn => nil) }
|
13
|
-
|
14
|
-
before do
|
15
|
-
Rapns.stub(:config => config, :logger => logger)
|
16
|
-
Rapns::Daemon::Feeder.stub(:start)
|
17
|
-
Rapns::Daemon::AppRunner.stub(:sync => nil, :stop => nil)
|
18
|
-
Rapns::Daemon.stub(:daemonize => nil, :exit => nil, :puts => nil)
|
19
|
-
File.stub(:open)
|
20
|
-
Rails.stub(:root).and_return("/rails_root")
|
21
|
-
end
|
22
|
-
|
23
|
-
unless Rapns.jruby?
|
24
|
-
it "forks into a daemon if the foreground option is false" do
|
25
|
-
config.stub(:foreground => false)
|
26
|
-
Rapns::Daemon.initialize_store
|
27
|
-
Rapns::Daemon.store.stub(:after_daemonize => nil)
|
28
|
-
Rapns::Daemon.should_receive(:daemonize)
|
29
|
-
Rapns::Daemon.start
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'notifies the store after forking' do
|
33
|
-
config.stub(:foreground => false)
|
34
|
-
Rapns::Daemon.initialize_store
|
35
|
-
Rapns::Daemon.store.should_receive(:after_daemonize)
|
36
|
-
Rapns::Daemon.start
|
37
|
-
end
|
38
|
-
|
39
|
-
it "does not fork into a daemon if the foreground option is true" do
|
40
|
-
config.stub(:foreground => true)
|
41
|
-
Rapns::Daemon.should_not_receive(:daemonize)
|
42
|
-
Rapns::Daemon.start
|
43
|
-
end
|
44
|
-
|
45
|
-
it "does not fork into a daemon if the push option is true" do
|
46
|
-
config.stub(:push => true)
|
47
|
-
Rapns::Daemon.should_not_receive(:daemonize)
|
48
|
-
Rapns::Daemon.start
|
49
|
-
end
|
50
|
-
|
51
|
-
it "does not fork into a daemon if the embedded option is true" do
|
52
|
-
config.stub(:embedded => true)
|
53
|
-
Rapns::Daemon.should_not_receive(:daemonize)
|
54
|
-
Rapns::Daemon.start
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'sets up setup signal traps' do
|
59
|
-
Rapns::Daemon.should_receive(:setup_signal_traps)
|
60
|
-
Rapns::Daemon.start
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'does not setup signal traps when embedded' do
|
64
|
-
config.stub(:embedded => true)
|
65
|
-
Rapns::Daemon.should_not_receive(:setup_signal_traps)
|
66
|
-
Rapns::Daemon.start
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'instantiates the store' do
|
70
|
-
config.stub(:store => :active_record)
|
71
|
-
Rapns::Daemon.start
|
72
|
-
Rapns::Daemon.store.should be_kind_of(Rapns::Daemon::Store::ActiveRecord)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'logs an error if the store cannot be loaded' do
|
76
|
-
config.stub(:store => :foo_bar)
|
77
|
-
Rapns.logger.should_receive(:error).with(kind_of(LoadError))
|
78
|
-
Rapns::Daemon.start
|
79
|
-
end
|
80
|
-
|
81
|
-
it "writes the process ID to the PID file" do
|
82
|
-
Rapns::Daemon.should_receive(:write_pid_file)
|
83
|
-
Rapns::Daemon.start
|
84
|
-
end
|
85
|
-
|
86
|
-
it "logs an error if the PID file could not be written" do
|
87
|
-
config.stub(:pid_file => '/rails_root/rapns.pid')
|
88
|
-
File.stub(:open).and_raise(Errno::ENOENT)
|
89
|
-
logger.should_receive(:error).with("Failed to write PID to '/rails_root/rapns.pid': #<Errno::ENOENT: No such file or directory>")
|
90
|
-
Rapns::Daemon.start
|
91
|
-
end
|
92
|
-
|
93
|
-
it "starts the feeder" do
|
94
|
-
Rapns::Daemon::Feeder.should_receive(:start)
|
95
|
-
Rapns::Daemon.start
|
96
|
-
end
|
97
|
-
|
98
|
-
it "syncs apps" do
|
99
|
-
Rapns::Daemon::AppRunner.should_receive(:sync)
|
100
|
-
Rapns::Daemon.start
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe Rapns::Daemon, "when being shutdown" do
|
105
|
-
let(:config) { double(:pid_file => '/rails_root/rapns.pid') }
|
106
|
-
let(:logger) { double(:info => nil, :error => nil, :warn => nil) }
|
107
|
-
|
108
|
-
before do
|
109
|
-
Rapns.stub(:config => config)
|
110
|
-
Rapns::Daemon.stub(:puts => nil)
|
111
|
-
Rapns::Daemon::Feeder.stub(:stop)
|
112
|
-
Rapns::Daemon::AppRunner.stub(:stop)
|
113
|
-
end
|
114
|
-
|
115
|
-
# These tests do not work on JRuby.
|
116
|
-
unless Rapns.jruby?
|
117
|
-
it "shuts down when signaled signaled SIGINT" do
|
118
|
-
Rapns::Daemon.setup_signal_traps
|
119
|
-
Rapns::Daemon.should_receive(:shutdown)
|
120
|
-
Process.kill("SIGINT", Process.pid)
|
121
|
-
end
|
122
|
-
|
123
|
-
it "shuts down when signaled signaled SIGTERM" do
|
124
|
-
Rapns::Daemon.setup_signal_traps
|
125
|
-
Rapns::Daemon.should_receive(:shutdown)
|
126
|
-
Process.kill("SIGTERM", Process.pid)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
it "stops the feeder" do
|
131
|
-
Rapns::Daemon::Feeder.should_receive(:stop)
|
132
|
-
Rapns::Daemon.shutdown
|
133
|
-
end
|
134
|
-
|
135
|
-
it "stops the app runners" do
|
136
|
-
Rapns::Daemon::AppRunner.should_receive(:stop)
|
137
|
-
Rapns::Daemon.shutdown
|
138
|
-
end
|
139
|
-
|
140
|
-
it "removes the PID file if one was written" do
|
141
|
-
File.stub(:exists?).and_return(true)
|
142
|
-
File.should_receive(:delete).with("/rails_root/rapns.pid")
|
143
|
-
Rapns::Daemon.shutdown
|
144
|
-
end
|
145
|
-
|
146
|
-
it "does not attempt to remove the PID file if it does not exist" do
|
147
|
-
File.stub(:exists?).and_return(false)
|
148
|
-
File.should_not_receive(:delete)
|
149
|
-
Rapns::Daemon.shutdown
|
150
|
-
end
|
151
|
-
|
152
|
-
it "does not attempt to remove the PID file if one was not written" do
|
153
|
-
config.stub(:pid_file).and_return(nil)
|
154
|
-
File.should_not_receive(:delete)
|
155
|
-
Rapns::Daemon.shutdown
|
156
|
-
end
|
157
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns::Deprecatable do
|
4
|
-
class HasDeprecatedMethod
|
5
|
-
include Rapns::Deprecatable
|
6
|
-
|
7
|
-
def original_called?
|
8
|
-
@called == true
|
9
|
-
end
|
10
|
-
|
11
|
-
def deprecated_method
|
12
|
-
@called = true
|
13
|
-
end
|
14
|
-
deprecated(:deprecated_method, '4.0')
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:klass) { HasDeprecatedMethod.new }
|
18
|
-
|
19
|
-
before do
|
20
|
-
Rapns::Deprecation.stub(:warn)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'warns the method is deprecated when called' do
|
24
|
-
Rapns::Deprecation.should_receive(:warn).with("deprecated_method is deprecated and will be removed from Rapns 4.0.")
|
25
|
-
klass.deprecated_method
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'calls the original method' do
|
29
|
-
klass.deprecated_method
|
30
|
-
klass.original_called?.should be_true
|
31
|
-
end
|
32
|
-
end
|