File: server_spec.rb

package info (click to toggle)
ruby-dbus 0.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 520 kB
  • sloc: ruby: 3,786; sh: 53; makefile: 8
file content (53 lines) | stat: -rwxr-xr-x 1,336 bytes parent folder | download | duplicates (3)
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
46
47
48
49
50
51
52
53
#!/usr/bin/env rspec
# Test that a server survives various error cases
require_relative "spec_helper"
require "dbus"

class Foo < DBus::Object
  dbus_interface "org.ruby.ServerTest" do
    dbus_signal :signal_without_arguments
    dbus_signal :signal_with_argument, "epsilon:d"
  end

  dbus_signal :signal_without_interface
rescue DBus::Object::UndefinedInterface
  # raised by the preceding signal declaration
end

class Bar < DBus::Object
  dbus_interface "org.ruby.ServerTest" do
    # a valid Ruby symbol but an invalid DBus name; Ticket#38
    dbus_signal :signal_with_a_bang!
  end
rescue DBus::InvalidMethodName
  # raised by the preceding signal declaration
end

describe "ServerTest" do
  before(:each) do
    @bus = DBus::ASessionBus.new
    @svc = @bus.request_service "org.ruby.server-test"
  end

  after(:each) do
    @bus.proxy.ReleaseName "org.ruby.server-test"
  end

  it "tests unexporting an object" do
    obj = Foo.new "/org/ruby/Foo"
    @svc.export obj
    expect(@svc.unexport(obj)).to be_a DBus::Object
  end

  it "tests unexporting an object not exported" do
    obj = Foo.new "/org/ruby/Foo"
    expect(@svc.unexport(obj)).to be false
  end

  it "tests emiting signals" do
    obj = Foo.new "/org/ruby/Foo"
    @svc.export obj
    obj.signal_without_arguments
    obj.signal_with_argument(-0.1)
  end
end