rapns 3.3.2-java → 3.4.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/README.md +19 -21
  3. data/bin/rapns +14 -13
  4. data/lib/generators/templates/rapns.rb +8 -4
  5. data/lib/rapns.rb +7 -0
  6. data/lib/rapns/TODO +3 -0
  7. data/lib/rapns/apns/feedback.rb +4 -2
  8. data/lib/rapns/app.rb +3 -1
  9. data/lib/rapns/configuration.rb +8 -1
  10. data/lib/rapns/daemon.rb +3 -1
  11. data/lib/rapns/daemon/apns/app_runner.rb +3 -2
  12. data/lib/rapns/daemon/apns/certificate_expired_error.rb +20 -0
  13. data/lib/rapns/daemon/apns/connection.rb +26 -0
  14. data/lib/rapns/daemon/apns/delivery.rb +2 -1
  15. data/lib/rapns/daemon/apns/delivery_handler.rb +2 -2
  16. data/lib/rapns/daemon/app_runner.rb +50 -28
  17. data/lib/rapns/daemon/batch.rb +100 -0
  18. data/lib/rapns/daemon/delivery.rb +6 -10
  19. data/lib/rapns/daemon/delivery_handler.rb +14 -12
  20. data/lib/rapns/daemon/delivery_handler_collection.rb +33 -0
  21. data/lib/rapns/daemon/feeder.rb +3 -5
  22. data/lib/rapns/daemon/gcm/delivery.rb +5 -4
  23. data/lib/rapns/daemon/gcm/delivery_handler.rb +2 -2
  24. data/lib/rapns/daemon/store/active_record.rb +23 -2
  25. data/lib/rapns/deprecation.rb +7 -6
  26. data/lib/rapns/logger.rb +1 -1
  27. data/lib/rapns/notification.rb +5 -3
  28. data/lib/rapns/reflection.rb +1 -1
  29. data/lib/rapns/version.rb +1 -1
  30. data/lib/tasks/cane.rake +1 -1
  31. data/lib/tasks/test.rake +8 -3
  32. data/spec/unit/apns/app_spec.rb +4 -4
  33. data/spec/unit/apns_feedback_spec.rb +1 -1
  34. data/spec/unit/configuration_spec.rb +12 -6
  35. data/spec/unit/daemon/apns/app_runner_spec.rb +6 -4
  36. data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +11 -0
  37. data/spec/unit/daemon/apns/connection_spec.rb +46 -10
  38. data/spec/unit/daemon/apns/delivery_handler_spec.rb +24 -18
  39. data/spec/unit/daemon/apns/delivery_spec.rb +11 -12
  40. data/spec/unit/daemon/apns/feedback_receiver_spec.rb +16 -16
  41. data/spec/unit/daemon/app_runner_shared.rb +27 -10
  42. data/spec/unit/daemon/app_runner_spec.rb +48 -28
  43. data/spec/unit/daemon/batch_spec.rb +160 -0
  44. data/spec/unit/daemon/delivery_handler_collection_spec.rb +37 -0
  45. data/spec/unit/daemon/delivery_handler_shared.rb +20 -11
  46. data/spec/unit/daemon/feeder_spec.rb +12 -12
  47. data/spec/unit/daemon/gcm/app_runner_spec.rb +4 -2
  48. data/spec/unit/daemon/gcm/delivery_handler_spec.rb +18 -10
  49. data/spec/unit/daemon/gcm/delivery_spec.rb +47 -17
  50. data/spec/unit/daemon/interruptible_sleep_spec.rb +3 -3
  51. data/spec/unit/daemon/reflectable_spec.rb +1 -1
  52. data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +1 -1
  53. data/spec/unit/daemon/store/active_record_spec.rb +87 -10
  54. data/spec/unit/daemon_spec.rb +6 -6
  55. data/spec/unit/deprecation_spec.rb +2 -2
  56. data/spec/unit/logger_spec.rb +33 -17
  57. data/spec/unit/notification_shared.rb +7 -3
  58. data/spec/unit/upgraded_spec.rb +8 -14
  59. data/spec/unit_spec_helper.rb +9 -1
  60. metadata +53 -44
  61. data/lib/rapns/daemon/delivery_queue.rb +0 -42
  62. data/lib/rapns/daemon/delivery_queue_18.rb +0 -44
  63. data/lib/rapns/daemon/delivery_queue_19.rb +0 -42
  64. data/spec/acceptance/gcm_upgrade_spec.rb +0 -34
  65. data/spec/acceptance_spec_helper.rb +0 -85
  66. data/spec/unit/daemon/delivery_queue_spec.rb +0 -29
