Skip to content

Commit

Permalink
fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
AS-AlStar committed Dec 6, 2024
1 parent b25bffe commit 488e424
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
8 changes: 0 additions & 8 deletions spec/units/dummy/some_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ class SomeSuccessfulEvent < Rabbit::EventHandler
def call; end
end

class SomeConfigurableEventHandler < Rabbit::EventHandler
queue_as { |message, arguments| "#{message.data[:hello]}_#{arguments[:type]}" }

attribute :hello

def call; end
end

class SomeUnsuccessfulEvent < Rabbit::EventHandler
queue_as :custom

Expand Down
28 changes: 13 additions & 15 deletions spec/units/rabbit/receiving_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let(:arguments) { { type: event, app_id: "some_group.some_app", message_id: "uuid" } }
let(:event) { "some_successful_event" }
let(:job_class) { Rabbit::Receiving::Job }
let(:job_configs) { {} }
let(:job_configs) { {} }
let(:conversion) { false }
let(:handler) { Rabbit::Handler::SomeGroup::SomeSuccessfulEvent }
let(:before_hook) { double("before hook") }
Expand Down Expand Up @@ -53,7 +53,7 @@ def expect_hooks_to_be_called
Rabbit.config.before_receiving_hooks = [before_hook]
Rabbit.config.after_receiving_hooks = [after_hook]

allow(job_class).to receive(:set).with(queue: queue).and_call_original
allow(job_class).to receive(:set).with(queue: queue, **job_configs).and_call_original

allow(before_hook).to receive(:call).with(message, message_info)
allow(after_hook).to receive(:call).with(message, message_info)
Expand Down Expand Up @@ -135,6 +135,17 @@ def call; end
run_receive
end

context "custom job configuration" do
let(:job_configs) { Hash[some: :kek, pek: 123] }

before { handler.additional_job_configs = job_configs }
after { handler.additional_job_configs = {} }

it "invokes job with custom config" do
run_receive
end
end

context "job performs unsuccessfully" do
let(:event) { "some_unsuccessful_event" }
let(:queue) { "custom_prepared" }
Expand Down Expand Up @@ -238,19 +249,6 @@ def call; end
end
end

context "custom job configuration" do
let(:queue) { "custom_queue" }
let(:job_configs) { Hash[some: :kek, pek: 123] }
let(:handler) { Rabbit::Handler::SomeGroup::SomeConfigurableEventHandler }

before { handler.job_configs(job_configs) }
after { handler.job_configs({}) }

it "invokes job with custom config" do
run_receive
end
end

context "custom receiving job" do
let(:custom_job_class) { class_double("CustomJobClass") }
let(:custom_job) { double("CustomJob") }
Expand Down

0 comments on commit 488e424

Please sign in to comment.