Skip to content

Commit 7ddabb9

Browse files
committed
Quit the testing service explicitly so that simplecov-lcov can merge the data
1 parent dee79c9 commit 7ddabb9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

spec/service_newapi.rb

+8
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,23 @@
1313
class Test < DBus::Object
1414
Point2D = Struct.new(:x, :y)
1515

16+
attr_writer :main_loop
17+
1618
INTERFACE = "org.ruby.SampleInterface"
1719
def initialize(path)
1820
super path
1921
@read_me = "READ ME"
2022
@read_or_write_me = "READ OR WRITE ME"
2123
@my_struct = ["three", "strings", "in a struct"].freeze
24+
@main_loop = nil
2225
end
2326

2427
# Create an interface aggregating all upcoming dbus_method defines.
2528
dbus_interface INTERFACE do
29+
dbus_method :quit, "" do
30+
@main_loop&.quit
31+
end
32+
2633
dbus_method :hello, "in name:s, in name2:s" do |name, name2|
2734
puts "hello(#{name}, #{name2})"
2835
end
@@ -193,6 +200,7 @@ class Test2 < DBus::Object
193200
puts "listening, with ruby-#{RUBY_VERSION}"
194201
main = DBus::Main.new
195202
main << bus
203+
myobj.main_loop = main
196204
begin
197205
main.run
198206
rescue SystemCallError

spec/zzz_quit_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env rspec
2+
# frozen_string_literal: true
3+
4+
require_relative "spec_helper"
5+
require "dbus"
6+
7+
describe "Quit the service" do
8+
it "Tells the service to quit and waits, to collate coverage data" do
9+
session_bus = DBus::ASessionBus.new
10+
@svc = session_bus.service("org.ruby.service")
11+
@obj = @svc.object("/org/ruby/MyInstance")
12+
@obj.default_iface = "org.ruby.SampleInterface"
13+
@obj.quit
14+
sleep 3
15+
end
16+
end

0 commit comments

Comments
 (0)