@@ -7,11 +7,13 @@ describe Rapns::Daemon::Gcm::AppRunner do
7
7
  let(:app_class) { Rapns::Gcm::App }
8
8
  let(:app) { app_class.new }
9
9
  let(:runner) { Rapns::Daemon::Gcm::AppRunner.new(app) }
10
- let(:handler) { stub(:start => nil, :stop => nil, :queue= => nil) }
11
- let(:logger) { stub(:info => nil) }
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) }
12
13
 
13
14
  before do
14
15
  Rapns.stub(:logger => logger)
15
16
  Rapns::Daemon::Gcm::DeliveryHandler.stub(:new => handler)
17
+ Rapns::Daemon::DeliveryHandlerCollection.stub(:new => handler_collection)
16
18
  end
17
19
  end
@@ -4,23 +4,32 @@ require File.dirname(__FILE__) + '/../delivery_handler_shared.rb'
4
4
  describe Rapns::Daemon::Gcm::DeliveryHandler do
5
5
  it_should_behave_like 'an DeliveryHandler subclass'
6
6
 
7
- let(:app) { stub }
7
+ let(:notification) { double }
8
+ let(:batch) { double(:notification_processed => nil) }
9
+ let(:queue) { Queue.new }
10
+ let(:app) { double }
8
11
  let(:delivery_handler) { Rapns::Daemon::Gcm::DeliveryHandler.new(app) }
9
- let(:notification) { stub }
10
- let(:http) { stub(:shutdown => nil)}
11
- let(:queue) { Rapns::Daemon::DeliveryQueue.new }
12
+ let(:http) { double(:shutdown => nil) }
13
+ let(:delivery) { double(:perform => nil) }
12
14
 
13
15
  before do
14
16
  Net::HTTP::Persistent.stub(:new => http)
15
- Rapns::Daemon::Gcm::Delivery.stub(:perform)
17
+ Rapns::Daemon::Gcm::Delivery.stub(:new => delivery)
16
18
  delivery_handler.queue = queue
17
- queue.push(notification)
19
+ queue.push([notification, batch])
18
20
  end
19
21
 
20
- it 'performs delivery of an notification' do
21
- Rapns::Daemon::Gcm::Delivery.should_receive(:perform).with(app, http, notification)
22
+ def run_delivery_handler
22
23
  delivery_handler.start
23
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
24
33
  end
25
34
 
26
35
  it 'initiates a persistent connection object' do
@@ -30,7 +39,6 @@ describe Rapns::Daemon::Gcm::DeliveryHandler do
30
39
 
31
40
  it 'shuts down the http connection stopped' do
32
41
  http.should_receive(:shutdown)
33
- delivery_handler.start
34
- delivery_handler.stop
42
+ run_delivery_handler
35
43
  end
36
44
  end
@@ -3,12 +3,13 @@ require 'unit_spec_helper'
3
3
  describe Rapns::Daemon::Gcm::Delivery do
4
4
  let(:app) { Rapns::Gcm::App.new(:name => 'MyApp', :auth_key => 'abc123') }
5
5
  let(:notification) { Rapns::Gcm::Notification.create!(:app => app, :registration_ids => ['xyz'], :deliver_after => Time.now) }
6
- let(:logger) { stub(:error => nil, :info => nil, :warn => nil) }
7
- let(:response) { stub(:code => 200, :header => {}) }
8
- let(:http) { stub(:shutdown => nil, :request => response)}
6
+ let(:logger) { double(:error => nil, :info => nil, :warn => nil) }
7
+ let(:response) { double(:code => 200, :header => {}) }
8
+ let(:http) { double(:shutdown => nil, :request => response)}
9
9
  let(:now) { Time.parse('2012-10-14 00:00:00') }
10
- let(:delivery) { Rapns::Daemon::Gcm::Delivery.new(app, http, notification) }
11
- let(:store) { stub(:mark_failed => nil, :mark_delivered => nil, :retry_after => nil, :create_gcm_notification => stub(:id => 2)) }
10
+ let(:batch) { double(:mark_failed => nil, :mark_delivered => nil, :mark_retryable => nil) }
11
+ let(:delivery) { Rapns::Daemon::Gcm::Delivery.new(app, http, notification, batch) }
12
+ let(:store) { double(:create_gcm_notification => double(:id => 2)) }
12
13
 
13
14
  def perform
14
15
  delivery.perform
