diff --git a/features/steps/output_steps.rb b/features/steps/output_steps.rb index 9bf2ea2..eb48120 100644 --- a/features/steps/output_steps.rb +++ b/features/steps/output_steps.rb @@ -1,3 +1,14 @@ +def uhwm_wait_output message, timeout: 1 + Timeout.timeout(timeout) do + loop do + break if assert_partial_output_interactive message + sleep 0.1 + end + end +rescue Timeout::Error + fail "expected message `#{message}' not seen after #{timeout} seconds" +end + Then /^the output must contain exactly the usage$/ do assert_exact_output <<-eoh, all_output Usage: uhwm [options] diff --git a/features/steps/x_steps.rb b/features/steps/x_steps.rb index cb32a42..d7bcd9e 100644 --- a/features/steps/x_steps.rb +++ b/features/steps/x_steps.rb @@ -1,10 +1,5 @@ Then /^it must connect to X display$/ do - Timeout.timeout(exit_timeout) do - loop do - break if assert_partial_output_interactive 'Connected to' - sleep 0.1 - end - end + uhwm_wait_output 'Connected to' expect(`sockstat -u`.lines.grep /\s+ruby.+\s+#{@process.pid}/) .not_to be_empty end