File: proxy_object_spec.rb

package info (click to toggle)
ruby-dbus 0.25.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 776 kB
  • sloc: ruby: 6,584; xml: 225; sh: 38; makefile: 8
file content (53 lines) | stat: -rwxr-xr-x 1,488 bytes parent folder | download
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
# frozen_string_literal: true

require_relative "spec_helper"
require "dbus"

describe DBus::ProxyObject do
  around(:each) do |example|
    with_private_bus do
      with_service_by_activation(&example)
    end
  end

  let(:bus) { DBus::ASessionBus.new }

  context "when calling org.ruby.service" do
    let(:svc) { bus["org.ruby.service"] }

    context "when introspection mode is not specified" do
      describe "#bounce_variant" do
        it "works without an explicit #introspect call" do
          obj = svc["/org/ruby/MyInstance"]
          ifc = obj["org.ruby.SampleInterface"]
          expect(ifc.bounce_variant(42)).to be_eql 42
        end

        it "works with one #introspect call" do
          obj = svc["/org/ruby/MyInstance"]
          obj.introspect
          ifc = obj["org.ruby.SampleInterface"]
          expect(ifc.bounce_variant(42)).to be_eql 42
        end

        it "works with two #introspect calls" do
          obj = svc["/org/ruby/MyInstance"]
          obj.introspect
          obj.introspect
          ifc = obj["org.ruby.SampleInterface"]
          expect(ifc.bounce_variant(42)).to be_eql 42
        end
      end
    end

    describe "#[]" do
      it "raises when the interface is not found" do
        obj = svc["/org/ruby/MyInstance"]
        expect { obj["org.ruby.NoSuchInterface"] }.to raise_error(DBus::Error) do |e|
          expect(e.message).to match(/no such interface/)
        end
      end
    end
  end
end