shoryuken 3.1.4 → 3.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +13 -3
  4. data/CHANGELOG.md +63 -0
  5. data/Gemfile +5 -3
  6. data/Gemfile.aws-sdk-core-v2 +13 -0
  7. data/bin/cli/sqs.rb +8 -4
  8. data/bin/shoryuken +2 -1
  9. data/lib/shoryuken/body_parser.rb +27 -0
  10. data/lib/shoryuken/fetcher.rb +40 -13
  11. data/lib/shoryuken/launcher.rb +2 -17
  12. data/lib/shoryuken/manager.rb +17 -5
  13. data/lib/shoryuken/middleware/chain.rb +4 -0
  14. data/lib/shoryuken/middleware/server/auto_extend_visibility.rb +2 -5
  15. data/lib/shoryuken/middleware/server/timing.rb +12 -14
  16. data/lib/shoryuken/options.rb +21 -1
  17. data/lib/shoryuken/processor.rb +5 -21
  18. data/lib/shoryuken/queue.rb +12 -5
  19. data/lib/shoryuken/runner.rb +3 -1
  20. data/lib/shoryuken/util.rb +2 -2
  21. data/lib/shoryuken/version.rb +1 -1
  22. data/lib/shoryuken/worker/default_executor.rb +33 -0
  23. data/lib/shoryuken/worker/inline_executor.rb +28 -0
  24. data/lib/shoryuken/worker.rb +68 -31
  25. data/lib/shoryuken.rb +11 -0
  26. data/shoryuken.gemspec +1 -1
  27. data/spec/shoryuken/body_parser_spec.rb +89 -0
  28. data/spec/shoryuken/fetcher_spec.rb +61 -9
  29. data/spec/shoryuken/manager_spec.rb +2 -2
  30. data/spec/shoryuken/middleware/chain_spec.rb +16 -4
  31. data/spec/shoryuken/options_spec.rb +80 -0
  32. data/spec/shoryuken/processor_spec.rb +15 -97
  33. data/spec/shoryuken/queue_spec.rb +43 -32
  34. data/spec/shoryuken/util_spec.rb +25 -1
  35. data/spec/shoryuken/worker/default_executor_spec.rb +100 -0
  36. data/spec/shoryuken/worker/inline_executor_spec.rb +23 -0
  37. data/spec/shoryuken/worker_spec.rb +32 -91
  38. data/spec/spec_helper.rb +2 -0
  39. metadata +15 -5
@@ -1,6 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'shoryuken/processor'
3
- require 'shoryuken/manager'
4
2
 
5
3
  RSpec.describe Shoryuken::Processor do
6
4
  let(:manager) { double Shoryuken::Manager }
@@ -8,12 +6,14 @@ RSpec.describe Shoryuken::Processor do
8
6
  let(:queue) { 'default' }
9
7
 
10
8
  let(:sqs_msg) do
11
- double Shoryuken::Message,
9
+ double(
10
+ Shoryuken::Message,
12
11
  queue_url: queue,
13
12
  body: 'test',
14
13
  message_attributes: {},
15
14
  message_id: SecureRandom.uuid,
16
15
  receipt_handle: SecureRandom.uuid
16
+ )
17
17
  end
18
18
 
19
19
  before do
@@ -25,101 +25,15 @@ RSpec.describe Shoryuken::Processor do
25
25
  subject { described_class.new(queue, sqs_msg) }
26
26
 
27
27
  describe '#process' do
28
- it 'parses the body into JSON' do
29
- TestWorker.get_shoryuken_options['body_parser'] = :json
28
+ it 'sets log context' do
29
+ expect(Shoryuken::Logging).to receive(:with_context).with("TestWorker/#{queue}/#{sqs_msg.message_id}")
30
30
 
31
- body = { 'test' => 'hi' }
32
-
33
- expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, body)
34
-
35
- allow(sqs_msg).to receive(:body).and_return(JSON.dump(body))
31
+ allow_any_instance_of(TestWorker).to receive(:perform)
32
+ allow(sqs_msg).to receive(:body)
36
33
 
37
34
  subject.process
38
35
  end
39
36
 
