From 488e424b6b0e797490c57b148b040e4ef7dff829 Mon Sep 17 00:00:00 2001 From: AS-AlStar Date: Fri, 6 Dec 2024 12:30:36 +0300 Subject: [PATCH] fix specs --- spec/units/dummy/some_group.rb | 8 -------- spec/units/rabbit/receiving_spec.rb | 28 +++++++++++++--------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/spec/units/dummy/some_group.rb b/spec/units/dummy/some_group.rb index e53372c..20475f8 100644 --- a/spec/units/dummy/some_group.rb +++ b/spec/units/dummy/some_group.rb @@ -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 diff --git a/spec/units/rabbit/receiving_spec.rb b/spec/units/rabbit/receiving_spec.rb index d5bb940..f2e970c 100644 --- a/spec/units/rabbit/receiving_spec.rb +++ b/spec/units/rabbit/receiving_spec.rb @@ -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") } @@ -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) @@ -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" } @@ -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") }