stapfen 2.2.1-java → 3.0.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.
@@ -1,10 +1,11 @@
1
1
  require 'spec_helper'
2
-
2
+ require 'hermann/consumer'
3
3
  require 'stapfen/client/kafka'
4
4
 
5
+
5
6
  describe Stapfen::Client::Kafka, :java => true do
6
- let(:config) { { :topic => 'test', :groupId => 'groupId', :zookeepers => 'foo' } }
7
- let(:consumer) { double('Hermann::Consumer') }
7
+ let(:config) { { :topic => 'test', :groupId => 'groupId', :zookeepers => 'foo' } }
8
+ let(:consumer) { double('Hermann::Consumer') }
8
9
 
9
10
  subject(:client) { described_class.new(config) }
10
11
 
@@ -14,10 +15,20 @@ describe Stapfen::Client::Kafka, :java => true do
14
15
 
15
16
  it { should respond_to :connect }
16
17
 
17
-
18
18
  describe '#initialize' do
19
19
  context 'with valid input params' do
20
+ let(:hermann_opts) { { :do_retry => false } }
21
+ let(:opts) { { :consumer_opts => hermann_opts } }
22
+ let(:config_with_opts) { config.merge(opts) }
23
+
24
+ subject(:client) { described_class.new(config_with_opts) }
25
+
20
26
  it 'should be a object' do
27
+ expect(Hermann::Consumer).to receive(:new).with(
28
+ config[:topic],
29
+ config[:groupId],
30
+ config[:zookeepers],
31
+ hermann_opts)
21
32
  expect(client).to be_a described_class
22
33
  end
23
34
  end
@@ -53,6 +64,24 @@ describe Stapfen::Client::Kafka, :java => true do
53
64
  end
54
65
  end
55
66
 
67
+ describe '#closed?' do
68
+ subject(:result) { client.closed? }
69
+
70
+ context 'if a connection exists' do
71
+ before :each do
72
+ allow(client).to receive(:connection) { double('KAFKA::Connection') }
73
+ end
74
+ it { should be false }
75
+ end
76
+
77
+ context 'without a connection' do
78
+ before :each do
79
+ allow(client).to receive(:connection) { nil }
80
+ end
81
+ it { should be true }
82
+ end
83
+ end
84
+
56
85
  describe '#subscribe' do
57
86
  let(:topic) { 'topic' }
58
87
  let(:destination) { double('Destination') }
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '../lib'))
2
2
 
3
+ # require 'pry'; binding.pry
3
4
  require 'stapfen'
4
5
  require 'rspec/its'
5
6
 
data/spec/worker_spec.rb CHANGED
@@ -1,273 +1,418 @@
1
1
  require 'spec_helper'
2
2
  require 'stapfen/client/stomp'
3
3
 
4
+ class ExampleWorker < Stapfen::Worker
5
+ end
6
+
4
7
  describe Stapfen::Worker do
5
- subject(:worker) { described_class.new }
6
8
 
7
- context 'class methods' do
8
- subject(:worker) { described_class }
9
+ after(:each) do
10
+ # These variables will persist between tests unless they're
11
+ # explicitly cleared. Also see `set_class_variable_defaults`.
12
+ described_class.set_class_variable_defaults
13
+ described_class.consumers = nil
14
+ if described_class.const_defined?(:RUBY_PLATFORM, false)
15
+ described_class.send(:remove_const, :RUBY_PLATFORM)
16
+ end
17
+ end
9
18
 
10
- it { should respond_to :run! }
11
- it { should respond_to :configure }
12
- it { should respond_to :consume }
13
- it { should respond_to :log }
14
- it { should respond_to :shutdown }
19
+ describe '.configure' do
20
+ let(:dummy_proc) { Proc.new { double('Proc') } }
21
+ let(:example_logger) { double('Logger') }
22
+ let(:example_protocol) { double('Protocol') }
23
+ let(:example_connection_options) { double('Connection Options') }
15
24
 
16
- describe '#use_stomp!' do
17
- subject(:result) { worker.use_stomp! }
25
+ it 'accepts a configuration block' do
26
+ ExampleWorker.configure &dummy_proc
27
+ expect(ExampleWorker.instance_configuration).to eq(dummy_proc)
28
+ end
29
+ end
18
30
 