40
- it 'parses the body calling the proc' do
41
- TestWorker.get_shoryuken_options['body_parser'] = proc { |sqs_msg| "*#{sqs_msg.body}*" }
42
-
43
- expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, '*test*')
44
-
45
- allow(sqs_msg).to receive(:body).and_return('test')
46
-
47
- subject.process
48
- end
49
-
50
- it 'parses the body as text' do
51
- TestWorker.get_shoryuken_options['body_parser'] = :text
52
-
53
- body = 'test'
54
-
55
- expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, body)
56
-
57
- allow(sqs_msg).to receive(:body).and_return(body)
58
-
59
- subject.process
60
- end
61
-
62
- it 'parses calling `.load`' do
63
- TestWorker.get_shoryuken_options['body_parser'] = Class.new do
64
- def self.load(*args)
65
- JSON.load(*args)
66
- end
67
- end
68
-
69
- body = { 'test' => 'hi' }
70
-
71
- expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, body)
72
-
73
- allow(sqs_msg).to receive(:body).and_return(JSON.dump(body))
74
-
75
- subject.process
76
- end
77
-
78
- it 'parses calling `.parse`' do
79
- TestWorker.get_shoryuken_options['body_parser'] = Class.new do
80
- def self.parse(*args)
81
- JSON.parse(*args)
82
- end
83
- end
84
-
85
- body = { 'test' => 'hi' }
86
-
87
- expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, body)
88
-
89
- allow(sqs_msg).to receive(:body).and_return(JSON.dump(body))
90
-
91
- subject.process
92
- end
93
-
94
- context 'when parse errors' do
95
- before do
96
- TestWorker.get_shoryuken_options['body_parser'] = :json
97
-
98
- allow(sqs_msg).to receive(:body).and_return('invalid JSON')
99
- end
100
-
101
- specify do
102
- expect(subject.logger).to receive(:error).twice
103
-
104
- expect { subject.process }.
105
- to raise_error(JSON::ParserError, /unexpected token at 'invalid JSON'/)
106
- end
107
- end
108
-
109
- context 'when `object_type: nil`' do
110
- it 'parses the body as text' do
111
- TestWorker.get_shoryuken_options['body_parser'] = nil
112
-
113
- body = 'test'
114
-
115
- expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, body)
116
-
117
- allow(sqs_msg).to receive(:body).and_return(body)
118
-
119
- subject.process
120
- end
121
- end
122
-
123
37
  context 'when custom middleware' do
124
38
  let(:queue) { 'worker_called_middleware' }
125
39
 
@@ -220,15 +134,19 @@ RSpec.describe Shoryuken::Processor do
220
134
 
221
135
  context 'when shoryuken_class header' do
222
136
  let(:sqs_msg) do
223
- double Shoryuken::Message,
137
+ double(
138
+ Shoryuken::Message,
224
139
  queue_url: queue,
225
140
  body: 'test',
226
141
  message_attributes: {
227
142
  'shoryuken_class' => {
228
143
  string_value: TestWorker.to_s,
229
- data_type: 'String' }},
230
- message_id: SecureRandom.uuid,
231
- receipt_handle: SecureRandom.uuid
144
+ data_type: 'String'
145
+ }
146
+ },
147
+ message_id: SecureRandom.uuid,
148
+ receipt_handle: SecureRandom.uuid
149
+ )
232
150
  end
233
151
 
234
152
  it 'performs without delete' do
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
+ # rubocop:disable Metrics/BlockLength
3
4
  RSpec.describe Shoryuken::Queue do
4
5
  let(:credentials) { Aws::Credentials.new('access_key_id', 'secret_access_key') }
5
6
  let(:sqs) { Aws::SQS::Client.new(stub_responses: true, credentials: credentials) }
@@ -15,10 +16,12 @@ RSpec.describe Shoryuken::Queue do
15
16
  end
16
17
 
17
18
  describe '#new' do
18
- context 'when queue url supplied' do
19
- subject { described_class.new(sqs, queue_url) }
19
+ context 'when queue URL supplied' do
20
+ it 'instantiates by URL and validate the URL' do
21
+ expect_any_instance_of(described_class).to receive(:fifo?).and_return(false)
22
+
23
+ subject = described_class.new(sqs, queue_url)
20
24
 
21
- specify do
22
25
  expect(subject.name).to eq(queue_name)
23
26
  end
24
27
  end
@@ -51,7 +54,9 @@ RSpec.describe Shoryuken::Queue do
51
54
  failure = double(id: 'id', code: 'code', message: '...', sender_fault: false)
