Sha256: 9964cfa03c8aa04bac92ef24a1d3b575948554232a38f4c563ad096adcac8e1d

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby
# Test the bus class
require "test/unit"
require 'rubygems'
require 'nokogiri'
require "dbus"

class BusAndXmlBackendTest < Test::Unit::TestCase
  def setup
    @bus = DBus::ASessionBus.new
  end

  def test_introspection_reading_rexml
    DBus::IntrospectXMLParser.backend = DBus::IntrospectXMLParser::REXMLParser
    @svc = @bus.service("org.ruby.service")
    obj = @svc.object("/org/ruby/MyInstance")
    obj.default_iface = 'org.ruby.SampleInterface'
    obj.introspect
    assert_nothing_raised do
      assert_equal 42, obj.the_answer[0], "should respond to :the_answer"
    end
    assert_nothing_raised do
      assert_equal "oof", obj["org.ruby.AnotherInterface"].Reverse('foo')[0], "should work with multiple interfaces"
    end
  end

  def test_introspection_reading_nokogiri
    # 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'
    obj.introspect
    assert_nothing_raised do
      assert_equal 42, obj.the_answer[0], "should respond to :the_answer"
    end
    assert_nothing_raised do
      assert_equal "oof", obj["org.ruby.AnotherInterface"].Reverse('foo')[0], "should work with multiple interfaces"
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-dbus-0.9.1 test/bus_and_xml_backend_test.rb
ruby-dbus-0.9.0 test/bus_and_xml_backend_test.rb
ruby-dbus-0.8.0 test/bus_and_xml_backend_test.rb