From 64983e218834265707895ca4ed778fb831515d6e Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Fri, 29 Sep 2023 11:22:47 +0200 Subject: [PATCH] Test request_name(... queue: true) --- spec/bus_connection_spec.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/spec/bus_connection_spec.rb b/spec/bus_connection_spec.rb index a6ee078..ed04aab 100755 --- a/spec/bus_connection_spec.rb +++ b/spec/bus_connection_spec.rb @@ -21,7 +21,6 @@ end context "when the name is taken already", tag_service: true do - # formerly it returned Service, now ObjectServer takes its role it "raises NameRequestError... too late" do name = "org.ruby.service" expect do @@ -60,13 +59,25 @@ end context "when the name is taken already", tag_service: true do - # formerly it returned Service, now ObjectServer takes its role it "raises NameRequestError" do name = "org.ruby.service" expect do - # flags: avoid getting the name sometime later, unexpectedly - bus.request_name(name, flags: DBus::Connection::NAME_FLAG_DO_NOT_QUEUE) + bus.request_name(name) + end.to raise_error(DBus::Connection::NameRequestError) + end + end + + context "when the name is taken already but we request queuing", tag_service: true do + it "raises NameRequestError but we are queued" do + name = "org.ruby.service" + owning = nil + # TODO: we do not expect the handlers to run + bus.on_name_acquired { owning = true } + bus.on_name_lost { owning = false } + expect do + bus.request_name(name, queue: true) end.to raise_error(DBus::Connection::NameRequestError) + expect(bus.release_name(name)).to eq DBus::BusConnection::RELEASE_NAME_REPLY_RELEASED end end