Skip to content

Commit 0a6a1f2

Browse files
committed
fix specs
1 parent 1783d0d commit 0a6a1f2

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

spec/units/dummy/some_group.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ class SomeSuccessfulEvent < Rabbit::EventHandler
1414
def call; end
1515
end
1616

17-
class SomeConfigurableEventHandler < Rabbit::EventHandler
18-
queue_as { |message, arguments| "#{message.data[:hello]}_#{arguments[:type]}" }
19-
20-
attribute :hello
21-
22-
def call; end
23-
end
24-
2517
class SomeUnsuccessfulEvent < Rabbit::EventHandler
2618
queue_as :custom
2719

spec/units/rabbit/receiving_spec.rb

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
let(:arguments) { { type: event, app_id: "some_group.some_app", message_id: "uuid" } }
1010
let(:event) { "some_successful_event" }
1111
let(:job_class) { Rabbit::Receiving::Job }
12-
let(:job_configs) { {} }
12+
let(:job_configs) { {} }
1313
let(:conversion) { false }
1414
let(:handler) { Rabbit::Handler::SomeGroup::SomeSuccessfulEvent }
1515
let(:before_hook) { double("before hook") }
@@ -53,7 +53,7 @@ def expect_hooks_to_be_called
5353
Rabbit.config.before_receiving_hooks = [before_hook]
5454
Rabbit.config.after_receiving_hooks = [after_hook]
5555

56-
allow(job_class).to receive(:set).with(queue: queue).and_call_original
56+
allow(job_class).to receive(:set).with(queue: queue, **job_configs).and_call_original
5757

5858
allow(before_hook).to receive(:call).with(message, message_info)
5959
allow(after_hook).to receive(:call).with(message, message_info)
@@ -135,6 +135,17 @@ def call; end
135135
run_receive
136136
end
137137

138+
context "custom job configuration" do
139+
let(:job_configs) { Hash[some: :kek, pek: 123] }
140+
141+
before { handler.additional_job_configs = job_configs }
142+
after { handler.additional_job_configs = {} }
143+
144+
it "invokes job with custom config" do
145+
run_receive
146+
end
147+
end
148+
138149
context "job performs unsuccessfully" do
139150
let(:event) { "some_unsuccessful_event" }
140151
let(:queue) { "custom_prepared" }
@@ -238,19 +249,6 @@ def call; end
238249
end
239250
end
240251

241-
context "custom job configuration" do
242-
let(:queue) { "custom_queue" }
243-
let(:job_configs) { Hash[some: :kek, pek: 123] }
244-
let(:handler) { Rabbit::Handler::SomeGroup::SomeConfigurableEventHandler }
245-
246-
before { handler.job_configs(job_configs) }
247-
after { handler.job_configs({}) }
248-
249-
it "invokes job with custom config" do
250-
run_receive
251-
end
252-
end
253-
254252
context "custom receiving job" do
255253
let(:custom_job_class) { class_double("CustomJobClass") }
256254
let(:custom_job) { double("CustomJob") }

0 commit comments

Comments
 (0)