Handle Manager logging with events Dispatcher

This commit is contained in:
Thibault Jouan
2015-04-09 23:31:56 +00:00
parent 7b9854b499
commit d965fb2afd
4 changed files with 48 additions and 6 deletions

View File

@@ -12,10 +12,38 @@ module Uh
end
describe '#connect' do
let(:block) { proc { } }
it 'opens the display' do
expect(manager.display).to receive :open
manager.connect
end
it 'emits :display, :connecting event with the display' do
events.on :display, :connecting, &block
expect(block).to receive(:call) do |*args|
expect(args).to eq [display]
end
manager.connect
end
it 'emits :display, :connected event with the display' do
events.on :display, :connected, &block
expect(block).to receive(:call) do |*args|
expect(args).to eq [display]
end
manager.connect
end
context 'when connection fails' do
before { allow(display).to receive(:open) { fail } }
it 'does not emit :display, :connected event' do
events.on :display, :connected, &block
expect(block).not_to receive :call
manager.connect rescue nil
end
end
end
describe '#grab_key' do