-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathemits_changed_signal_spec.rb
executable file
·58 lines (48 loc) · 1.63 KB
/
emits_changed_signal_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env rspec
# frozen_string_literal: true
require_relative "spec_helper"
require "dbus"
describe DBus::EmitsChangedSignal do
describe "#initialize" do
it "accepts a simple value" do
expect(described_class.new(:const).value).to eq :const
end
it "avoids nil by asking the interface" do
ifc = DBus::Interface.new("org.example.Foo")
ifc.emits_changed_signal = described_class.new(:invalidates)
expect(described_class.new(nil, interface: ifc).value).to eq :invalidates
end
it "fails for unknown value" do
expect { described_class.new(:huh) }.to raise_error(ArgumentError, /Seen :huh/)
end
it "fails for 2 nils" do
expect { described_class.new(nil, interface: nil) }.to raise_error(ArgumentError, /Both/)
end
end
describe "#==" do
it "is true for two different objects with the same value" do
const_a = described_class.new(:const)
const_b = described_class.new(:const)
expect(const_a == const_b).to be true
end
end
describe "#to_xml" do
it "uses a string value" do
expect(described_class.new(:const).to_xml)
.to eq " <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"const\"/>\n"
end
end
describe "#to_s" do
it "uses a string value" do
expect(described_class.new(:const).to_s).to eq "const"
end
end
end
describe DBus::Interface do
describe ".emits_changed_signal=" do
it "only allows an EmitsChangedSignal as argument" do
ifc = described_class.new("org.ruby.Interface")
expect { ifc.emits_changed_signal = :const }.to raise_error(TypeError)
end
end
end