Extract user acceptance test helpers in a module
This commit is contained in:
@@ -1,20 +1,3 @@
|
||||
def uhwm_wait_output message, timeout: 1
|
||||
Timeout.timeout(timeout) do
|
||||
loop do
|
||||
break if case message
|
||||
when Regexp then @process.stdout + @process.stderr =~ message
|
||||
when String then assert_partial_output_interactive message
|
||||
end
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
rescue Timeout::Error
|
||||
fail [
|
||||
"expected `#{message}' not seen after #{timeout} seconds in:",
|
||||
" ```\n #{@process.stdout + @process.stderr} ```"
|
||||
].join "\n"
|
||||
end
|
||||
|
||||
Then /^the output must contain exactly the usage$/ do
|
||||
assert_exact_output <<-eoh, all_output
|
||||
Usage: uhwm [options]
|
||||
@@ -29,17 +12,13 @@ options:
|
||||
end
|
||||
|
||||
Then /^the output must match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
||||
expect(@process.stdout).to match Regexp.new(pattern, options)
|
||||
end
|
||||
|
||||
Then /^the current output must match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
||||
uhwm_wait_output Regexp.new(pattern, options)
|
||||
end
|
||||
|
||||
Then /^the current output must contain:$/ do |content|
|
||||
Then /^the output must contain:$/ do |content|
|
||||
uhwm_wait_output content.to_s
|
||||
end
|
||||
|
||||
Then /^the current output must contain current display$/ do
|
||||
Then /^the output must contain current display$/ do
|
||||
uhwm_wait_output ENV['DISPLAY']
|
||||
end
|
||||
|
Reference in New Issue
Block a user