class Quails::Engine::CommandsTest
Public Instance Methods
setup()
click to toggle source
# File railties/test/engine/commands_test.rb, line 9 def setup @destination_root = Dir.mktmpdir("bukkits") Dir.chdir(@destination_root) { `bundle exec quails plugin new bukkits --mountable` } end
teardown()
click to toggle source
# File railties/test/engine/commands_test.rb, line 14 def teardown FileUtils.rm_rf(@destination_root) end
test_console_command_work_inside_engine()
click to toggle source
# File railties/test/engine/commands_test.rb, line 33 def test_console_command_work_inside_engine skip "PTY unavailable" unless available_pty? master, slave = PTY.open spawn_command("console", slave) assert_output(">", master) ensure master.puts "quit" end
test_dbconsole_command_work_inside_engine()
click to toggle source
# File railties/test/engine/commands_test.rb, line 43 def test_dbconsole_command_work_inside_engine skip "PTY unavailable" unless available_pty? master, slave = PTY.open spawn_command("dbconsole", slave) assert_output("sqlite>", master) ensure master.puts ".exit" end
test_help_command_work_inside_engine()
click to toggle source
# File railties/test/engine/commands_test.rb, line 18 def test_help_command_work_inside_engine output = capture(:stderr) do Dir.chdir(plugin_path) { `bin/quails --help` } end assert_no_match "NameError", output end
test_runner_command_work_inside_engine()
click to toggle source
# File railties/test/engine/commands_test.rb, line 25 def test_runner_command_work_inside_engine output = capture(:stdout) do Dir.chdir(plugin_path) { system("bin/quails runner 'puts Quails.env'") } end assert_equal "test", output.strip end
test_server_command_work_inside_engine()
click to toggle source
# File railties/test/engine/commands_test.rb, line 53 def test_server_command_work_inside_engine skip "PTY unavailable" unless available_pty? master, slave = PTY.open pid = spawn_command("server", slave) assert_output("Listening on", master) ensure kill(pid) end
Private Instance Methods
kill(pid)
click to toggle source
# File railties/test/engine/commands_test.rb, line 75 def kill(pid) Process.kill("TERM", pid) Process.wait(pid) rescue Errno::ESRCH end
plugin_path()
click to toggle source
# File railties/test/engine/commands_test.rb, line 64 def plugin_path "#{@destination_root}/bukkits" end
spawn_command(command, fd)
click to toggle source
# File railties/test/engine/commands_test.rb, line 68 def spawn_command(command, fd) Process.spawn( "#{plugin_path}/bin/quails #{command}", in: fd, out: fd, err: fd ) end