52
55
  logger = double 'Logger'
53
56
 
54
- expect(sqs).to receive(:delete_message_batch).with(entries: entries, queue_url: queue_url).and_return(double(failed: [failure]))
57
+ expect(sqs).to(
58
+ receive(:delete_message_batch).with(entries: entries, queue_url: queue_url).and_return(double(failed: [failure]))
59
+ )
55
60
  expect(subject).to receive(:logger).and_return(logger)
56
61
  expect(logger).to receive(:error)
57
62
 
@@ -111,36 +116,30 @@ RSpec.describe Shoryuken::Queue do
111
116
  end
112
117
 
113
118
  describe '#send_messages' do
114
- before {
115
- allow(subject).to receive(:fifo?).and_return(false)
116
- }
119
+ before { allow(subject).to receive(:fifo?).and_return(false) }
120
+
117
121
  it 'accepts SQS request parameters' do
118
122
  # https://docs.aws.amazon.com/sdkforruby/api/Aws/SQS/Client.html#send_message_batch-instance_method
119
- expect(sqs).to receive(:send_message_batch).with(hash_including(entries: [{id: '0', message_body: 'msg1'}, {id: '1', message_body: 'msg2'}]))
123
+ expect(sqs).to(
124
+ receive(:send_message_batch).with(hash_including(entries: [{id: '0', message_body: 'msg1'}, {id: '1', message_body: 'msg2'}]))
125
+ )
120
126
 
121
127
  subject.send_messages(entries: [{id: '0', message_body: 'msg1'}, {id: '1', message_body: 'msg2'}])
122
128
  end
123
129
 
124
130
  it 'accepts an array of messages' do
125
- options = { entries: [{ id: '0',
126
- message_body: 'msg1',
127
- delay_seconds: 1,
128
- message_attributes: { attr: 'attr1' } },
129
- { id: '1',
130
- message_body: 'msg2',
131
- delay_seconds: 1,
132
- message_attributes: { attr: 'attr2' } }] }
133
-
131
+ options = { entries: [
132
+ { id: '0', message_body: 'msg1', delay_seconds: 1, message_attributes: { attr: 'attr1' } },
133
+ { id: '1', message_body: 'msg2', delay_seconds: 1, message_attributes: { attr: 'attr2' } }
134
+ ] }
134
135
  expect(sqs).to receive(:send_message_batch).with(hash_including(options))
135
136
 
136
- subject.send_messages([{ message_body: 'msg1',
137
- delay_seconds: 1,
138
- message_attributes: { attr: 'attr1' }
139
- }, {
140
- message_body: 'msg2',
141
- delay_seconds: 1,
142
- message_attributes: { attr: 'attr2' }
143
- }])
137
+ subject.send_messages(
138
+ [
139
+ { message_body: 'msg1', delay_seconds: 1, message_attributes: { attr: 'attr1' } },
140
+ { message_body: 'msg2', delay_seconds: 1, message_attributes: { attr: 'attr2' } }
141
+ ]
142
+ )
144
143
  end
145
144
 
146
145
  context 'when FIFO' do
@@ -170,16 +169,24 @@ RSpec.describe Shoryuken::Queue do
170
169
  expect(first_entry[:message_deduplication_id]).to eq 'my id'
171
170
  end
172
171
 
173
- subject.send_messages([{ message_body: 'msg1',
174
- message_attributes: { attr: 'attr1' },
175
- message_group_id: 'my group',
176
- message_deduplication_id: 'my id' }])
172
+ subject.send_messages(
173
+ [
174
+ { message_body: 'msg1',
175
+ message_attributes: { attr: 'attr1' },
176
+ message_group_id: 'my group',
177
+ message_deduplication_id: 'my id' }
178
+ ]
179
+ )
177
180
  end
178
181
  end
179
182
  end
180
183
 
181
184
  it 'accepts an array of string' do
182
- expect(sqs).to receive(:send_message_batch).with(hash_including(entries: [{ id: '0', message_body: 'msg1' }, { id: '1', message_body: 'msg2' }]))
185
+ expect(sqs).to(
186
+ receive(:send_message_batch).with(
187
+ hash_including(entries: [{ id: '0', message_body: 'msg1' }, { id: '1', message_body: 'msg2' }])
188
+ )
189
+ )
183
190
 
