1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/usr/bin/env rspec
# should report it missing on org.ruby.SampleInterface
# (on object...) instead of on DBus::Proxy::ObjectInterface
require_relative "spec_helper"
require "dbus"
describe "ErrMsgTest" do
before(:each) do
session_bus = DBus::ASessionBus.new
svc = session_bus.service("org.ruby.service")
@obj = svc.object("/org/ruby/MyInstance")
@obj.default_iface = "org.ruby.SampleInterface"
end
it "tests report dbus interface" do
# a specific exception...
# mentioning DBus and the interface
expect { @obj.NoSuchMethod }
.to raise_error(NameError, /DBus interface.*#{@obj.default_iface}/)
end
it "tests report short struct" do
expect { @obj.test_variant ["(ss)", ["too few"]] }
.to raise_error(DBus::TypeException, /1 elements but type info for 2/)
end
it "tests report long struct" do
expect { @obj.test_variant ["(ss)", ["a", "b", "too many"]] }
.to raise_error(DBus::TypeException, /3 elements but type info for 2/)
end
it "tests report nil" do
nils = [
["(s)", [nil]], # would get disconnected
["i", nil],
["a{ss}", { "foo" => nil }]
]
nils.each do |has_nil|
# TODO: want backtrace from the perspective of the caller:
# rescue/reraise in send_sync?
expect { @obj.test_variant has_nil }
.to raise_error(DBus::TypeException, /Cannot send nil/)
end
end
end
|