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,219 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns::Daemon::Batch do
|
4
|
-
let(:notification1) { double(:notification1, :id => 1) }
|
5
|
-
let(:notification2) { double(:notification2, :id => 2) }
|
6
|
-
let(:batch) { Rapns::Daemon::Batch.new([notification1, notification2]) }
|
7
|
-
let(:store) { double.as_null_object }
|
8
|
-
|
9
|
-
before do
|
10
|
-
Rapns::Daemon.stub(:store => store)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'exposes the notifications' do
|
14
|
-
batch.notifications.should == [notification1, notification2]
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'exposes the number notifications' do
|
18
|
-
batch.num_notifications.should == 2
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'exposes the number notifications processed' do
|
22
|
-
batch.num_processed.should == 0
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'increments the processed notifications count' do
|
26
|
-
expect { batch.notification_processed }.to change(batch, :num_processed).to(1)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'completes the batch when all notifications have been processed' do
|
30
|
-
batch.should_receive(:complete)
|
31
|
-
2.times { batch.notification_processed }
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'can be described' do
|
35
|
-
batch.describe.should == '1, 2'
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'mark_delivered' do
|
39
|
-
describe 'batching is disabled' do
|
40
|
-
before { Rapns.config.batch_storage_updates = false }
|
41
|
-
|
42
|
-
it 'marks the notification as delivered immediately' do
|
43
|
-
store.should_receive(:mark_delivered).with(notification1)
|
44
|
-
batch.mark_delivered(notification1)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'reflects the notification was delivered' do
|
48
|
-
batch.should_receive(:reflect).with(:notification_delivered, notification1)
|
49
|
-
batch.mark_delivered(notification1)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'batching is enabled' do
|
54
|
-
before { Rapns.config.batch_storage_updates = true }
|
55
|
-
|
56
|
-
it 'defers marking the notification as delivered until the batch is complete' do
|
57
|
-
batch.mark_delivered(notification1)
|
58
|
-
batch.delivered.should == [notification1]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'mark_failed' do
|
64
|
-
describe 'batching is disabled' do
|
65
|
-
before { Rapns.config.batch_storage_updates = false }
|
66
|
-
|
67
|
-
it 'marks the notification as failed' do
|
68
|
-
store.should_receive(:mark_failed).with(notification1, 1, 'an error')
|
69
|
-
batch.mark_failed(notification1, 1, 'an error')
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'reflects the notification failed' do
|
73
|
-
batch.should_receive(:reflect).with(:notification_delivered, notification1)
|
74
|
-
batch.mark_delivered(notification1)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe 'batching is enabled' do
|
79
|
-
before { Rapns.config.batch_storage_updates = true }
|
80
|
-
|
81
|
-
it 'defers marking the notification as failed' do
|
82
|
-
Rapns.config.batch_storage_updates = true
|
83
|
-
batch.mark_failed(notification1, 1, 'an error')
|
84
|
-
batch.failed.should == {[1, 'an error'] => [notification1]}
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'mark_retryable' do
|
90
|
-
let(:time) { Time.now }
|
91
|
-
|
92
|
-
describe 'batching is disabled' do
|
93
|
-
before { Rapns.config.batch_storage_updates = false }
|
94
|
-
|
95
|
-
it 'marks the notification as retryable' do
|
96
|
-
store.should_receive(:mark_retryable).with(notification1, time)
|
97
|
-
batch.mark_retryable(notification1, time)
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'reflects the notification will be retried' do
|
101
|
-
batch.should_receive(:reflect).with(:notification_will_retry, notification1)
|
102
|
-
batch.mark_retryable(notification1, time)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe 'batching is enabled' do
|
107
|
-
before { Rapns.config.batch_storage_updates = true }
|
108
|
-
|
109
|
-
it 'defers marking the notification as retryable' do
|
110
|
-
batch.mark_retryable(notification1, time)
|
111
|
-
batch.retryable.should == {time => [notification1]}
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe 'complete' do
|
117
|
-
before do
|
118
|
-
Rapns.config.batch_storage_updates = true
|
119
|
-
Rapns.stub(:logger => double.as_null_object)
|
120
|
-
batch.stub(:reflect)
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'clears the notifications' do
|
124
|
-
expect do
|
125
|
-
2.times { batch.notification_processed }
|
126
|
-
end.to change(batch.notifications, :length).to(0)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'identifies as complete' do
|
130
|
-
expect do
|
131
|
-
2.times { batch.notification_processed }
|
132
|
-
end.to change(batch, :complete?).to(true)
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'reflects errors raised during completion' do
|
136
|
-
e = StandardError.new
|
137
|
-
batch.stub(:complete_delivered).and_raise(e)
|
138
|
-
batch.should_receive(:reflect).with(:error, e)
|
139
|
-
2.times { batch.notification_processed }
|
140
|
-
end
|
141
|
-
|
142
|
-
describe 'delivered' do
|
143
|
-
def complete
|
144
|
-
[notification1, notification2].each do |n|
|
145
|
-
batch.mark_delivered(n)
|
146
|
-
batch.notification_processed
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'marks the batch as delivered' do
|
151
|
-
store.should_receive(:mark_batch_delivered).with([notification1, notification2])
|
152
|
-
complete
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'reflects the notifications were delivered' do
|
156
|
-
batch.should_receive(:reflect).with(:notification_delivered, notification1)
|
157
|
-
batch.should_receive(:reflect).with(:notification_delivered, notification2)
|
158
|
-
complete
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'clears the delivered notifications' do
|
162
|
-
complete
|
163
|
-
batch.delivered.should == []
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe 'failed' do
|
168
|
-
def complete
|
169
|
-
[notification1, notification2].each do |n|
|
170
|
-
batch.mark_failed(n, 1, 'an error')
|
171
|
-
batch.notification_processed
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'marks the batch as failed' do
|
176
|
-
store.should_receive(:mark_batch_failed).with([notification1, notification2], 1, 'an error')
|
177
|
-
complete
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'reflects the notifications failed' do
|
181
|
-
batch.should_receive(:reflect).with(:notification_failed, notification1)
|
182
|
-
batch.should_receive(:reflect).with(:notification_failed, notification2)
|
183
|
-
complete
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'clears the failed notifications' do
|
187
|
-
complete
|
188
|
-
batch.failed.should == {}
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe 'retryable' do
|
193
|
-
let(:time) { Time.now }
|
194
|
-
|
195
|
-
def complete
|
196
|
-
[notification1, notification2].each do |n|
|
197
|
-
batch.mark_retryable(n, time)
|
198
|
-
batch.notification_processed
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'marks the batch as retryable' do
|
203
|
-
store.should_receive(:mark_batch_retryable).with([notification1, notification2], time)
|
204
|
-
complete
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'reflects the notifications will be retried' do
|
208
|
-
batch.should_receive(:reflect).with(:notification_will_retry, notification1)
|
209
|
-
batch.should_receive(:reflect).with(:notification_will_retry, notification2)
|
210
|
-
complete
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'clears the retryable notifications' do
|
214
|
-
complete
|
215
|
-
batch.retryable.should == {}
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns::DeliveryError do
|
4
|
-
let(:error) { Rapns::DeliveryError.new(4, 12, "Missing payload") }
|
5
|
-
|
6
|
-
it "returns an informative message" do
|
7
|
-
error.to_s.should == "Unable to deliver notification 12, received error 4 (Missing payload)"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "returns the error code" do
|
11
|
-
error.code.should == 4
|
12
|
-
end
|
13
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns::Daemon::DeliveryHandlerCollection do
|
4
|
-
let(:handler) { double.as_null_object }
|
5
|
-
let(:collection) { Rapns::Daemon::DeliveryHandlerCollection.new }
|
6
|
-
|
7
|
-
it 'returns the size of the collection' do
|
8
|
-
collection.push(handler)
|
9
|
-
collection.size.should == 1
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'pops a handler from the collection' do
|
13
|
-
collection.push(handler)
|
14
|
-
handler.should_receive(:stop)
|
15
|
-
handler.should_receive(:wakeup)
|
16
|
-
handler.should_receive(:wait)
|
17
|
-
collection.pop
|
18
|
-
collection.size.should == 0
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'wakes up all handlers when popping a single handler' do
|
22
|
-
collection.push(handler)
|
23
|
-
handler2 = double.as_null_object
|
24
|
-
collection.push(handler2)
|
25
|
-
handler.should_receive(:wakeup)
|
26
|
-
handler2.should_receive(:wakeup)
|
27
|
-
collection.pop
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'stops all handlers' do
|
31
|
-
collection.push(handler)
|
32
|
-
handler.should_receive(:stop)
|
33
|
-
handler.should_receive(:wakeup)
|
34
|
-
handler.should_receive(:wait)
|
35
|
-
collection.stop
|
36
|
-
end
|
37
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
shared_examples_for 'an DeliveryHandler subclass' do
|
2
|
-
def run_delivery_handler
|
3
|
-
delivery_handler.start
|
4
|
-
delivery_handler.stop
|
5
|
-
delivery_handler.wakeup
|
6
|
-
delivery_handler.wait
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'logs all delivery errors' do
|
10
|
-
logger = double
|
11
|
-
Rapns.stub(:logger => logger)
|
12
|
-
error = StandardError.new
|
13
|
-
delivery_handler.stub(:deliver).and_raise(error)
|
14
|
-
Rapns.logger.should_receive(:error).with(error)
|
15
|
-
run_delivery_handler
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'reflects an exception' do
|
19
|
-
Rapns.stub(:logger => double(:error => nil))
|
20
|
-
error = StandardError.new
|
21
|
-
delivery_handler.stub(:deliver).and_raise(error)
|
22
|
-
delivery_handler.should_receive(:reflect).with(:error, error)
|
23
|
-
run_delivery_handler
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'instructs the batch that the notification has been processed' do
|
27
|
-
batch.should_receive(:notification_processed)
|
28
|
-
run_delivery_handler
|
29
|
-
end
|
30
|
-
|
31
|
-
it "instructs the queue to wakeup the thread when told to stop" do
|
32
|
-
queue.should_receive(:push).with(Rapns::Daemon::DeliveryHandler::WAKEUP) { |*a| queue.proxied_by_rspec__push(*a) }
|
33
|
-
run_delivery_handler
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "when being stopped" do
|
37
|
-
before { queue.pop }
|
38
|
-
|
39
|
-
it "does not attempt to deliver a notification when a WAKEUP is dequeued" do
|
40
|
-
queue.stub(:pop).and_return(Rapns::Daemon::DeliveryHandler::WAKEUP)
|
41
|
-
delivery_handler.should_not_receive(:deliver)
|
42
|
-
delivery_handler.send(:handle_next_notification)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns::Daemon::Feeder do
|
4
|
-
let(:config) { double(:batch_size => 5000,
|
5
|
-
:push_poll => 0,
|
6
|
-
:embedded => false,
|
7
|
-
:push => false,
|
8
|
-
:wakeup => nil) }
|
9
|
-
let!(:app) { Rapns::Apns::App.create!(:name => 'my_app', :environment => 'development', :certificate => TEST_CERT) }
|
10
|
-
let(:notification) { Rapns::Apns::Notification.create!(:device_token => "a" * 256, :app => app) }
|
11
|
-
let(:logger) { double }
|
12
|
-
let(:interruptible_sleep) { double(:sleep => nil, :interrupt_sleep => nil) }
|
13
|
-
|
14
|
-
before do
|
15
|
-
Rapns.stub(:config => config,:logger => logger)
|
16
|
-
Rapns::Daemon.stub(:store => double(:deliverable_notifications => [notification]))
|
17
|
-
Rapns::Daemon::Feeder.stub(:stop? => true)
|
18
|
-
Rapns::Daemon::AppRunner.stub(:enqueue => nil, :idle => [double(:app => app)])
|
19
|
-
Rapns::Daemon::InterruptibleSleep.stub(:new => interruptible_sleep)
|
20
|
-
Rapns::Daemon::Feeder.instance_variable_set('@interruptible_sleeper', nil)
|
21
|
-
end
|
22
|
-
|
23
|
-
def start_and_stop
|
24
|
-
Rapns::Daemon::Feeder.start
|
25
|
-
Rapns::Daemon::Feeder.stop
|
26
|
-
end
|
27
|
-
|
28
|
-
it "starts the loop in a new thread if embedded" do
|
29
|
-
config.stub(:embedded => true)
|
30
|
-
Thread.should_receive(:new).and_yield
|
31
|
-
Rapns::Daemon::Feeder.should_receive(:feed_forever)
|
32
|
-
start_and_stop
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'loads deliverable notifications' do
|
36
|
-
Rapns::Daemon.store.should_receive(:deliverable_notifications).with([app])
|
37
|
-
start_and_stop
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'does not attempt to load deliverable notifications if there are no idle runners' do
|
41
|
-
Rapns::Daemon::AppRunner.stub(:idle => [])
|
42
|
-
Rapns::Daemon.store.should_not_receive(:deliverable_notifications)
|
43
|
-
start_and_stop
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'enqueues notifications without looping if in push mode' do
|
47
|
-
config.stub(:push => true)
|
48
|
-
Rapns::Daemon::Feeder.should_not_receive(:feed_forever)
|
49
|
-
Rapns::Daemon::Feeder.should_receive(:enqueue_notifications)
|
50
|
-
start_and_stop
|
51
|
-
end
|
52
|
-
|
53
|
-
it "enqueues the notifications" do
|
54
|
-
Rapns::Daemon::AppRunner.should_receive(:enqueue).with([notification])
|
55
|
-
start_and_stop
|
56
|
-
end
|
57
|
-
|
58
|
-
it "logs errors" do
|
59
|
-
e = StandardError.new("bork")
|
60
|
-
Rapns::Daemon.store.stub(:deliverable_notifications).and_raise(e)
|
61
|
-
Rapns.logger.should_receive(:error).with(e)
|
62
|
-
start_and_stop
|
63
|
-
end
|
64
|
-
|
65
|
-
it "interrupts sleep when stopped" do
|
66
|
-
Rapns::Daemon::Feeder.should_receive(:interrupt_sleep)
|
67
|
-
start_and_stop
|
68
|
-
end
|
69
|
-
|
70
|
-
it "enqueues notifications when started" do
|
71
|
-
Rapns::Daemon::Feeder.should_receive(:enqueue_notifications).at_least(:once)
|
72
|
-
Rapns::Daemon::Feeder.stub(:loop).and_yield
|
73
|
-
start_and_stop
|
74
|
-
end
|
75
|
-
|
76
|
-
it "sleeps for the given period" do
|
77
|
-
config.stub(:push_poll => 2)
|
78
|
-
interruptible_sleep.should_receive(:sleep).with(2)
|
79
|
-
start_and_stop
|
80
|
-
end
|
81
|
-
|
82
|
-
it "creates the wakeup socket" do
|
83
|
-
bind = '127.0.0.1'
|
84
|
-
port = 12345
|
85
|
-
config.stub(:wakeup => { :bind => bind, :port => port})
|
86
|
-
interruptible_sleep.should_receive(:enable_wake_on_udp).with(bind, port)
|
87
|
-
start_and_stop
|
88
|
-
end
|
89
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
require File.dirname(__FILE__) + '/../app_runner_shared.rb'
|
3
|
-
|
4
|
-
describe Rapns::Daemon::Gcm::AppRunner do
|
5
|
-
it_should_behave_like 'an AppRunner subclass'
|
6
|
-
|
7
|
-
let(:app_class) { Rapns::Gcm::App }
|
8
|
-
let(:app) { app_class.new }
|
9
|
-
let(:runner) { Rapns::Daemon::Gcm::AppRunner.new(app) }
|
10
|
-
let(:handler) { double(:start => nil, :queue= => nil, :wakeup => nil, :wait => nil) }
|
11
|
-
let(:handler_collection) { double(:handler_collection, :push => nil, :size => 1, :stop => nil) }
|
12
|
-
let(:logger) { double(:info => nil) }
|
13
|
-
|
14
|
-
before do
|
15
|
-
Rapns.stub(:logger => logger)
|
16
|
-
Rapns::Daemon::Gcm::DeliveryHandler.stub(:new => handler)
|
17
|
-
Rapns::Daemon::DeliveryHandlerCollection.stub(:new => handler_collection)
|
18
|
-
end
|
19
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
require File.dirname(__FILE__) + '/../delivery_handler_shared.rb'
|
3
|
-
|
4
|
-
describe Rapns::Daemon::Gcm::DeliveryHandler do
|
5
|
-
it_should_behave_like 'an DeliveryHandler subclass'
|
6
|
-
|
7
|
-
let(:notification) { double }
|
8
|
-
let(:batch) { double(:notification_processed => nil) }
|
9
|
-
let(:queue) { Queue.new }
|
10
|
-
let(:app) { double }
|
11
|
-
let(:delivery_handler) { Rapns::Daemon::Gcm::DeliveryHandler.new(app) }
|
12
|
-
let(:http) { double(:shutdown => nil) }
|
13
|
-
let(:delivery) { double(:perform => nil) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
Net::HTTP::Persistent.stub(:new => http)
|
17
|
-
Rapns::Daemon::Gcm::Delivery.stub(:new => delivery)
|
18
|
-
delivery_handler.queue = queue
|
19
|
-
queue.push([notification, batch])
|
20
|
-
end
|
21
|
-
|
22
|
-
def run_delivery_handler
|
23
|
-
delivery_handler.start
|
24
|
-
delivery_handler.stop
|
25
|
-
delivery_handler.wakeup
|
26
|
-
delivery_handler.wait
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'performs delivery of an notification' do
|
30
|
-
Rapns::Daemon::Gcm::Delivery.should_receive(:new).with(app, http, notification, batch).and_return(delivery)
|
31
|
-
delivery.should_receive(:perform)
|
32
|
-
run_delivery_handler
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'initiates a persistent connection object' do
|
36
|
-
Net::HTTP::Persistent.should_receive(:new).with('rapns')
|
37
|
-
Rapns::Daemon::Gcm::DeliveryHandler.new(app)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'shuts down the http connection stopped' do
|
41
|
-
http.should_receive(:shutdown)
|
42
|
-
run_delivery_handler
|
43
|
-
end
|
44
|
-
end
|