19
- it 'should update the instance variable' do
20
- expect(result).to be true
21
- expect(worker).to be_stomp
22
- expect(worker).not_to be_jms
23
- end
31
+ describe '.run!' do
32
+ let(:dummy_instance) { double('Instance') }
33
+ it 'creates a new instance, handle signals, and call run' do
34
+ expect(ExampleWorker).to receive(:new).and_return dummy_instance
35
+ expect(ExampleWorker).to receive(:handle_signals)
36
+ expect(dummy_instance).to receive(:run)
37
+
38
+ ExampleWorker.run!
39
+
40
+ expect(ExampleWorker.class_variable_get(:@@workers)).to eq [dummy_instance]
24
41
  end
42
+ end
25
43
 
26
- describe '#use_jms!', :java => true do
27
- subject(:result) { worker.use_jms! }
44
+ describe '.consume(config_overrides={}, &block)' do
45
+ it 'adds the given block and config to @consumers array' do
46
+ example_proc = Proc.new {}
47
+ example_hash = double('hash')
48
+ described_class.consume(example_hash, &example_proc)
49
+ expect(described_class.consumers.first).to be_an(Array)
50
+ expect(described_class.consumers.first.first).to be example_hash
51
+ expect(described_class.consumers.first.last).to be example_proc
52
+ end
28
53
 
29
- after :each do
30
- # Reset to the default since we've modified the class
31
- worker.use_stomp!
32
- end
54
+ it 'raises a Stapfen::ConsumeError when called without a block' do
55
+ expect { described_class.consume }.to raise_error(Stapfen::ConsumeError)
56
+ end
57
+ end
33
58
 
34
- it 'should update the instance variable' do
35
- expect(result).to be true
36
- expect(worker).to be_jms
37
- expect(worker).not_to be_stomp
38
- end
59
+ describe '.shutdown(&block)' do
60
+ it 'sets @destructor' do
61
+ example_proc = Proc.new {}
62
+ described_class.shutdown &example_proc
63
+ expect(described_class.instance_variable_get(:@destructor)).to be(example_proc)
39
64
  end
65
+ end
40
66
 
41
- describe '#log' do
42
- it "should store the block it's passed" do
43
- logger = double('Mock Logger')
67
+ describe '.workers' do
68
+ it 'returns the array of workers' do
69
+ expect(described_class.workers).to eq([])
70
+ end
71
+ end
44
72
 
45
- worker.log do
46
- logger
47
- end
73
+ describe '.exit_cleanly' do
74
+ let(:example_worker) { double('ExWorker') }
48
75
 
49
- expect(worker.logger).to be_instance_of Proc
50
- end
76
+ it 'is false if no workers' do
77
+ expect(described_class.workers.empty?).to eq(true)
78
+ expect(described_class.exit_cleanly).to eq(false)
79
+ end
51
80
 
52
- after :each do
53
- worker.logger = nil
54
- end
81
+ it 'cleanly exits the worker and java environment' do
82
+ described_class.workers << example_worker
83
+ expect(Java::JavaLang::System).to receive(:exit).with(0)
84
+ expect(example_worker).to receive(:exit_cleanly)
85
+ expect(described_class.exit_cleanly).to eq(true)
55
86
  end
56
87
 
57
- describe '#configure' do
58
- let(:config) { {:valid => true} }
59
- it 'should error when not passed a block' do
60
- expect {
61
- worker.configure
62
- }.to raise_error(Stapfen::ConfigurationError)
63
- end
88
+ it 'cleanly exits just the worker when not java' do
89
+ described_class.const_set(:RUBY_PLATFORM, '*not java*')
90
+ described_class.workers << example_worker
91
+ expect(Java::JavaLang::System).to_not receive(:exit)
92
+ expect(example_worker).to receive(:exit_cleanly)
93
+ expect(described_class.exit_cleanly).to eq(true)
94
+ end
64
95
 
65
- it 'should save the return value from the block' do
66
- worker.configure do
67
- config
68
- end
69
- expect(worker.configuration.call).to eql(config)
70
- end
96
+ it 'is false if an exception is raised' do
97
+ expect(Java::JavaLang::System).to receive(:exit).with(0)
98
+ described_class.workers << example_worker
99
+ expect(example_worker).to receive(:exit_cleanly).and_raise(StandardError)
100
+ expect(described_class.exit_cleanly).to eq(false)
71
101
  end
102
+ end
72
103
 