184
191
  subject.send_messages(%w(msg1 msg2))
185
192
  end
@@ -189,9 +196,13 @@ RSpec.describe Shoryuken::Queue do
189
196
  before do
190
197
  attribute_response = double 'Aws::SQS::Types::GetQueueAttributesResponse'
191
198
 
192
- allow(attribute_response).to receive(:attributes).and_return('FifoQueue' => fifo.to_s, 'ContentBasedDeduplication' => 'true')
199
+ allow(attribute_response).to(
200
+ receive(:attributes).and_return('FifoQueue' => fifo.to_s, 'ContentBasedDeduplication' => 'true')
201
+ )
193
202
  allow(subject).to receive(:url).and_return(queue_url)
194
- allow(sqs).to receive(:get_queue_attributes).with(queue_url: queue_url, attribute_names: ['All']).and_return(attribute_response)
203
+ allow(sqs).to(
204
+ receive(:get_queue_attributes).with(queue_url: queue_url, attribute_names: ['All']).and_return(attribute_response)
205
+ )
195
206
  end
196
207
 
197
208
  context 'when queue is FIFO' do
@@ -9,7 +9,7 @@ describe 'Shoryuken::Util' do
9
9
 
10
10
  describe '#unparse_queues' do
11
11
  it 'returns queues and weights' do
12
- queues = %w[queue1 queue1 queue2 queue3 queue4 queue4 queue4]
12
+ queues = %w(queue1 queue1 queue2 queue3 queue4 queue4 queue4)
13
13
 
14
14
  expect(subject.unparse_queues(queues)).to eq([['queue1', 2], ['queue2', 1], ['queue3', 1], ['queue4', 3]])
15
15
  end
@@ -26,4 +26,28 @@ describe 'Shoryuken::Util' do
26
26
 
27
27
  it 'returns ActiveJob worker name'
28
28
  end
