-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathbyte_array_spec.rb
executable file
·38 lines (31 loc) · 1 KB
/
byte_array_spec.rb
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
#!/usr/bin/env rspec
# frozen_string_literal: true
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