73
- describe '#exit_cleanly', :java => true do
74
- subject(:result) { worker.exit_cleanly }
104
+ describe '.handle_signals' do
105
+ it 'traps INT and TERM' do
106
+ expect(Signal).to receive(:trap).with(:INT)
107
+ expect(Signal).to receive(:trap).with(:TERM)
108
+ described_class.handle_signals
109
+ end
110
+ end
75
111
 
76
- before do
77
- allow(Java::JavaLang::System).to receive(:exit).with(0)
78
- end
112
+ describe '#use_stomp!' do
113
+ it 'should require stomp' do
114
+ expect(subject).to receive(:require).with('stomp')
115
+ subject.use_stomp!
116
+ expect(subject.instance_variable_get(:@protocol)).to eq Stapfen::Worker::STOMP
117
+ end
79
118
 
80
- after do
81
- worker.class_variable_set(:@@workers, [])
119
+ it 'should raise a LoadError if require fails' do
120
+ expect(subject).to receive(:require).and_raise(LoadError)
121
+ expect { subject.use_stomp! }.to raise_error(LoadError)
122
+ end
123
+ end
124
+
125
+ describe '#stomp?' do
126
+ it 'is true when the protocol is stomp' do
127
+ subject.protocol = Stapfen::Worker::STOMP
128
+ expect(subject.stomp?).to be(true)
129
+ end
130
+
131
+ it 'is false when the protocol is anything else' do
132
+ subject.protocol = Stapfen::Worker::JMS
133
+ expect(subject.stomp?).to be(false)
134
+ end
135
+ end
136
+
137
+ describe '#use_jms!' do
138
+ it 'should require jms' do
139
+ described_class.const_set(:RUBY_PLATFORM, 'java')
140
+ expect(subject).to receive(:require).with('java')
141
+ expect(subject).to receive(:require).with('jms')
142
+ subject.use_jms!
143
+ expect(subject.instance_variable_get(:@protocol)).to eq Stapfen::Worker::JMS
144
+ end
145
+
146
+ it 'should raise a Stapfen::ConfigurationError if require fails' do
147
+ described_class.const_set(:RUBY_PLATFORM, '*not java*')
148
+ expect { subject.use_jms! }.to raise_error(Stapfen::ConfigurationError)
149
+ end
150
+
151
+ it 'should raise a LoadError if require fails' do
152
+ described_class.const_set(:RUBY_PLATFORM, 'java')
153
+ expect(subject).to receive(:require).and_raise(LoadError)
154
+ expect { subject.use_jms! }.to raise_error(LoadError)
155
+ end
156
+ end
157
+
158
+ describe '#jms?' do
159
+ it 'is true when the protocol is jms' do
160
+ subject.protocol = Stapfen::Worker::JMS
161
+ expect(subject.jms?).to be(true)
162
+ end
163
+
164
+ it 'is false when the protocol is anything else' do
165
+ subject.protocol = Stapfen::Worker::STOMP
166
+ expect(subject.jms?).to be(false)
167
+ end
168
+ end
169
+
170
+ describe '#use_kafka!' do
171
+ it 'should require kafka' do
172
+ described_class.const_set(:RUBY_PLATFORM, 'java')
173
+ expect(subject).to receive(:require).with('java')
174
+ expect(subject).to receive(:require).with('hermann')
175
+ subject.use_kafka!
176
+ expect(subject.instance_variable_get(:@protocol)).to eq Stapfen::Worker::KAFKA
177
+ end
178
+
179
+ it 'should raise a Stapfen::ConfigurationError if require fails' do
180
+ described_class.const_set(:RUBY_PLATFORM, '*not java*')
181
+ expect { subject.use_kafka! }.to raise_error(Stapfen::ConfigurationError)
182
+ end
183
+
184
+ it 'should raise a LoadError if require fails' do
185
+ described_class.const_set(:RUBY_PLATFORM, 'java')
186
+ expect(subject).to receive(:require).and_raise(LoadError)
187
+ expect { subject.use_kafka! }.to raise_error(LoadError)
188
+ end
189
+ end
190
+
191
+ describe '#kafka?' do
192
+ it 'is true when the protocol is kafka' do
193
+ subject.protocol = Stapfen::Worker::KAFKA
194
+ expect(subject.kafka?).to be(true)
195
+ end
196
+
197
+ it 'is false when the protocol is anything else' do
198
+ subject.protocol = Stapfen::Worker::JMS
199
+ expect(subject.kafka?).to be(false)
200
+ end
201
+ end
202
+
203
+ describe '#exit_cleanly' do
204
+ let(:stapfen_client) { double('RSpec Stomp Client') }
205
+
206
+ before :each do
207
+ subject.stub(:stapfen_client).and_return(stapfen_client)
208
+ end
209
+
210
+ it 'should close the stapfen_client' do
211
+ stapfen_client.stub(:closed?).and_return(false)
212
+ stapfen_client.should_receive(:close)
213
+ subject.exit_cleanly
214
+ end
215
+
216
+ context 'with out having connected a stapfen_client yet' do
217
+ before :each do
218
+ subject.stub(:stapfen_client).and_return(nil)
82
219
  end
