diff options
Diffstat (limited to 'railties/test/application/dbconsole_test.rb')
-rw-r--r-- | railties/test/application/dbconsole_test.rb | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/railties/test/application/dbconsole_test.rb b/railties/test/application/dbconsole_test.rb index 12d1cfb089..5d89d0e44d 100644 --- a/railties/test/application/dbconsole_test.rb +++ b/railties/test/application/dbconsole_test.rb @@ -1,12 +1,10 @@ require "isolation/abstract_unit" -begin - require "pty" -rescue LoadError -end +require "console_helpers" module ApplicationTests class DBConsoleTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation + include ConsoleHelpers def setup skip "PTY unavailable" unless available_pty? @@ -64,7 +62,7 @@ module ApplicationTests spawn_dbconsole(slave, "-e production") assert_output("sqlite>", master) - master.puts ".databases" + master.puts "pragma database_list;" assert_output("production.sqlite3", master) ensure master.puts ".exit" @@ -74,22 +72,5 @@ module ApplicationTests def spawn_dbconsole(fd, options = nil) Process.spawn("#{app_path}/bin/rails dbconsole #{options}", in: fd, out: fd, err: fd) end - - def assert_output(expected, io, timeout = 5) - 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 - - def available_pty? - defined?(PTY) && PTY.respond_to?(:open) - end end end |