philotic 1.1.0 → 1.1.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 +4 -4
- data/lib/philotic/subscriber.rb +1 -1
- data/lib/philotic/version.rb +1 -1
- data/spec/philotic/subscriber_spec.rb +27 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5aa6de95d72e998edad55939b1b194101189c96
|
4
|
+
data.tar.gz: b1972e32e338076a218f18f96a32ca9150cb0ca1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a3fc577e42079e2747e72b13905a831f1bdbccdfd7bbd6dae815e1fcb013fd1e8ee7e37d68444f4a773bea2c9005884c4f44d4be77ac20bae32de147f21a0a7
|
7
|
+
data.tar.gz: 10075f5fd0473498dae8b45ea57eca725ffa48909eedb203cf31d9a8bcd7acb1a5f6b4642f275b313ccbb7f1a6f116ff0241b08b490187563357757461000cf0
|
data/lib/philotic/subscriber.rb
CHANGED
@@ -22,7 +22,7 @@ module Philotic
|
|
22
22
|
lambda do |delivery_info, metadata, payload|
|
23
23
|
hash_payload = JSON.parse payload
|
24
24
|
|
25
|
-
message = Philotic::Message.new(metadata[:headers], hash_payload)
|
25
|
+
message = Class.new(Philotic::Message).new(metadata[:headers], hash_payload)
|
26
26
|
message.delivery_info = delivery_info
|
27
27
|
|
28
28
|
instance_exec(message, &block)
|
data/lib/philotic/version.rb
CHANGED
@@ -8,15 +8,34 @@ require 'philotic/subscriber'
|
|
8
8
|
describe Philotic::Subscriber do
|
9
9
|
|
10
10
|
|
11
|
+
describe '#subscription_callback' do
|
12
|
+
|
13
|
+
subject { Philotic::Connection.new.subscriber }
|
14
|
+
let(:subscribe_callback) do
|
15
|
+
Proc.new do |message|
|
16
|
+
message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:delivery_info) { double }
|
21
|
+
let(:metadata) { {headers: {header_1: 'foo'}} }
|
22
|
+
let(:payload) { {message: 'body'} }
|
23
|
+
|
24
|
+
it 'hydrates received messages' do
|
25
|
+
message = subject.subscription_callback(&subscribe_callback).call(delivery_info, metadata, payload.to_json)
|
26
|
+
expect(message).to be_a Philotic::Message
|
27
|
+
expect(message.headers).to include(metadata[:headers])
|
28
|
+
expect(message.payload).to eq payload
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
11
32
|
describe '#subscribe' do
|
12
33
|
let(:subscription) { 'some_queue' }
|
13
34
|
subject { Philotic::Connection.new.subscriber }
|
14
35
|
context 'when options is a string' do
|
15
36
|
it 'binds to a queue defined by the options' do
|
16
|
-
|
17
|
-
|
18
|
-
channel = double
|
19
|
-
queue = double
|
37
|
+
channel = double
|
38
|
+
queue = double
|
20
39
|
|
21
40
|
metadata = double
|
22
41
|
message = double
|
@@ -41,7 +60,7 @@ describe Philotic::Subscriber do
|
|
41
60
|
context 'when options is not a string' do
|
42
61
|
let(:subscription) do
|
43
62
|
{
|
44
|
-
|
63
|
+
firehose: true
|
45
64
|
}
|
46
65
|
end
|
47
66
|
it 'binds to a queue defined by the options' do
|
@@ -75,9 +94,9 @@ describe Philotic::Subscriber do
|
|
75
94
|
describe '#subscribe_to_any' do
|
76
95
|
let(:headers) do
|
77
96
|
{
|
78
|
-
|
79
|
-
|
80
|
-
|
97
|
+
header1: 'h1',
|
98
|
+
header2: 'h2',
|
99
|
+
header3: 'h3',
|
81
100
|
}
|
82
101
|
end
|
83
102
|
subject { Philotic::Connection.new.subscriber }
|