mercurius 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bec5b859eb19a5440358662bc0a93f3ac208954
4
- data.tar.gz: f1be876675c15d94f4e01d56a4433dd1c5e41117
3
+ metadata.gz: ac98854864ddc1b93cb4765942c671f0ae00ddeb
4
+ data.tar.gz: fb659a89604e5603ed1b2e65a1f84ffb08d772ee
5
5
  SHA512:
6
- metadata.gz: c1abbe942330a73eda1e16f5c7e5aed2eacd73900141b022de13af35a5e76de8b7a587ed4750715d0f138a97824c5e4e21c6dd56b8ffdfbb76544ea132d3570a
7
- data.tar.gz: f74f921cb62b2d36e73cc18a914df59e8c8a3e5f36204cb917f86cda18f392f507dd83571f6062f3570ea833e4db6f4e8e5531df58fc5c528402e24edd9bc6d0
6
+ metadata.gz: 7ae8af9b0438937b48bbb6aa770bf695d26c79977b3e44fb9217bde3c5cbc60890085ecbd45fcb58ee65af3a23f54f20c3e68414ee8ac79b6639f2605f6d018b
7
+ data.tar.gz: b5eae17438b8408084672cbefb36047d15149dce3a51183cdb5f1accb8f90874592f6b5cbabb315a49fd9b3005b4408b5d60782b777ddab2af32637f1533f9d1
@@ -0,0 +1,21 @@
1
+ module Mercurius
2
+ module Testing
3
+ class Base
4
+
5
+ def self.deliveries
6
+ @@deliveries ||= []
7
+ end
8
+
9
+ def self.reset
10
+ @@deliveries = []
11
+ end
12
+
13
+ def self.deliveries_to(device_token)
14
+ deliveries.select do |delivery|
15
+ delivery.device_tokens.include? device_token
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ module Mercurius
2
+ module Testing
3
+ class Delivery < Struct.new(:notification, :device_tokens)
4
+ end
5
+ end
6
+ end
@@ -2,26 +2,8 @@ module Mercurius
2
2
  module Testing
3
3
  module Service
4
4
 
5
- class Delivery < Struct.new(:notification, :device_tokens)
6
- end
7
-
8
5
  def deliver(notification, *device_tokens)
9
- @deliveries ||= []
10
- @deliveries << Delivery.new(notification, Array(device_tokens).flatten)
11
- end
12
-
13
- def deliveries
14
- @deliveries
15
- end
16
-
17
- def notifications_to(device_token)
18
- deliveries_to(device_token).map(&:notification)
19
- end
20
-
21
- def deliveries_to(device_token)
22
- deliveries.select do |delivery|
23
- delivery.device_tokens.include? device_token
24
- end
6
+ Mercurius::Testing::Base.deliveries << Mercurius::Testing::Delivery.new(notification, Array(device_tokens).flatten)
25
7
  end
26
8
 
27
9
  end
@@ -1,3 +1,3 @@
1
1
  module Mercurius
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require File.expand_path('../../../lib/mercurius/testing/service', __FILE__)
2
+ require File.expand_path('../../../lib/mercurius/testing/base', __FILE__)
3
+ require File.expand_path('../../../lib/mercurius/testing/delivery', __FILE__)
2
4
 
3
5
  describe 'Test mode' do
4
6
 
@@ -10,13 +12,17 @@ describe 'Test mode' do
10
12
  include Mercurius::Testing::Service
11
13
  end
12
14
 
15
+ after do
16
+ Mercurius::Testing::Base.reset
17
+ end
18
+
13
19
  context 'GCM' do
14
20
  let(:service) { GCM::MockService.new }
15
21
  let(:message) { GCM::Notification.new(alert: 'Hey') }
16
22
 
17
23
  it 'returns the deliveries sent to GCM' do
18
24
  service.deliver message, 'token123'
19
- delivery = service.deliveries[0]
25
+ delivery = Mercurius::Testing::Base.deliveries[0]
20
26
  expect(delivery.device_tokens).to include 'token123'
21
27
  expect(delivery.notification.data).to eq Hash[alert: 'Hey']
22
28
  end
@@ -28,7 +34,7 @@ describe 'Test mode' do
28
34
 
29
35
  it 'returns the deliveries sent to APNS' do
30
36
  service.deliver message, 'token123'
31
- delivery = service.deliveries[0]
37
+ delivery = Mercurius::Testing::Base.deliveries[0]
32
38
  expect(delivery.device_tokens).to include 'token123'
33
39
  expect(delivery.notification.alert).to eq 'Hey'
34
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercurius
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Beck
@@ -155,6 +155,8 @@ files:
155
155
  - lib/mercurius/gcm/result.rb
156
156
  - lib/mercurius/gcm/service.rb
157
157
  - lib/mercurius/testing.rb
158
+ - lib/mercurius/testing/base.rb
159
+ - lib/mercurius/testing/delivery.rb
158
160
  - lib/mercurius/testing/service.rb
159
161
  - lib/mercurius/version.rb
160
162
  - mercurius.gemspec