mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
6efd009569
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@3786 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
43 lines
1 KiB
Ruby
43 lines
1 KiB
Ruby
$:.unshift File.dirname(__FILE__) + "/../lib"
|
|
|
|
require 'stringio'
|
|
require 'test/unit'
|
|
require 'capistrano/command'
|
|
|
|
class CommandTest < Test::Unit::TestCase
|
|
class MockSession
|
|
def open_channel
|
|
{ :closed => true, :status => 0 }
|
|
end
|
|
end
|
|
|
|
class MockActor
|
|
attr_reader :sessions
|
|
|
|
def initialize
|
|
@sessions = Hash.new { |h,k| h[k] = MockSession.new }
|
|
end
|
|
end
|
|
|
|
def setup
|
|
@actor = MockActor.new
|
|
end
|
|
|
|
def test_command_executes_on_all_servers
|
|
command = Capistrano::Command.new(%w(server1 server2 server3),
|
|
"hello", nil, {}, @actor)
|
|
assert_equal %w(server1 server2 server3), @actor.sessions.keys.sort
|
|
end
|
|
|
|
def test_command_with_newlines
|
|
command = Capistrano::Command.new(%w(server1), "hello\nworld", nil, {},
|
|
@actor)
|
|
assert_equal "hello\\\nworld", command.command
|
|
end
|
|
|
|
def test_command_with_windows_newlines
|
|
command = Capistrano::Command.new(%w(server1), "hello\r\nworld", nil, {},
|
|
@actor)
|
|
assert_equal "hello\\\nworld", command.command
|
|
end
|
|
end
|