83
220
 
84
- context 'with no worker classes' do
85
- it { should be false }
221
+ it 'should not raise any errors' do
222
+ expect {
223
+ subject.exit_cleanly
224
+ }.not_to raise_error
86
225
  end
226
+ end
227
+ end
87
228
 
88
- context 'with a single worker class' do
89
- let(:w) { double('Fake worker instance') }
229
+ describe '.configure' do
230
+ let(:config_proc) { Proc.new { {:valid => true} } }
231
+ it 'should error when not passed a block' do
232
+ expect {
233
+ described_class.configure
234
+ }.to raise_error(Stapfen::ConfigurationError)
235
+ end
90
236
 
91
- before :each do
92
- worker.class_variable_set(:@@workers, [w])
93
- end
237
+ it 'should save the return value from the block' do
238
+ described_class.configure &config_proc
239
+ expect(described_class.instance_configuration.call).to eql(config_proc.call)
240
+ end
241
+ end
94
242
 
95
- it "should execute the worker's #exit_cleanly method" do
96
- w.should_receive(:exit_cleanly)
97
- expect(result).to be true
98
- end
243
+ describe '.exit_cleanly', :java => true do
244
+ subject(:result) { described_class.exit_cleanly }
99
245
 
100
- it "should return false if the worker's #exit_cleanly method" do
101
- w.should_receive(:exit_cleanly).and_raise(StandardError)
102
- expect(result).to be false
103
- end
104
- end
246
+ before do
247
+ allow(Java::JavaLang::System).to receive(:exit).with(0)
248
+ end
105
249
 
106
- context 'with multiple worker classes' do
107
- let(:w1) { double('Fake Worker 1') }
108
- let(:w2) { double('Fake Worker 2') }
250
+ after do
251
+ described_class.class_variable_set(:@@workers, [])
252
+ end
109
253
 
110
- before do
111
- worker.class_variable_set(:@@workers, [w1, w2])
112
- end
254
+ context 'with no worker classes' do
255
+ it { should be false }
256
+ end
113
257
 
114
- it 'should invoke both #exit_cleanly methods' do
115
- expect(w1).to receive(:exit_cleanly)
116
- expect(w2).to receive(:exit_cleanly)
117
- expect(worker.exit_cleanly).to be true
118
- end
258
+ context 'with a single worker class' do
259
+ let(:w) { double('Fake worker instance') }
260
+
261
+ before :each do
262
+ described_class.class_variable_set(:@@workers, [w])
263
+ end
264
+
265
+ it "should execute the worker's .exit_cleanly method" do
266
+ w.should_receive(:exit_cleanly)
267
+ expect(result).to be true
268
+ end
269
+
270
+ it "should return false if the worker's .exit_cleanly method" do
271
+ w.should_receive(:exit_cleanly).and_raise(StandardError)
272
+ expect(result).to be false
119
273
  end
120
274
  end
121
275
 
122
- describe 'consume' do
123
- context 'if no block is passed' do
124
- it 'should raise an error if no block is passed' do
125
- expect {
126
- worker.consume 'jms.queue.lol'
127
- }.to raise_error(Stapfen::ConsumeError)
128
- end
276
+ context 'with multiple worker classes' do
277
+ let(:w1) { double('Fake Worker 1') }
278
+ let(:w2) { double('Fake Worker 2') }
279
+
280
+ before do
281
+ described_class.class_variable_set(:@@workers, [w1, w2])
129
282
  end
130
283
 
131
- context 'with just a queue name' do
132
- let(:name) { 'jms.queue.lol' }
284
+ it 'should invoke both .exit_cleanly methods' do
285
+ expect(w1).to receive(:exit_cleanly)
286
+ expect(w2).to receive(:exit_cleanly)
287
+ expect(described_class.exit_cleanly).to be true
288
+ end
289
+ end
290
+ end
133
291
 