@@ -21,6 +22,35 @@ describe Rapns::Daemon::Gcm::Delivery do
21
22
  Rapns.stub(:logger => logger)
22
23
  end
23
24
 
25
+ shared_examples_for 'an notification with some delivery failures' do
26
+ let(:new_notification) { Rapns::Gcm::Notification.where('id != ?', notification.id).first }
27
+
28
+ before { response.stub(:body => JSON.dump(body)) }
29
+
30
+ it 'marks the original notification as failed' do
31
+ batch.should_receive(:mark_failed).with(notification, nil, error_description)
32
+ perform rescue Rapns::DeliveryError
33
+ end
34
+
35
+ it 'reflects the notification delivery failed' do
36
+ delivery.should_receive(:reflect).with(:notification_failed, notification)
37
+ perform rescue Rapns::DeliveryError
38
+ end
39
+
40
+ it 'creates a new notification for the unavailable devices' do
41
+ notification.update_attributes(:registration_ids => ['id_0', 'id_1', 'id_2'], :data => {'one' => 1}, :collapse_key => 'thing', :delay_while_idle => true)
42
+ response.stub(:header => { 'retry-after' => 10 })
43
+ attrs = { 'collapse_key' => 'thing', 'delay_while_idle' => true, 'app_id' => app.id }
44
+ store.should_receive(:create_gcm_notification).with(attrs, notification.data,
45
+ ['id_0', 'id_2'], now + 10.seconds, notification.app)
46
+ perform rescue Rapns::DeliveryError
47
+ end
48
+
49
+ it 'raises a DeliveryError' do
50
+ expect { perform }.to raise_error(Rapns::DeliveryError)
51
+ end
52
+ end
53
+
24
54
  describe 'an 200 response' do
25
55
  before do
26
56
  response.stub(:code => 200)
@@ -28,7 +58,7 @@ describe Rapns::Daemon::Gcm::Delivery do
28
58
 
29
59
  it 'marks the notification as delivered if delivered successfully to all devices' do
30
60
  response.stub(:body => JSON.dump({ 'failure' => 0 }))
31
- store.should_receive(:mark_delivered).with(notification)
61
+ batch.should_receive(:mark_delivered).with(notification)
32
62
  perform
33
63
  end
34
64
 
@@ -53,7 +83,7 @@ describe Rapns::Daemon::Gcm::Delivery do
53
83
  { 'error' => 'NotRegistered' }
54
84
  ]}
55
85
  response.stub(:body => JSON.dump(body))
56
- store.should_receive(:mark_failed).with(notification, nil, "Failed to deliver to all recipients. Errors: NotRegistered.")
86
+ batch.should_receive(:mark_failed).with(notification, nil, "Failed to deliver to all recipients. Errors: NotRegistered.")
57
87
  perform rescue Rapns::DeliveryError
58
88
  end
59
89
 
@@ -87,17 +117,17 @@ describe Rapns::Daemon::Gcm::Delivery do
87
117
 
88
118
  it 'retries the notification respecting the Retry-After header' do
89
119
  response.stub(:header => { 'retry-after' => 10 })
90
- store.should_receive(:retry_after).with(notification, now + 10.seconds)
120
+ batch.should_receive(:mark_retryable).with(notification, now + 10.seconds)
91
121
  perform
92
122
  end
93
123
 
94
124
  it 'retries the notification using exponential back-off if the Retry-After header is not present' do
95
- store.should_receive(:retry_after).with(notification, now + 2)
125
+ batch.should_receive(:mark_retryable).with(notification, now + 2)
96
126
  perform
97
127
  end
98
128
 
99
129
  it 'does not mark the notification as failed' do
100
- store.should_not_receive(:mark_failed)
130
+ batch.should_not_receive(:mark_failed)
101
131
  perform
102
132
  end
103
133
 
@@ -115,7 +145,7 @@ describe Rapns::Daemon::Gcm::Delivery do
115
145
  before { response.stub(:body => JSON.dump(body)) }
116
146
 
117
147
  it 'marks the original notification as failed' do
118
- store.should_receive(:mark_failed).with(notification, nil, error_description)
148
+ batch.should_receive(:mark_failed).with(notification, nil, error_description)
119
149
  perform rescue Rapns::DeliveryError
120
150
  end
121
151
 
@@ -177,18 +207,18 @@ describe Rapns::Daemon::Gcm::Delivery do
177
207
 
178
208
  it 'respects an integer Retry-After header' do
179
209
  response.stub(:header => { 'retry-after' => 10 })
