rails/railties/test/console_helpers.rb
Yasuo Honda 1b736a8720 Do not run tests that have ensure instead of skip
Even if tests are "skipped" by `Minitest::Assertions#skip`
`ensure` is executed because tests methods are Ruby methods.

Adding conditions outside of the test methods, entire test methods are
executed only when they are necessary.
2022-09-20 22:12:20 +09:00

26 lines
508 B
Ruby

# frozen_string_literal: true
begin
require "pty"
rescue LoadError
end
module ConsoleHelpers
def assert_output(expected, io, timeout = 10)
timeout = Time.now + timeout
output = +""
until output.include?(expected) || Time.now > timeout
if IO.select([io], [], [], 0.1)
output << io.read(1)
end
end
assert_includes output, expected, "#{expected.inspect} expected, but got:\n\n#{output}"
end
end
def available_pty?
defined?(PTY) && PTY.respond_to?(:open)
end