Sha256: 70c665cb4105537392d1952b14c0a28a86dc7931428ab8ebd08e8e3a63544687

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

#!/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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-dbus-0.17.0 spec/server_spec.rb
ruby-dbus-0.16.0 spec/server_spec.rb
ruby-dbus-0.15.0 spec/server_spec.rb
ruby-dbus-0.14.1 spec/server_spec.rb
ruby-dbus-0.14.0 spec/server_spec.rb
ruby-dbus-0.13.0 spec/server_spec.rb
ruby-dbus-0.12.0 spec/server_spec.rb
ruby-dbus-0.11.2 spec/server_spec.rb
ruby-dbus-0.11.1 spec/server_spec.rb