Skip to content

Commit 0fc1ae1

Browse files
committed
Test 0, 1, 2, introspect calls.
Fixed method redefinition warnings for multiple introspections.
1 parent add5381 commit 0fc1ae1

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

lib/dbus/proxy_object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def define_shortcut_methods
102102
# creates a shortcut function that forwards each call to the method on
103103
# the appropriate intf
104104
singleton_class.class_eval do
105-
define_method name do |*args, &reply_handler|
105+
redefine_method name do |*args, &reply_handler|
106106
intf.method(name).call(*args, &reply_handler)
107107
end
108108
end

spec/proxy_object_spec.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env rspec
2+
require_relative "spec_helper"
3+
require "dbus"
4+
5+
describe DBus::ProxyObject do
6+
around(:each) do |example|
7+
with_private_bus do
8+
with_service_by_activation(&example)
9+
end
10+
end
11+
12+
let(:bus) { DBus::ASessionBus.new }
13+
14+
context "when calling org.ruby.service" do
15+
let(:svc) { bus["org.ruby.service"] }
16+
17+
context "when introspection mode is not specified" do
18+
describe "#bounce_variant" do
19+
it "works without an explicit #introspect call" do
20+
obj = svc["/org/ruby/MyInstance"]
21+
ifc = obj["org.ruby.SampleInterface"]
22+
expect(ifc.bounce_variant(42)).to be_eql 42
23+
end
24+
25+
it "works with one #introspect call" do
26+
obj = svc["/org/ruby/MyInstance"]
27+
obj.introspect
28+
ifc = obj["org.ruby.SampleInterface"]
29+
expect(ifc.bounce_variant(42)).to be_eql 42
30+
end
31+
32+
it "works with two #introspect calls" do
33+
obj = svc["/org/ruby/MyInstance"]
34+
obj.introspect
35+
obj.introspect
36+
ifc = obj["org.ruby.SampleInterface"]
37+
expect(ifc.bounce_variant(42)).to be_eql 42
38+
end
39+
end
40+
end
41+
end
42+
end

0 commit comments

Comments
 (0)