134
- before do
135
- worker.instance_variable_set(:@consumers, [])
136
- end
292
+ describe 'detailed consume tests' do
293
+ context 'if no block is passed' do
294
+ it 'should raise an error if no block is passed' do
295
+ expect {
296
+ described_class.consume 'jms.queue.lol'
297
+ }.to raise_error(Stapfen::ConsumeError)
298
+ end
299
+ end
137
300
 
138
- it 'should add an entry for the queue name' do
139
- worker.consume(name) do |msg|
140
- nil
141
- end
301
+ context 'with just a queue name' do
302
+ let(:name) { 'jms.queue.lol' }
303
+ let(:client_options) { {:topic => name} }
142
304
 
143
- worker.consumers.should_not be_empty
144
- entry = worker.consumers.first
145
- entry.first.should eq(name)
146
- end
305
+ before do
306
+ described_class.instance_variable_set(:@consumers, [])
147
307
  end
148
308
 
149
- context 'unreceive behavior' do
150
- let(:client) do
151
- c = double('Mock Stapfen::Client')
152
- c.stub(:connect)
153
- c.stub(:can_unreceive? => true)
154
- c.stub(:runloop)
155
- c.stub(:unreceive)
156
- c
309
+ it 'should add an entry for the queue name' do
310
+ described_class.consume(client_options) do |msg|
311
+ nil
157
312
  end
158
313
 
159
- let(:name) { '/queue/some_queue' }
160
- let(:message) do
161
- m = Stomp::Message.new(nil)
162
- m.stub(:body => 'rspec msg')
163
- m
164
- end
314
+ described_class.consumers.should_not be_empty
315
+ entry = described_class.consumers.first
316
+ entry.first.should eq(client_options)
317
+ end
318
+ end
165
319
 
166
- before :each do
167
- Stapfen::Client::Stomp.stub(:new).and_return(client)
320
+ context 'unreceive behavior' do
321
+ let(:stapfen_client) do
322
+ c = double('Mock Stapfen::Client')
323
+ c.stub(:connect)
324
+ c.stub(:can_unreceive? => true)
325
+ c.stub(:runloop)
326
+ c.stub(:unreceive)
327
+ c
328
+ end
168
329
 
169
- # Clear any old consumers out
170
- worker.consumers = []
330
+ let(:name) { '/queue/some_queue' }
331
+ let(:client_options) { {:topic => name} }
332
+ let(:message) do
333
+ m = Stomp::Message.new(nil)
334
+ m.stub(:body => 'rspec msg')
335
+ m
336
+ end
171
337
 
172
- # Get a subscription? Call the message handler block.
173
- client.stub(:subscribe) do |name, headers, &block|
174
- block.call(message)
175
- end
338
+ before :each do
339
+ Stapfen::Client::Stomp.stub(:new).and_return(stapfen_client)
176
340
 
177
- config = {:valid => true}
341
+ # Clear any old consumers out
342
+ described_class.consumers = []
178
343
 
179
- worker.configure do
180
- config
181
- end
344
+ # Get a subscription? Call the message handler block.
345
+ stapfen_client.stub(:subscribe) do |name, headers, &block|
346
+ block.call(message)
182
347
  end
183
348
 
184
- after do
185
- worker.class_variable_set(:@@workers, [])
349
+ config = {:valid => true}
350
+
351
+ described_class.configure do
352
+ config
186
353
  end
354
+ end
187
355
 
188
- context 'with just a queue name' do
189
- context 'on a failed message' do
190
- it 'should not unreceive' do
191
- client.should_receive(:unreceive).never
356
+ after do
357
+ described_class.class_variable_set(:@@workers, [])
358
+ end
192
359
 
193
- worker.consume(name) {|msg| false }
194
- worker.new.run
195
- end
196
- end
197
- context 'on a successful message' do
198
- it 'should not unreceive' do
199
- client.should_receive(:unreceive).never
360
+ context 'with just a queue name' do
361
+ context 'on a failed message' do
362
+ it 'should not unreceive' do
363
+ stapfen_client.should_receive(:unreceive).never
200
364
 
201
- worker.consume(name) {|msg| true }
202
- worker.new.run
203
- end
365
+ described_class.consume(client_options) {|msg| false }
366
+ described_class.new.run
204
367
  end