180
- store.should_receive(:retry_after).with(notification, now + 10.seconds)
210
+ batch.should_receive(:mark_retryable).with(notification, now + 10.seconds)
181
211
  perform
182
212
  end
183
213
 
184
214
  it 'respects a HTTP-date Retry-After header' do
185
215
  response.stub(:header => { 'retry-after' => 'Wed, 03 Oct 2012 20:55:11 GMT' })
186
- store.should_receive(:retry_after).with(notification, Time.parse('Wed, 03 Oct 2012 20:55:11 GMT'))
216
+ batch.should_receive(:mark_retryable).with(notification, Time.parse('Wed, 03 Oct 2012 20:55:11 GMT'))
187
217
  perform
188
218
  end
189
219
 
190
220
  it 'defaults to exponential back-off if the Retry-After header is not present' do
191
- store.should_receive(:retry_after).with(notification, now + 2 ** 1)
221
+ batch.should_receive(:mark_retryable).with(notification, now + 2 ** 1)
192
222
  perform
193
223
  end
194
224
 
@@ -212,7 +242,7 @@ describe Rapns::Daemon::Gcm::Delivery do
212
242
  end
213
243
 
214
244
  it 'retries the notification in accordance with the exponential back-off strategy.' do
215
- store.should_receive(:retry_after).with(notification, now + 2 ** 3)
245
+ batch.should_receive(:mark_retryable).with(notification, now + 2 ** 3)
216
246
  perform
217
247
  end
218
248
 
@@ -234,7 +264,7 @@ describe Rapns::Daemon::Gcm::Delivery do
234
264
  before { response.stub(:code => 400) }
235
265
 
236
266
  it 'marks the notification as failed' do
237
- store.should_receive(:mark_failed).with(notification, 400, 'GCM failed to parse the JSON request. Possibly an rapns bug, please open an issue.')
267
+ batch.should_receive(:mark_failed).with(notification, 400, 'GCM failed to parse the JSON request. Possibly an rapns bug, please open an issue.')
238
268
  perform rescue Rapns::DeliveryError
239
269
  end
240
270
 
@@ -248,7 +278,7 @@ describe Rapns::Daemon::Gcm::Delivery do
248
278
  before { response.stub(:code => 418) }
249
279
 
250
280
  it 'marks the notification as failed' do
251
- store.should_receive(:mark_failed).with(notification, 418, "I'm a Teapot")
281
+ batch.should_receive(:mark_failed).with(notification, 418, "I'm a Teapot")
252
282
  perform rescue Rapns::DeliveryError
253
283
  end
254
284
 
@@ -5,8 +5,8 @@ describe Rapns::Daemon::InterruptibleSleep do
5
5
  extend Rapns::Daemon::InterruptibleSleep
6
6
  end
7
7
 
8
- let(:rd) { stub(:close => nil) }
9
- let(:wr) { stub(:close => nil) }
8
+ let(:rd) { double(:close => nil) }
9
+ let(:wr) { double(:close => nil) }
10
10
 
11
11
  before do
12
12
  IO.stub(:pipe)
@@ -37,4 +37,4 @@ describe Rapns::Daemon::InterruptibleSleep do
37
37
  wr.should_receive(:close)
38
38
  SleepTest.interrupt_sleep
39
39
  end
40
- end
40
+ end
@@ -5,7 +5,7 @@ describe Rapns::Daemon::Reflectable do
5
5
  include Rapns::Daemon::Reflectable
6
6
  end
7
7
 
8
- let(:logger) { stub(:error => nil) }
8
+ let(:logger) { double(:error => nil) }
9
9
  let(:test_reflectable) { TestReflectable.new }
10
10
 
11
11
  before do
@@ -43,7 +43,7 @@ describe Rapns::Daemon::Store::ActiveRecord::Reconnectable do
43
43
  let(:test_double) { TestDouble.new(error, 1) }
44
44
 
45
45
  before do
46
- @logger = mock("Logger", :info => nil, :error => nil, :warn => nil)
46
+ @logger = double("Logger", :info => nil, :error => nil, :warn => nil)
47
47
  Rapns.stub(:logger).and_return(@logger)
48
48
 
49
49
  ActiveRecord::Base.stub(:clear_all_connections!)
@@ -5,10 +5,15 @@ describe Rapns::Daemon::Store::ActiveRecord do
5
5
  let(:app) { Rapns::Apns::App.create!(:name => 'my_app', :environment => 'development', :certificate => TEST_CERT) }
