Sha256: 4698ce5e4e64eeb9f007dbd023be07f354060580492a2fb32e8ef270a28db1a8

Contents?: true

Size: 998 Bytes

Versions: 6

Compression:

Stored size: 998 Bytes

Contents

#!/usr/bin/env rspec
require_relative "spec_helper"

require "dbus"

describe "ByteArrayTest" do
  before(:each) do
    @bus = DBus::ASessionBus.new
    @svc = @bus.service("org.ruby.service")
    @obj = @svc.object("/org/ruby/MyInstance")
    @obj.default_iface = "org.ruby.SampleInterface"
  end

  it "tests passing byte array" do
    data = [0, 77, 255]
    result = @obj.mirror_byte_array(data).first
    expect(result).to eq(data)
  end

  it "tests passing byte array from string" do
    data = "AAA"
    result = @obj.mirror_byte_array(data).first
    expect(result).to eq([65, 65, 65])
  end

  it "tests passing byte array from hash" do
    # Hash is an Enumerable, but is caught earlier
    data = { "this will" => "fail" }
    expect { @obj.mirror_byte_array(data).first }.to raise_error(DBus::TypeException)
  end

  it "tests passing byte array from nonenumerable" do
    data = Time.now
    expect { @obj.mirror_byte_array(data).first }.to raise_error(DBus::TypeException)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-dbus-0.17.0 spec/byte_array_spec.rb
ruby-dbus-0.16.0 spec/byte_array_spec.rb
ruby-dbus-0.15.0 spec/byte_array_spec.rb
ruby-dbus-0.14.1 spec/byte_array_spec.rb
ruby-dbus-0.14.0 spec/byte_array_spec.rb
ruby-dbus-0.13.0 spec/byte_array_spec.rb