Skip to content

Commit ebfb800

Browse files
committed
Test methods and properties on ApiOptions::V1
1 parent 0148047 commit ebfb800

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

spec/property_spec.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
describe "PropertyTest" do
66
before(:each) do
77
session_bus = DBus::ASessionBus.new
8-
svc = session_bus.service("org.ruby.service")
9-
@obj = svc.object("/org/ruby/MyInstance")
8+
@svc = session_bus.service("org.ruby.service")
9+
@obj = @svc.object("/org/ruby/MyInstance")
1010
@obj.introspect
1111
@iface = @obj["org.ruby.SampleInterface"]
1212
end
@@ -15,6 +15,14 @@
1515
expect(@iface["ReadMe"]).to eq("READ ME")
1616
end
1717

18+
it "tests property reading on a V1 object" do
19+
obj = @svc["/org/ruby/MyInstance"]
20+
obj.introspect
21+
iface = obj["org.ruby.SampleInterface"]
22+
23+
expect(iface["ReadMe"]).to eq("READ ME")
24+
end
25+
1826
it "tests property nonreading" do
1927
expect { @iface["WriteMe"] }.to raise_error(DBus::Error, /not readable/)
2028
end
@@ -43,6 +51,15 @@
4351
expect(all.keys.sort).to eq(["ReadMe", "ReadOrWriteMe"])
4452
end
4553

54+
it "tests get all on a V1 object" do
55+
obj = @svc["/org/ruby/MyInstance"]
56+
obj.introspect
57+
iface = obj["org.ruby.SampleInterface"]
58+
59+
all = iface.all_properties
60+
expect(all.keys.sort).to eq(["ReadMe", "ReadOrWriteMe"])
61+
end
62+
4663
it "tests unknown property reading" do
4764
expect { @iface["Spoon"] }.to raise_error(DBus::Error, /not found/)
4865
end

spec/value_spec.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
describe "ValueTest" do
77
before(:each) do
88
session_bus = DBus::ASessionBus.new
9-
svc = session_bus.service("org.ruby.service")
10-
@obj = svc.object("/org/ruby/MyInstance")
9+
@svc = session_bus.service("org.ruby.service")
10+
@obj = @svc.object("/org/ruby/MyInstance")
1111
@obj.introspect # necessary
1212
@obj.default_iface = "org.ruby.SampleInterface"
1313
end
@@ -36,7 +36,19 @@
3636
empty_hash = {}
3737
expect(@obj.bounce_variant(empty_hash)[0]).to eq(empty_hash)
3838
end
39-
39+
40+
it "retrieves a single return value with API V1" do
41+
obj = @svc["/org/ruby/MyInstance"]
42+
obj.introspect
43+
obj.default_iface = "org.ruby.SampleInterface"
44+
45+
expect(obj.bounce_variant("cuckoo")).to eq("cuckoo")
46+
expect(obj.bounce_variant(["coucou", "kuku"])).to eq(["coucou", "kuku"])
47+
expect(obj.bounce_variant([])).to eq([])
48+
empty_hash = {}
49+
expect(obj.bounce_variant(empty_hash)).to eq(empty_hash)
50+
end
51+
4052
# these are ambiguous
4153
it "tests pairs with a string" do
4254

0 commit comments

Comments
 (0)