diff --git a/lib/uh/wm/manager.rb b/lib/uh/wm/manager.rb index 5fb9089..5dc6edb 100644 --- a/lib/uh/wm/manager.rb +++ b/lib/uh/wm/manager.rb @@ -16,6 +16,10 @@ module Uh @clients = [] end + def to_io + IO.new(@display.fileno) + end + def connect @events.emit :connecting, args: @display @display.open diff --git a/spec/uh/wm/manager_spec.rb b/spec/uh/wm/manager_spec.rb index 4c498b3..a18f918 100644 --- a/spec/uh/wm/manager_spec.rb +++ b/spec/uh/wm/manager_spec.rb @@ -15,6 +15,18 @@ module Uh expect(manager.clients).to be_empty end + describe '#to_io', :xvfb do + context 'when connected' do + before { manager.connect } + + it 'returns an IO object wrapping the display file descriptor' do + expect(manager.to_io) + .to be_an(IO) + .and have_attributes(fileno: display.fileno) + end + end + end + describe '#connect', :xvfb do it 'opens the display' do expect(manager.display).to receive(:open).and_call_original