aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/engine
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-07-25 15:01:33 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-07-25 15:01:33 +0900
commitaf4cef024b40fd425ea7e24fd648591ccd196327 (patch)
tree5949b5a522541268503f74f7540c6e4ea413f044 /railties/test/engine
parent65f861ee1e8cdeec1533c565f949d05cf8195965 (diff)
downloadrails-af4cef024b40fd425ea7e24fd648591ccd196327.tar.gz
rails-af4cef024b40fd425ea7e24fd648591ccd196327.tar.bz2
rails-af4cef024b40fd425ea7e24fd648591ccd196327.zip
Extract `assert_output` and `available_pty?` into `ConsoleHelpers` module
We define almost the same method with multiple tests. Therefore, it extract into module.
Diffstat (limited to 'railties/test/engine')
-rw-r--r--railties/test/engine/commands_test.rb24
1 files changed, 3 insertions, 21 deletions
diff --git a/railties/test/engine/commands_test.rb b/railties/test/engine/commands_test.rb
index b1c937143f..018c7c949e 100644
--- a/railties/test/engine/commands_test.rb
+++ b/railties/test/engine/commands_test.rb
@@ -1,10 +1,9 @@
require "abstract_unit"
-begin
- require "pty"
-rescue LoadError
-end
+require "console_helpers"
class Rails::Engine::CommandsTest < ActiveSupport::TestCase
+ include ConsoleHelpers
+
def setup
@destination_root = Dir.mktmpdir("bukkits")
Dir.chdir(@destination_root) { `bundle exec rails plugin new bukkits --mountable` }
@@ -64,19 +63,6 @@ class Rails::Engine::CommandsTest < ActiveSupport::TestCase
"#{@destination_root}/bukkits"
end
- 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
-
def spawn_command(command, fd)
Process.spawn(
"#{plugin_path}/bin/rails #{command}",
@@ -84,10 +70,6 @@ class Rails::Engine::CommandsTest < ActiveSupport::TestCase
)
end
- def available_pty?
- defined?(PTY) && PTY.respond_to?(:open)
- end
-
def kill(pid)
Process.kill("TERM", pid)
Process.wait(pid)