29
+
30
+ describe '#fire_event' do
31
+ let(:value_holder) { Object.new }
32
+ let(:callback_without_options) { proc { value_holder.value = :without_options } }
33
+ let(:callback_with_options) { proc { |options| value_holder.value = [:with_options, options] } }
34
+
35
+ after :all do
36
+ Shoryuken.options[:lifecycle_events].delete(:some_event)
37
+ end
38
+
39
+ it 'triggers callbacks that do not accept arguments' do
40
+ Shoryuken.options[:lifecycle_events][:some_event] = [callback_without_options]
41
+
42
+ expect(value_holder).to receive(:value=).with(:without_options)
43
+ subject.fire_event(:some_event)
44
+ end
45
+
46
+ it 'triggers callbacks that accept an argument' do
47
+ Shoryuken.options[:lifecycle_events][:some_event] = [callback_with_options]
48
+
49
+ expect(value_holder).to receive(:value=).with([:with_options, { my_option: :some_option }])
50
+ subject.fire_event(:some_event, false, my_option: :some_option)
51
+ end
52
+ end
29
53
  end
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Shoryuken::Worker::DefaultExecutor do
4
+ let(:sqs_queue) { double 'SQS Queue' }
5
+ let(:queue) { 'default' }
6
+
7
+ before do
8
+ allow(Shoryuken::Client).to receive(:queues).with(queue).and_return(sqs_queue)
9
+ end
10
+
11
+ describe '.perform_in' do
12
+ it 'delays a message' do
13
+ expect(sqs_queue).to receive(:send_message).with(
14
+ message_attributes: {
15
+ 'shoryuken_class' => {
16
+ string_value: TestWorker.to_s,
17
+ data_type: 'String'
18
+ }
19
+ },
20
+ message_body: 'message',
21
+ delay_seconds: 60)
22
+
23
+ TestWorker.perform_in(60, 'message')
24
+ end
25
+
26
+ it 'raises an exception' do
27
+ expect {
28
+ TestWorker.perform_in(901, 'message')
29
+ }.to raise_error 'The maximum allowed delay is 15 minutes'
30
+ end
31
+ end
32
+
33
+ describe '.perform_at' do
34
+ it 'delays a message' do
35
+ expect(sqs_queue).to receive(:send_message).with(
36
+ message_attributes: {
37
+ 'shoryuken_class' => {
38
+ string_value: TestWorker.to_s,
39
+ data_type: 'String'
40
+ }
41
+ },
42
+ message_body: 'message',
43
+ delay_seconds: 60)
44
+
45
+ TestWorker.perform_in(Time.now + 60, 'message')
46
+ end
47
+
48
+ it 'raises an exception' do
49
+ expect {
50
+ TestWorker.perform_in(Time.now + 901, 'message')
51
+ }.to raise_error 'The maximum allowed delay is 15 minutes'
52
+ end
53
+ end
54
+
55
+ describe '.perform_async' do
56
+ it 'enqueues a message' do
57
+ expect(sqs_queue).to receive(:send_message).with(
58
+ message_attributes: {
59
+ 'shoryuken_class' => {
60
+ string_value: TestWorker.to_s,
61
+ data_type: 'String'
62
+ }
63
+ },
64
+ message_body: 'message')
65
+
66
+ TestWorker.perform_async('message')
67
+ end
68
+
69
+ it 'enqueues a message with options' do
70
+ expect(sqs_queue).to receive(:send_message).with(
71
+ delay_seconds: 60,
72
+ message_attributes: {
73
+ 'shoryuken_class' => {
74
+ string_value: TestWorker.to_s,
75
+ data_type: 'String'
76
+ }
77
+ },
78
+ message_body: 'delayed message')
79
+
80
+ TestWorker.perform_async('delayed message', delay_seconds: 60)
81
+ end
82
+
83
+ it 'accepts an `queue` option' do
84
+ new_queue = 'some_different_queue'
85
+
86
+ expect(Shoryuken::Client).to receive(:queues).with(new_queue).and_return(sqs_queue)
87
+
88
+ expect(sqs_queue).to receive(:send_message).with(
89
+ message_attributes: {
90
+ 'shoryuken_class' => {
91
+ string_value: TestWorker.to_s,
92
+ data_type: 'String'
93
+ }
94
+ },
95
+ message_body: 'delayed message')
96
+
97
+ TestWorker.perform_async('delayed message', queue: new_queue)
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Shoryuken::Worker::InlineExecutor do
4
+ before do
5
+ Shoryuken.worker_executor = described_class
6
+ end
7
+
8
+ describe '.perform_async' do
9
+ specify do
10
+ expect_any_instance_of(TestWorker).to receive(:perform)
11
+
12
+ TestWorker.perform_async('test')
13
+ end
14
+ end
15
+
16
+ describe '.perform_in' do
17
+ specify do
18
+ expect_any_instance_of(TestWorker).to receive(:perform)
19
+
20
+ TestWorker.perform_in(60, 'test')
21
+ end
22
+ end
23
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe 'Shoryuken::Worker' do
3
+ RSpec.describe Shoryuken::Worker do
4
4
  let(:sqs_queue) { double 'SQS Queue' }
5
5
  let(:queue) { 'default' }
6
6
 
@@ -8,96 +8,6 @@ RSpec.describe 'Shoryuken::Worker' do
8
8
  allow(Shoryuken::Client).to receive(:queues).with(queue).and_return(sqs_queue)
9
9
  end
10
10
 