205
368
  end
369
+ context 'on a successful message' do
370
+ it 'should not unreceive' do
371
+ stapfen_client.should_receive(:unreceive).never
206
372
 
207
- context 'with a queue name and headers for a dead_letter_queue and max_redeliveries' do
208
- let(:unrec_headers) do
209
- { :dead_letter_queue => '/queue/foo',
210
- :max_redeliveries => 3 }
211
- end
212
-
213
- let(:raw_headers) { unrec_headers.merge(:other_header => 'foo!') }
214
- context 'on a failed message' do
215
- it 'should unreceive' do
216
- client.should_receive(:unreceive).once
217
-
218
- worker.consume(name, raw_headers) {|msg| false }
219
- worker.new.run
220
- end
221
- it 'should pass :unreceive_headers through to the unreceive call' do
222
- client.should_receive(:unreceive).with(message, unrec_headers).once
223
-
224
- worker.consume(name, raw_headers) {|msg| false }
225
- worker.new.run
226
- end
227
- it 'should not remove the unreceive headers from the consumer' do
228
- worker.consume(name, raw_headers) {|msg| false}
229
- worker.new.run
230
-
231
- expect(worker.consumers.last[1][:dead_letter_queue]).to eql unrec_headers[:dead_letter_queue]
232
- expect(worker.consumers.last[1][:max_redeliveries]).to eql unrec_headers[:max_redeliveries]
233
- end
234
- end
235
- context 'on a successfully handled message' do
236
- it 'should not unreceive' do
237
- client.should_receive(:unreceive).never
238
-
239
- worker.consume(name, raw_headers) {|msg| true }
240
- worker.new.run
241
- end
373
+ described_class.consume(client_options) {|msg| true }
374
+ described_class.new.run
242
375
  end
243
376
  end
244
377
  end
245
- end
246
- end
247
378
 
248
- context 'instance methods' do
249
- describe '#exit_cleanly' do
250
- let(:client) { double('RSpec Stomp Client') }
379
+ context 'with a queue name and headers for a dead_letter_queue and max_redeliveries' do
380
+ let(:unrec_headers) do
381
+ { :dead_letter_queue => '/queue/foo',
382
+ :max_redeliveries => 3 }
383
+ end
251
384
 
252
- before :each do
253
- worker.stub(:client).and_return(client)
254
- end
385
+ let(:raw_headers) { unrec_headers.merge(:other_header => 'foo!') }
386
+ let(:client_options) { {:topic => name}.merge(raw_headers) }
387
+ let(:config_overrides) { client_options.merge(unrec_headers) }
388
+ context 'on a failed message' do
389
+ it 'should unreceive' do
390
+ stapfen_client.should_receive(:unreceive).once
255
391
 
256
- it 'should close the client' do
257
- client.stub(:closed?).and_return(false)
258
- client.should_receive(:close)
259
- worker.exit_cleanly
260
- end
392
+ described_class.consume(config_overrides) {|msg| false }
393
+ described_class.new.run
394
+ end
395
+ it 'should pass :unreceive_headers through to the unreceive call' do
396
+ stapfen_client.should_receive(:unreceive).with(message, config_overrides).once
261
397
 
262
- context 'with out having connected a client yet' do
263
- before :each do
264
- worker.stub(:client).and_return(nil)
398
+ described_class.consume(config_overrides) {|msg| false }
399
+ described_class.new.run
400
+ end
401
+ it 'should not remove the unreceive headers from the consumer' do
402
+ described_class.consume(config_overrides) {|msg| false}
403
+ described_class.new.run
404
+
405
+ expect(described_class.consumers.last[0][:dead_letter_queue]).to eql unrec_headers[:dead_letter_queue]
406
+ expect(described_class.consumers.last[0][:max_redeliveries]).to eql unrec_headers[:max_redeliveries]
407
+ end
265
408
  end
409
+ context 'on a successfully handled message' do
410
+ it 'should not unreceive' do
411
+ stapfen_client.should_receive(:unreceive).never
266
412
 
267
- it 'should not raise any errors' do
268
- expect {
269
- worker.exit_cleanly
270
- }.not_to raise_error
413
+ described_class.consume(config_overrides) {|msg| true }
414
+ described_class.new.run
415
+ end
271
416
  end
272
417
  end
273
418
  end