File: object_manager_spec.rb

package info (click to toggle)
ruby-dbus 0.25.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 776 kB
  • sloc: ruby: 6,584; xml: 225; sh: 38; makefile: 8
file content (33 lines) | stat: -rwxr-xr-x 1,039 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
#!/usr/bin/env rspec
# frozen_string_literal: true

require_relative "spec_helper"
require "dbus"

describe DBus::ObjectManager do
  describe "GetManagedObjects" do
    let(:bus) { DBus::ASessionBus.new }
    let(:service) { bus["org.ruby.service"] }
    let(:obj) { service["/org/ruby/MyInstance"] }
    let(:parent_iface) { obj["org.ruby.TestParent"] }
    let(:om_iface) { obj["org.freedesktop.DBus.ObjectManager"] }

    it "returns the interfaces and properties of currently managed objects" do
      c1_opath = parent_iface.New("child1")
      c2_opath = parent_iface.New("child2")

      parent_iface.Delete(c1_opath)
      expected_gmo = {
        "/org/ruby/MyInstance/child2" => {
          "org.freedesktop.DBus.Introspectable" => {},
          "org.freedesktop.DBus.Properties" => {},
          "org.ruby.TestChild" => { "Name" => "Child2" }
        }
      }
      expect(om_iface.GetManagedObjects).to eq(expected_gmo)

      parent_iface.Delete(c2_opath)
      expect(om_iface.GetManagedObjects).to eq({})
    end
  end
end