Sha256: 8f3f0ceb46685f22c6389141e873b5613581a8e011982a8e3a9d77b80cc93a65

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

#!/usr/bin/env rspec
# frozen_string_literal: true

# Test the bus class
require_relative "spec_helper"

require "rubygems"
# If we have nokogiri, rexml is normally omitted
# but here we include it for test coverage
require "rexml"
require "dbus"

describe "BusAndXmlBackendTest" do
  before(:each) do
    @bus = DBus::ASessionBus.new
  end

  it "tests introspection reading rexml" do
    DBus::IntrospectXMLParser.backend = DBus::IntrospectXMLParser::REXMLParser
    @svc = @bus.service("org.ruby.service")
    obj = @svc.object("/org/ruby/MyInstance")
    obj.default_iface = "org.ruby.SampleInterface"
    # "should respond to :the_answer"
    expect(obj.the_answer[0]).to eq(42)
    # "should work with multiple interfaces"
    expect(obj["org.ruby.AnotherInterface"].Reverse("foo")[0]).to eq("oof")
  end

  it "tests introspection reading nokogiri" do
    # peek inside the object to see if a cleanup step worked or not
    DBus::IntrospectXMLParser.backend = DBus::IntrospectXMLParser::NokogiriParser
    @svc = @bus.service("org.ruby.service")
    obj = @svc.object("/org/ruby/MyInstance")
    obj.default_iface = "org.ruby.SampleInterface"
    # "should respond to :the_answer"
    expect(obj.the_answer[0]).to eq(42)
    # "should work with multiple interfaces"
    expect(obj["org.ruby.AnotherInterface"].Reverse("foo")[0]).to eq("oof")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-dbus-0.23.1 spec/bus_and_xml_backend_spec.rb
ruby-dbus-0.23.0.beta2 spec/bus_and_xml_backend_spec.rb
ruby-dbus-0.23.0.beta1 spec/bus_and_xml_backend_spec.rb
ruby-dbus-0.22.1 spec/bus_and_xml_backend_spec.rb
ruby-dbus-0.22.0 spec/bus_and_xml_backend_spec.rb