From 224ae6be5fc0b5d546425a54050db0189d9ec1b1 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Thu, 9 Apr 2015 00:11:23 +0000 Subject: [PATCH] Implement Runner#run_until --- lib/uh/wm/runner.rb | 4 ++++ spec/uh/wm/runner_spec.rb | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/uh/wm/runner.rb b/lib/uh/wm/runner.rb index a4dd118..f279c9f 100644 --- a/lib/uh/wm/runner.rb +++ b/lib/uh/wm/runner.rb @@ -29,6 +29,10 @@ module Uh @manager.connect @env.log "Connected to X server" end + + def run_until &block + @manager.handle_pending_events until block.call + end end end end diff --git a/spec/uh/wm/runner_spec.rb b/spec/uh/wm/runner_spec.rb index 6b40cd4..014c795 100644 --- a/spec/uh/wm/runner_spec.rb +++ b/spec/uh/wm/runner_spec.rb @@ -73,6 +73,15 @@ module Uh runner.connect_manager end end + + describe '#run_until' do + it 'tells the manager to handle 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 + runner.run_until &block + end + end end end end