Implement Manager#to_io

This commit is contained in:
Thibault Jouan 2015-04-17 15:13:18 +00:00
parent 799cb3f5d9
commit 18667e2492
2 changed files with 16 additions and 0 deletions

View File

@ -16,6 +16,10 @@ module Uh
@clients = [] @clients = []
end end
def to_io
IO.new(@display.fileno)
end
def connect def connect
@events.emit :connecting, args: @display @events.emit :connecting, args: @display
@display.open @display.open

View File

@ -15,6 +15,18 @@ module Uh
expect(manager.clients).to be_empty expect(manager.clients).to be_empty
end 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 describe '#connect', :xvfb do
it 'opens the display' do it 'opens the display' do
expect(manager.display).to receive(:open).and_call_original expect(manager.display).to receive(:open).and_call_original