message-driver 0.2.0.rc2 → 0.2.0
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/.travis.yml +1 -2
- data/CHANGELOG.md +7 -0
- data/Guardfile +2 -2
- data/features/CHANGELOG.md +7 -0
- data/features/message_consumers/subscribe_with_a_block.feature +50 -0
- data/lib/message_driver/adapters/bunny_adapter.rb +2 -2
- data/lib/message_driver/client.rb +5 -1
- data/lib/message_driver/version.rb +1 -1
- data/spec/integration/bunny/bunny_adapter_spec.rb +3 -3
- data/spec/units/message_driver/client_spec.rb +41 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9f0a7a7dd768f5bf8af2020720c7bf6a5f550d
|
4
|
+
data.tar.gz: daafbfc5b67b2eb79c562e490dbc4516ac8bb8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e788da60c674485779dc4a910cc6e88a8a7e8bcbbe2d53c63b63b150d56ea4a91eea7c673dbe4e80fa6dd3532a773d054b05fceacc6c8ae46b3c6737f1b09ec8
|
7
|
+
data.tar.gz: 5694fa3975c55b9e610e8028f2e61402e6925402210188d78c5a02e41120365fc42de2567a7c89e21f88134ab6609f7174ac96cc23ecbb06ed3bc8c9191c30e0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Guardfile
CHANGED
@@ -9,8 +9,8 @@ guard 'bundler' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
common_rspec_opts = {keep_failed: true, all_after_pass: true}
|
12
|
-
unit_spec_opts = common_rspec_opts.merge({spec_paths: ["spec/units"],
|
13
|
-
integration_spec_opts = common_rspec_opts.merge({spec_paths: ["spec/integration/#{BrokerConfig.current_adapter}"],
|
12
|
+
unit_spec_opts = common_rspec_opts.merge({spec_paths: ["spec/units"], cmd: 'rspec -f doc', run_all: {cmd: 'rspec'}})
|
13
|
+
integration_spec_opts = common_rspec_opts.merge({spec_paths: ["spec/integration/#{BrokerConfig.current_adapter}"], cmd: 'rspec -f doc -t all_adapters', run_all: {cmd: 'rspec -t all_adapters'}})
|
14
14
|
|
15
15
|
group 'specs' do
|
16
16
|
guard 'rspec', unit_spec_opts do
|
data/features/CHANGELOG.md
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
@in_memory
|
2
|
+
@bunny
|
3
|
+
Feature: Subscribing a Consumer with a block
|
4
|
+
Background:
|
5
|
+
Given I am connected to the broker
|
6
|
+
And I have a destination :dest_queue with no messages on it
|
7
|
+
And I have a destination :source_queue with no messages on it
|
8
|
+
And I create a subscription
|
9
|
+
"""ruby
|
10
|
+
MessageDriver::Client.subscribe_with(:source_queue) do |message|
|
11
|
+
MessageDriver::Client.publish(:dest_queue, message.body)
|
12
|
+
end
|
13
|
+
"""
|
14
|
+
|
15
|
+
|
16
|
+
Scenario: Consuming Messages
|
17
|
+
When I send the following messages to :source_queue
|
18
|
+
| body |
|
19
|
+
| Test Message 1 |
|
20
|
+
| Test Message 2 |
|
21
|
+
And I let the subscription process
|
22
|
+
|
23
|
+
Then I expect to find no messages on :source_queue
|
24
|
+
And I expect to find the following 2 messages on :dest_queue
|
25
|
+
| body |
|
26
|
+
| Test Message 1 |
|
27
|
+
| Test Message 2 |
|
28
|
+
|
29
|
+
|
30
|
+
Scenario: Ending a subscription
|
31
|
+
When I send the following messages to :source_queue
|
32
|
+
| body |
|
33
|
+
| Test Message 1 |
|
34
|
+
| Test Message 2 |
|
35
|
+
And I allow for processing
|
36
|
+
And I cancel the subscription
|
37
|
+
And I send the following messages to :source_queue
|
38
|
+
| body |
|
39
|
+
| Test Message 3 |
|
40
|
+
| Test Message 4 |
|
41
|
+
|
42
|
+
Then I expect to find the following 2 messages on :dest_queue
|
43
|
+
| body |
|
44
|
+
| Test Message 1 |
|
45
|
+
| Test Message 2 |
|
46
|
+
|
47
|
+
And I expect to find the following 2 messages on :source_queue
|
48
|
+
| body |
|
49
|
+
| Test Message 3 |
|
50
|
+
| Test Message 4 |
|
@@ -399,10 +399,10 @@ module MessageDriver
|
|
399
399
|
private
|
400
400
|
|
401
401
|
def validate_bunny_version
|
402
|
-
required = Gem::Requirement.create('>= 0.
|
402
|
+
required = Gem::Requirement.create('>= 0.10.8')
|
403
403
|
current = Gem::Version.create(Bunny::VERSION)
|
404
404
|
unless required.satisfied_by? current
|
405
|
-
raise MessageDriver::Error, "bunny 0.
|
405
|
+
raise MessageDriver::Error, "bunny 0.10.8 or later is required for the bunny adapter"
|
406
406
|
end
|
407
407
|
end
|
408
408
|
end
|
@@ -16,8 +16,12 @@ module MessageDriver
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def subscribe(destination_name, consumer_name, options={})
|
19
|
-
destination = find_destination(destination_name)
|
20
19
|
consumer = find_consumer(consumer_name)
|
20
|
+
subscribe_with(destination_name, options, &consumer)
|
21
|
+
end
|
22
|
+
|
23
|
+
def subscribe_with(destination_name, options={}, &consumer)
|
24
|
+
destination = find_destination(destination_name)
|
21
25
|
current_adapter_context.subscribe(destination, options, &consumer)
|
22
26
|
end
|
23
27
|
|
@@ -14,7 +14,7 @@ module MessageDriver::Adapters
|
|
14
14
|
stub_const("Bunny::VERSION", version)
|
15
15
|
expect {
|
16
16
|
described_class.new(valid_connection_attrs)
|
17
|
-
}.to raise_error MessageDriver::Error, "bunny 0.
|
17
|
+
}.to raise_error MessageDriver::Error, "bunny 0.10.8 or later is required for the bunny adapter"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
shared_examples "doesn't raise an error" do
|
@@ -26,13 +26,13 @@ module MessageDriver::Adapters
|
|
26
26
|
}.to_not raise_error
|
27
27
|
end
|
28
28
|
end
|
29
|
-
%w(0.8.0 0.9.0.pre11 0.9.0.rc1 0.9.0 0.9.2).each do |v|
|
29
|
+
%w(0.8.0 0.9.0.pre11 0.9.0.rc1 0.9.0 0.9.2 0.9.8 0.10.7).each do |v|
|
30
30
|
context "bunny version #{v}" do
|
31
31
|
let(:version) { v }
|
32
32
|
include_examples "raises an error"
|
33
33
|
end
|
34
34
|
end
|
35
|
-
%w(0.
|
35
|
+
%w(0.10.8 1.0.0 1.0.3).each do |v|
|
36
36
|
context "bunny version #{v}" do
|
37
37
|
let(:version) { v }
|
38
38
|
include_examples "doesn't raise an error"
|
@@ -359,6 +359,47 @@ module MessageDriver
|
|
359
359
|
end
|
360
360
|
end
|
361
361
|
end
|
362
|
+
|
363
|
+
describe "#subscribe_with" do
|
364
|
+
let(:destination) { Broker.destination(:my_queue, "my_queue", exclusive: true) }
|
365
|
+
let(:consumer_double) { lambda do |m| end }
|
366
|
+
|
367
|
+
before do
|
368
|
+
adapter_context.stub(:subscribe)
|
369
|
+
end
|
370
|
+
|
371
|
+
it "delegates to the adapter_context" do
|
372
|
+
adapter_context.should_receive(:subscribe).with(destination, {}) do |&blk|
|
373
|
+
expect(blk).to be(consumer_double)
|
374
|
+
end
|
375
|
+
subject.subscribe_with(destination, &consumer_double)
|
376
|
+
end
|
377
|
+
|
378
|
+
it "passes the options through" do
|
379
|
+
options = {foo: :bar}
|
380
|
+
adapter_context.should_receive(:subscribe).with(destination, options) do |&blk|
|
381
|
+
expect(blk).to be(consumer_double)
|
382
|
+
end
|
383
|
+
subject.subscribe_with(destination, options, &consumer_double)
|
384
|
+
end
|
385
|
+
|
386
|
+
it "looks up the destination" do
|
387
|
+
adapter_context.should_receive(:subscribe).with(destination, {}) do |&blk|
|
388
|
+
expect(blk).to be(consumer_double)
|
389
|
+
end
|
390
|
+
subject.subscribe_with(:my_queue, &consumer_double)
|
391
|
+
end
|
392
|
+
|
393
|
+
context "when the destination can't be found" do
|
394
|
+
let(:bad_dest_name) { :not_a_queue }
|
395
|
+
it "raises a MessageDriver:NoSuchDestinationError" do
|
396
|
+
expect {
|
397
|
+
subject.subscribe_with(bad_dest_name, &consumer_double)
|
398
|
+
}.to raise_error(MessageDriver::NoSuchDestinationError, /#{bad_dest_name}/)
|
399
|
+
adapter_context.should_not have_received(:subscribe)
|
400
|
+
end
|
401
|
+
end
|
402
|
+
end
|
362
403
|
end
|
363
404
|
end
|
364
405
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- features/message_consumers/auto_ack_consumers.feature
|
108
108
|
- features/message_consumers/manual_ack_consumers.feature
|
109
109
|
- features/message_consumers/prefetch_size.feature
|
110
|
+
- features/message_consumers/subscribe_with_a_block.feature
|
110
111
|
- features/message_consumers/transactional_ack_consumers.feature
|
111
112
|
- features/publishing_a_message.feature
|
112
113
|
- features/publishing_with_transactions.feature
|
@@ -176,9 +177,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
177
|
version: 1.9.2
|
177
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
179
|
requirements:
|
179
|
-
- - '
|
180
|
+
- - '>='
|
180
181
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
182
|
+
version: '0'
|
182
183
|
requirements: []
|
183
184
|
rubyforge_project:
|
184
185
|
rubygems_version: 2.0.3
|
@@ -206,6 +207,7 @@ test_files:
|
|
206
207
|
- features/message_consumers/auto_ack_consumers.feature
|
207
208
|
- features/message_consumers/manual_ack_consumers.feature
|
208
209
|
- features/message_consumers/prefetch_size.feature
|
210
|
+
- features/message_consumers/subscribe_with_a_block.feature
|
209
211
|
- features/message_consumers/transactional_ack_consumers.feature
|
210
212
|
- features/publishing_a_message.feature
|
211
213
|
- features/publishing_with_transactions.feature
|