mercurius 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mercurius/testing/base.rb +21 -0
- data/lib/mercurius/testing/delivery.rb +6 -0
- data/lib/mercurius/testing/service.rb +1 -19
- data/lib/mercurius/version.rb +1 -1
- data/spec/lib/testing_spec.rb +8 -2
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac98854864ddc1b93cb4765942c671f0ae00ddeb
|
4
|
+
data.tar.gz: fb659a89604e5603ed1b2e65a1f84ffb08d772ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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
|
-
|
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
|
data/lib/mercurius/version.rb
CHANGED
data/spec/lib/testing_spec.rb
CHANGED
@@ -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 =
|
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 =
|
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.
|
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
|