6
6
  let(:notification) { Rapns::Apns::Notification.create!(:device_token => "a" * 64, :app => app) }
7
7
  let(:store) { Rapns::Daemon::Store::ActiveRecord.new }
8
- let(:now) { Time.now }
8
+ let(:now) { Time.now.utc }
9
9
 
10
10
  before { Time.stub(:now => now) }
11
11
 
12
+ it 'reconnects after daemonize' do
13
+ store.should_receive(:reconnect_database)
14
+ store.after_daemonize
15
+ end
16
+
12
17
  describe 'deliverable_notifications' do
13
18
  it 'checks for new notifications with the ability to reconnect the database' do
14
19
  store.should_receive(:with_database_reconnect_and_retry)
@@ -18,7 +23,7 @@ describe Rapns::Daemon::Store::ActiveRecord do
18
23
  it 'loads notifications in batches' do
19
24
  Rapns.config.batch_size = 5000
20
25
  Rapns.config.push = false
21
- relation = stub.as_null_object
26
+ relation = double.as_null_object
22
27
  relation.should_receive(:limit).with(5000)
23
28
  Rapns::Notification.stub(:ready_for_delivery => relation)
24
29
  store.deliverable_notifications([app])
@@ -26,7 +31,7 @@ describe Rapns::Daemon::Store::ActiveRecord do
26
31
 
27
32
  it 'does not load notification in batches if in push mode' do
28
33
  Rapns.config.push = true
29
- relation = stub.as_null_object
34
+ relation = double.as_null_object
30
35
  relation.should_not_receive(:limit)
31
36
  Rapns::Notification.stub(:ready_for_delivery => relation)
32
37
  store.deliverable_notifications([app])
@@ -63,23 +68,40 @@ describe Rapns::Daemon::Store::ActiveRecord do
63
68
  end
64
69
  end
65
70
 
66
- describe 'retry_after' do
71
+ describe 'mark_retryable' do
67
72
  it 'increments the retry count' do
68
73
  expect do
69
- store.retry_after(notification, now)
74
+ store.mark_retryable(notification, now)
70
75
  end.to change(notification, :retries).by(1)
71
76
  end
72
77
 
73
78
  it 'sets the deliver after timestamp' do
74
79
  deliver_after = now + 10.seconds
75
80
  expect do
76
- store.retry_after(notification, deliver_after)
81
+ store.mark_retryable(notification, deliver_after)
77
82
  end.to change(notification, :deliver_after).to(deliver_after)
78
83
  end
79
84
 
80
85
  it 'saves the notification without validation' do
81
86
  notification.should_receive(:save!).with(:validate => false)
82
- store.retry_after(notification, now)
87
+ store.mark_retryable(notification, now)
88
+ end
89
+ end
90
+
91
+ describe 'mark_batch_retryable' do
92
+ it 'increments the retired count' do
93
+ expect do
94
+ store.mark_batch_retryable([notification], now)
95
+ notification.reload
96
+ end.to change(notification, :retries).by(1)
97
+ end
98
+
99
+ it 'sets the deliver after timestamp' do
100
+ deliver_after = now + 10.seconds
101
+ expect do
102
+ store.mark_batch_retryable([notification], deliver_after)
103
+ notification.reload
104
+ end.to change { notification.deliver_after.try(:utc).to_s }.to(deliver_after.utc.to_s)
83
105
  end
84
106
  end
85
107
 
@@ -93,7 +115,8 @@ describe Rapns::Daemon::Store::ActiveRecord do
93
115
  it 'sets the time the notification was delivered' do
94
116
  expect do
95
117
  store.mark_delivered(notification)
96
- end.to change(notification, :delivered_at).to(now)
118
+ notification.reload
119
+ end.to change { notification.delivered_at.try(:utc).to_s }.to(now.to_s)
97
120
  end
98
121
 
99
122
  it 'saves the notification without validation' do
@@ -102,6 +125,22 @@ describe Rapns::Daemon::Store::ActiveRecord do
102
125
  end
103
126
  end
104
127
 
128
+ describe 'mark_batch_delivered' do
129
+ it 'marks the notifications as delivered' do
130
+ expect do
131
+ store.mark_batch_delivered([notification])
132
+ notification.reload
133
+ end.to change(notification, :delivered).to(true)
134
+ end
135
+
136
+ it 'sets the time the notifications were delivered' do
137
+ expect do
138
+ store.mark_batch_delivered([notification])
139
+ notification.reload
140
+ end.to change { notification.delivered_at.try(:utc).to_s }.to(now.to_s)
141
+ end
142
+ end
143
+
105
144
  describe 'mark_failed' do
