Integrate blocking and multiplexing workers usage

This commit is contained in:
Thibault Jouan
2015-04-17 21:25:43 +00:00
parent fa03cd736a
commit 9ea43ee69a
7 changed files with 35 additions and 3 deletions

View File

@@ -176,6 +176,15 @@ module Uh
end
end
context 'with worker option' do
let(:arguments) { %w[-w mux] }
it 'assigns the worker type in the env' do
cli.parse_arguments!
expect(cli.env.worker).to eq :mux
end
end
context 'with invalid option' do
let(:arguments) { %w[--unknown-option] }

View File

@@ -144,10 +144,15 @@ module Uh
end
describe '#run_until' do
it 'tells the manager to handle events until given block is true' do
it 'tells the worker to watch the manager' do
expect(runner.worker).to receive(:watch).with runner.manager
runner.run_until { true }
end
it 'tells the worker to work events until given block is true' do
block = proc { }
allow(block).to receive(:call).and_return(false, false, false, true)
expect(runner.manager).to receive(:handle_pending_events).exactly(3).times
expect(runner.worker).to receive(:work_events).exactly(3).times
runner.run_until &block
end
end