11
- describe '.perform_in' do
12
- it 'delays a message' do
13
- expect(sqs_queue).to receive(:send_message).with(
14
- message_attributes: {
15
- 'shoryuken_class' => {
16
- string_value: TestWorker.to_s,
17
- data_type: 'String'
18
- }
19
- },
20
- message_body: 'message',
21
- delay_seconds: 60)
22
-
23
- TestWorker.perform_in(60, 'message')
24
- end
25
-
26
- it 'raises an exception' do
27
- expect {
28
- TestWorker.perform_in(901, 'message')
29
- }.to raise_error 'The maximum allowed delay is 15 minutes'
30
- end
31
- end
32
-
33
- describe '.perform_at' do
34
- it 'delays a message' do
35
- expect(sqs_queue).to receive(:send_message).with(
36
- message_attributes: {
37
- 'shoryuken_class' => {
38
- string_value: TestWorker.to_s,
39
- data_type: 'String'
40
- }
41
- },
42
- message_body: 'message',
43
- delay_seconds: 60)
44
-
45
- TestWorker.perform_in(Time.now + 60, 'message')
46
- end
47
-
48
- it 'raises an exception' do
49
- expect {
50
- TestWorker.perform_in(Time.now + 901, 'message')
51
- }.to raise_error 'The maximum allowed delay is 15 minutes'
52
- end
53
- end
54
-
55
- describe '.perform_async' do
56
- it 'enqueues a message' do
57
- expect(sqs_queue).to receive(:send_message).with(
58
- message_attributes: {
59
- 'shoryuken_class' => {
60
- string_value: TestWorker.to_s,
61
- data_type: 'String'
62
- }
63
- },
64
- message_body: 'message')
65
-
66
- TestWorker.perform_async('message')
67
- end
68
-
69
- it 'enqueues a message with options' do
70
- expect(sqs_queue).to receive(:send_message).with(
71
- delay_seconds: 60,
72
- message_attributes: {
73
- 'shoryuken_class' => {
74
- string_value: TestWorker.to_s,
75
- data_type: 'String'
76
- }
77
- },
78
- message_body: 'delayed message')
79
-
80
- TestWorker.perform_async('delayed message', delay_seconds: 60)
81
- end
82
-
83
- it 'accepts an `queue` option' do
84
- new_queue = 'some_different_queue'
85
-
86
- expect(Shoryuken::Client).to receive(:queues).with(new_queue).and_return(sqs_queue)
87
-
88
- expect(sqs_queue).to receive(:send_message).with(
89
- message_attributes: {
90
- 'shoryuken_class' => {
91
- string_value: TestWorker.to_s,
92
- data_type: 'String'
93
- }
94
- },
95
- message_body: 'delayed message')
96
-
97
- TestWorker.perform_async('delayed message', queue: new_queue)
98
- end
99
- end
100
-
101
11
  describe '.shoryuken_options' do
102
12
  it 'registers a worker' do
103
13
  expect(Shoryuken.worker_registry.workers('default')).to eq([TestWorker])
@@ -116,6 +26,20 @@ RSpec.describe 'Shoryuken::Worker' do
116
26
  expect(NewTestWorker.get_shoryuken_options['queue']).to eq 'production_default'
117
27
  end
118
28
 
29
+ it 'does not change the original hash' do
30
+ class TestWorker
31
+ include Shoryuken::Worker
32
+
33
+ OPT = { queue: :default }
34
+
35
+ shoryuken_options OPT
36
+ end
37
+
38
+ expect(TestWorker::OPT['queue']).to eq(nil)
39
+ expect(TestWorker.get_shoryuken_options['queue']).to eq('default')
40
+ expect(TestWorker::OPT[:queue]).to eq(:default)
41
+ end
42
+
119
43
  it 'accepts an array as a queue' do
120
44
  class WorkerMultipleQueues
121
45
  include Shoryuken::Worker
@@ -164,6 +88,23 @@ RSpec.describe 'Shoryuken::Worker' do
164
88
  expect(Shoryuken.worker_registry.workers('symbol_queue2')).to eq([WorkerMultipleSymbolQueues])
165
89
  expect(Shoryuken.worker_registry.workers('symbol_queue3')).to eq([WorkerMultipleSymbolQueues])
166
90
  end
91
+
92
+ it 'preserves parent class options' do
93
+ class ParentWorker
94
+ include Shoryuken::Worker
95
+
96
+ shoryuken_options queue: "myqueue", auto_delete: false
97
+ end
98
+
99
+ class ChildWorker < ParentWorker
100
+ shoryuken_options auto_delete: true
101
+ end
102
+
103
+ expect(ParentWorker.get_shoryuken_options['queue']).to eq("myqueue")
104
+ expect(ChildWorker.get_shoryuken_options['queue']).to eq("myqueue")
105
+ expect(ParentWorker.get_shoryuken_options['auto_delete']).to eq(false)
106
+ expect(ChildWorker.get_shoryuken_options['auto_delete']).to eq(true)
107
+ end
167
108
  end
168
109
 
169
110
  describe '.server_middleware' do
data/spec/spec_helper.rb CHANGED
@@ -59,6 +59,8 @@ RSpec.configure do |config|
59
59
 
60
60
  Aws.config[:stub_responses] = true
61
61
 
62
+ Shoryuken.sqs_client_receive_message_opts.clear
63
+
62
64
  allow(Concurrent).to receive(:global_io_executor).and_return(Concurrent::ImmediateExecutor.new)
63
65
  allow(Shoryuken).to receive(:active_job?).and_return(false)
64
66
  end