106
145
  it 'marks the notification as not delivered' do
107
146
  store.mark_failed(notification, nil, '')
@@ -111,13 +150,15 @@ describe Rapns::Daemon::Store::ActiveRecord do
111
150
  it 'marks the notification as failed' do
112
151
  expect do
113
152
  store.mark_failed(notification, nil, '')
153
+ notification.reload
114
154
  end.to change(notification, :failed).to(true)
115
155
  end
116
156
 
117
157
  it 'sets the time the notification delivery failed' do
118
158
  expect do
119
159
  store.mark_failed(notification, nil, '')
120
- end.to change(notification, :failed_at).to(now)
160
+ notification.reload
161
+ end.to change { notification.failed_at.try(:utc).to_s }.to(now.to_s)
121
162
  end
122
163
 
123
164
  it 'sets the error code' do
@@ -138,6 +179,42 @@ describe Rapns::Daemon::Store::ActiveRecord do
138
179
  end
139
180
  end
140
181
 
182
+ describe 'mark_batch_failed' do
183
+ it 'marks the notification as not delivered' do
184
+ store.mark_batch_failed([notification], nil, '')
185
+ notification.reload
186
+ notification.delivered.should be_false
187
+ end
188
+
189
+ it 'marks the notification as failed' do
190
+ expect do
191
+ store.mark_batch_failed([notification], nil, '')
192
+ notification.reload
193
+ end.to change(notification, :failed).to(true)
194
+ end
195
+
196
+ it 'sets the time the notification delivery failed' do
197
+ expect do
198
+ store.mark_batch_failed([notification], nil, '')
199
+ notification.reload
200
+ end.to change { notification.failed_at.try(:utc).to_s }.to(now.to_s)
201
+ end
202
+
203
+ it 'sets the error code' do
204
+ expect do
205
+ store.mark_batch_failed([notification], 42, '')
206
+ notification.reload
207
+ end.to change(notification, :error_code).to(42)
208
+ end
209
+
210
+ it 'sets the error description' do
211
+ expect do
212
+ store.mark_batch_failed([notification], 42, 'Weeee')
213
+ notification.reload
214
+ end.to change(notification, :error_description).to('Weeee')
215
+ end
216
+ end
217
+
141
218
  describe 'create_apns_feedback' do
142
219
  it 'creates the Feedback record' do
143
220
  Rapns::Apns::Feedback.should_receive(:create!).with(
@@ -170,7 +247,7 @@ describe Rapns::Daemon::Store::ActiveRecord do
170
247
 
171
248
  it 'sets the deliver_after timestamp' do
172
249
  new_notification = store.create_gcm_notification(*args)
173
- new_notification.deliver_after.should == deliver_after
250
+ new_notification.deliver_after.to_s.should == deliver_after.to_s
174
251
  end
175
252
 
176
253
  it 'saves the new notification' do
@@ -4,12 +4,12 @@ require 'rapns/daemon/store/active_record'
4
4
  describe Rapns::Daemon, "when starting" do
5
5
  module Rails; end
6
6
 
7
- let(:certificate) { stub }
8
- let(:password) { stub }
9
- let(:config) { stub(:pid_file => nil, :airbrake_notify => false,
7
+ let(:certificate) { double }
8
+ let(:password) { double }
9
+ let(:config) { double(:pid_file => nil, :airbrake_notify => false,
10
10
  :foreground => true, :embedded => false, :push => false,
11
11
  :store => :active_record, :logger => nil) }
12
- let(:logger) { stub(:logger, :info => nil, :error => nil, :warn => nil) }
12
+ let(:logger) { double(:logger, :info => nil, :error => nil, :warn => nil) }
13
13
 
14
14
  before do
15
15
  Rapns.stub(:config => config, :logger => logger)
@@ -102,8 +102,8 @@ describe Rapns::Daemon, "when starting" do
102
102
  end
103
103
 
104
104
  describe Rapns::Daemon, "when being shutdown" do
105
- let(:config) { stub(:pid_file => '/rails_root/rapns.pid') }
106
- let(:logger) { stub(:info => nil, :error => nil, :warn => nil) }
105
+ let(:config) { double(:pid_file => '/rails_root/rapns.pid') }
106
+ let(:logger) { double(:info => nil, :error => nil, :warn => nil) }
107
107
 
108
108
  before do
109
109
  Rapns.stub(:config => config)