2008-04-25 11:21:12 -04:00
|
|
|
require "utils"
|
2006-03-05 22:48:35 -05:00
|
|
|
require 'capistrano/command'
|
2008-08-21 16:29:28 -04:00
|
|
|
require 'capistrano/configuration'
|
2005-08-06 15:35:25 -04:00
|
|
|
|
|
|
|
class CommandTest < Test::Unit::TestCase
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_command_should_open_channels_on_all_sessions
|
2008-08-21 16:29:28 -04:00
|
|
|
s1, s2, s3 = mock_session, mock_session, mock_session
|
|
|
|
assert_equal "ls", Capistrano::Command.new("ls", [s1, s2, s3]).tree.fallback.command
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_command_with_newlines_should_be_properly_escaped
|
2008-08-21 16:29:28 -04:00
|
|
|
cmd = Capistrano::Command.new("ls\necho", [mock_session])
|
|
|
|
assert_equal "ls\\\necho", cmd.tree.fallback.command
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_command_with_windows_newlines_should_be_properly_escaped
|
2008-08-21 16:29:28 -04:00
|
|
|
cmd = Capistrano::Command.new("ls\r\necho", [mock_session])
|
|
|
|
assert_equal "ls\\\necho", cmd.tree.fallback.command
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
2007-08-31 23:23:51 -04:00
|
|
|
def test_command_with_pty_should_request_pty_and_register_success_callback
|
2008-04-27 23:47:23 -04:00
|
|
|
session = setup_for_extracting_channel_action(:request_pty, true) do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(sh -c 'ls'))
|
2007-08-31 23:23:51 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :pty => true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_command_with_env_key_should_have_environment_constructed_and_prepended
|
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
|
|
|
ch.expects(:request_pty).never
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(env FOO=bar sh -c 'ls'))
|
2007-06-25 11:32:43 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :env => { "FOO" => "bar" })
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_env_with_symbolic_key_should_be_accepted_as_a_string
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(env FOO=bar sh -c 'ls'))
|
2007-06-25 11:32:43 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :env => { :FOO => "bar" })
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_env_as_string_should_be_substituted_in_directly
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(env HOWDY=there sh -c 'ls'))
|
2007-06-25 11:32:43 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :env => "HOWDY=there")
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_env_with_symbolic_value_should_be_accepted_as_string
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(env FOO=bar sh -c 'ls'))
|
2007-06-25 11:32:43 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :env => { "FOO" => :bar })
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_env_value_should_be_escaped
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(env FOO=(\\ \\\"bar\\\"\\ ) sh -c 'ls'))
|
2007-06-25 11:32:43 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :env => { "FOO" => '( "bar" )' })
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_env_with_multiple_keys_should_chain_the_entries_together
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2007-06-25 11:32:43 -04:00
|
|
|
ch.expects(:exec).with do |command|
|
|
|
|
command =~ /^env / &&
|
|
|
|
command =~ /\ba=b\b/ &&
|
|
|
|
command =~ /\bc=d\b/ &&
|
|
|
|
command =~ /\be=f\b/ &&
|
2009-05-19 23:54:57 -04:00
|
|
|
command =~ / sh -c 'ls'$/
|
2007-06-25 11:32:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :env => { :a => :b, :c => :d, :e => :f })
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_open_channel_should_set_host_key_on_channel
|
2008-08-21 16:29:28 -04:00
|
|
|
channel = nil
|
|
|
|
session = setup_for_extracting_channel_action { |ch| channel = ch }
|
2007-03-01 01:23:26 -05:00
|
|
|
Capistrano::Command.new("ls", [session])
|
2008-08-21 16:29:28 -04:00
|
|
|
assert_equal "capistrano", channel[:host]
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_open_channel_should_set_options_key_on_channel
|
2008-08-21 16:29:28 -04:00
|
|
|
channel = nil
|
|
|
|
session = setup_for_extracting_channel_action { |ch| channel = ch }
|
2007-03-01 01:23:26 -05:00
|
|
|
Capistrano::Command.new("ls", [session], :data => "here we go")
|
2008-08-21 16:29:28 -04:00
|
|
|
assert_equal({ :data => 'here we go' }, channel[:options])
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_successful_channel_should_send_command
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(sh -c 'ls'))
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
2007-03-01 01:23:26 -05:00
|
|
|
Capistrano::Command.new("ls", [session])
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
|
|
|
|
2007-06-05 12:10:01 -04:00
|
|
|
def test_successful_channel_with_shell_option_should_send_command_via_specified_shell
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(/bin/bash -c 'ls'))
|
2007-06-05 12:10:01 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :shell => "/bin/bash")
|
|
|
|
end
|
|
|
|
|
2007-08-31 23:31:53 -04:00
|
|
|
def test_successful_channel_with_shell_false_should_send_command_without_shell
|
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
|
|
|
ch.expects(:exec).with(%(echo `hostname`))
|
|
|
|
end
|
|
|
|
Capistrano::Command.new("echo `hostname`", [session], :shell => false)
|
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_successful_channel_should_send_data_if_data_key_is_present
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(sh -c 'ls'))
|
2007-03-01 01:23:26 -05:00
|
|
|
ch.expects(:send_data).with("here we go")
|
|
|
|
end
|
|
|
|
Capistrano::Command.new("ls", [session], :data => "here we go")
|
|
|
|
end
|
|
|
|
|
2007-08-31 23:23:51 -04:00
|
|
|
def test_unsuccessful_pty_request_should_close_channel
|
2008-04-27 23:47:23 -04:00
|
|
|
session = setup_for_extracting_channel_action(:request_pty, false) do |ch|
|
2007-03-01 01:23:26 -05:00
|
|
|
ch.expects(:close)
|
|
|
|
end
|
2007-08-31 23:23:51 -04:00
|
|
|
Capistrano::Command.new("ls", [session], :pty => true)
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_on_data_should_invoke_callback_as_stdout
|
|
|
|
session = setup_for_extracting_channel_action(:on_data, "hello")
|
|
|
|
called = false
|
|
|
|
Capistrano::Command.new("ls", [session]) do |ch, stream, data|
|
|
|
|
called = true
|
|
|
|
assert_equal :out, stream
|
|
|
|
assert_equal "hello", data
|
|
|
|
end
|
|
|
|
assert called
|
|
|
|
end
|
2005-08-06 15:35:25 -04:00
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_on_extended_data_should_invoke_callback_as_stderr
|
|
|
|
session = setup_for_extracting_channel_action(:on_extended_data, 2, "hello")
|
|
|
|
called = false
|
|
|
|
Capistrano::Command.new("ls", [session]) do |ch, stream, data|
|
|
|
|
called = true
|
|
|
|
assert_equal :err, stream
|
|
|
|
assert_equal "hello", data
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
2007-03-01 01:23:26 -05:00
|
|
|
assert called
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_on_request_should_record_exit_status
|
|
|
|
data = mock(:read_long => 5)
|
2008-08-21 16:29:28 -04:00
|
|
|
channel = nil
|
|
|
|
session = setup_for_extracting_channel_action([:on_request, "exit-status"], data) { |ch| channel = ch }
|
2007-03-01 01:23:26 -05:00
|
|
|
Capistrano::Command.new("ls", [session])
|
2008-08-21 16:29:28 -04:00
|
|
|
assert_equal 5, channel[:status]
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
2013-01-20 12:58:24 -05:00
|
|
|
def test_on_request_should_log_exit_signal_if_logger_present
|
|
|
|
data = mock(:read_string => "TERM")
|
|
|
|
logger = stub_everything
|
|
|
|
|
|
|
|
session = setup_for_extracting_channel_action([:on_request, "exit-signal"], data)
|
|
|
|
logger.expects(:important).with("command received signal TERM", server("capistrano"))
|
|
|
|
|
|
|
|
Capistrano::Command.new("puppet", [session], :logger => logger)
|
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_on_close_should_set_channel_closed
|
2008-08-21 16:29:28 -04:00
|
|
|
channel = nil
|
|
|
|
session = setup_for_extracting_channel_action(:on_close) { |ch| channel = ch }
|
2007-03-01 01:23:26 -05:00
|
|
|
Capistrano::Command.new("ls", [session])
|
2008-08-21 16:29:28 -04:00
|
|
|
assert channel[:closed]
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_stop_should_close_all_open_channels
|
2008-04-27 23:47:23 -04:00
|
|
|
sessions = [mock_session(new_channel(false)),
|
|
|
|
mock_session(new_channel(true)),
|
|
|
|
mock_session(new_channel(false))]
|
2007-03-01 01:23:26 -05:00
|
|
|
|
|
|
|
cmd = Capistrano::Command.new("ls", sessions)
|
|
|
|
cmd.stop!
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_process_should_return_cleanly_if_all_channels_have_zero_exit_status
|
2008-04-27 23:47:23 -04:00
|
|
|
sessions = [mock_session(new_channel(true, 0)),
|
|
|
|
mock_session(new_channel(true, 0)),
|
|
|
|
mock_session(new_channel(true, 0))]
|
2007-03-01 01:23:26 -05:00
|
|
|
cmd = Capistrano::Command.new("ls", sessions)
|
|
|
|
assert_nothing_raised { cmd.process! }
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_process_should_raise_error_if_any_channel_has_non_zero_exit_status
|
2008-04-27 23:47:23 -04:00
|
|
|
sessions = [mock_session(new_channel(true, 0)),
|
|
|
|
mock_session(new_channel(true, 0)),
|
|
|
|
mock_session(new_channel(true, 1))]
|
2007-03-01 01:23:26 -05:00
|
|
|
cmd = Capistrano::Command.new("ls", sessions)
|
2007-03-02 16:33:27 -05:00
|
|
|
assert_raises(Capistrano::CommandError) { cmd.process! }
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|
2007-03-01 01:23:26 -05:00
|
|
|
|
2007-03-27 17:41:55 -04:00
|
|
|
def test_command_error_should_include_accessor_with_host_array
|
2008-04-27 23:47:23 -04:00
|
|
|
sessions = [mock_session(new_channel(true, 0)),
|
|
|
|
mock_session(new_channel(true, 0)),
|
|
|
|
mock_session(new_channel(true, 1))]
|
2007-03-27 17:41:55 -04:00
|
|
|
cmd = Capistrano::Command.new("ls", sessions)
|
|
|
|
|
|
|
|
begin
|
|
|
|
cmd.process!
|
|
|
|
flunk "expected an exception to be raised"
|
|
|
|
rescue Capistrano::CommandError => e
|
|
|
|
assert e.respond_to?(:hosts)
|
2007-05-09 00:45:54 -04:00
|
|
|
assert_equal %w(capistrano), e.hosts.map { |h| h.to_s }
|
2007-03-27 17:41:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def test_process_should_loop_until_all_channels_are_closed
|
|
|
|
new_channel = Proc.new do |times|
|
|
|
|
ch = mock("channel")
|
|
|
|
returns = [false] * (times-1)
|
2011-08-23 16:58:11 -04:00
|
|
|
ch.stubs(:to_ary)
|
2007-06-27 23:14:37 -04:00
|
|
|
ch.stubs(:[]).with(:closed).returns(*(returns + [true]))
|
2007-03-01 01:23:26 -05:00
|
|
|
ch.expects(:[]).with(:status).returns(0)
|
|
|
|
ch
|
|
|
|
end
|
|
|
|
|
2008-04-27 23:47:23 -04:00
|
|
|
sessions = [mock_session(new_channel[5]),
|
|
|
|
mock_session(new_channel[10]),
|
|
|
|
mock_session(new_channel[7])]
|
2007-03-01 01:23:26 -05:00
|
|
|
cmd = Capistrano::Command.new("ls", sessions)
|
Release 2.7.0
A fairly substantial release. There are fixes so that current_release
works
during dry-runs, (although, apparently still not with bundler.)
The test-suite was also modified to work with Ruby 1.9.2, except in one
case
where Ruby 1.9.x calls `to_ary` and `to_a` on mocks, which still makes
an
error. 1.9.x has always been supported, but due to lack of maintenance
on my
part the tests didn't ever pass.
The `start`, `stop` and `restart` tasks have been reduced to mere hooks
into
which extensions can define their own functionality.
The `readme` was also slightly improved, simply tweaks to express how
best to
run the test suite.
* Ensure dry-run works with `:current_release` variable (Carol Nichols)
* Added a new variable `:git_submodules_recursive`, setting the value to
* false
will ensure Git doesn't recursively initialize and checkout submodules.
(Konstantin Kudryashov)
* Added an additional task option, `:on_no_matching_servers`, setting
* the
value to `:continue` will ensure tasks with no matched servers continue
without error, instead of raising `Capistrano::NoMatchingServersError`
as was
the previous behaviour. (Chris Griego)
A huge thanks to all contributors, as always!
Remember: @capistranorb on twitter for news.
2011-08-02 20:11:19 -04:00
|
|
|
assert_nothing_raised do
|
|
|
|
cmd.process!
|
|
|
|
end
|
2007-03-01 01:23:26 -05:00
|
|
|
end
|
|
|
|
|
2007-03-04 16:09:37 -05:00
|
|
|
def test_process_should_instantiate_command_and_process!
|
|
|
|
cmd = mock("command", :process! => nil)
|
2008-08-21 16:29:28 -04:00
|
|
|
Capistrano::Command.expects(:new).with("ls -l", %w(a b c), {:foo => "bar"}).returns(cmd)
|
|
|
|
Capistrano::Command.process("ls -l", %w(a b c), :foo => "bar")
|
2007-03-04 16:09:37 -05:00
|
|
|
end
|
|
|
|
|
2011-05-14 16:23:47 -04:00
|
|
|
def test_process_with_host_placeholder_should_substitute_host_placeholder_with_each_host
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(sh -c 'echo capistrano'))
|
2007-03-14 10:22:35 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("echo $CAPISTRANO:HOST$", [session])
|
|
|
|
end
|
|
|
|
|
2011-05-14 16:23:47 -04:00
|
|
|
class MockConfig
|
|
|
|
include Capistrano::Configuration::Roles
|
|
|
|
end
|
2013-01-20 12:58:24 -05:00
|
|
|
|
2011-05-14 16:23:47 -04:00
|
|
|
def test_hostroles_substitution
|
|
|
|
@config = MockConfig.new
|
|
|
|
@config.server "capistrano", :db, :worker
|
|
|
|
server = @config.roles[:db].servers.first
|
|
|
|
channel = {:server => server, :host => 'capistrano'}
|
|
|
|
tree = Capistrano::Command::Tree.new(@config) { |t| t.else("echo $CAPISTRANO:HOSTROLES$") }
|
|
|
|
result = Capistrano::Command.new(tree, []).send(:replace_placeholders, "echo $CAPISTRANO:HOSTROLES$", channel)
|
|
|
|
assert result == "echo db,worker" || result == "echo worker,db"
|
|
|
|
end
|
|
|
|
|
2007-03-14 10:22:35 -04:00
|
|
|
def test_process_with_unknown_placeholder_should_not_replace_placeholder
|
2007-08-31 23:23:51 -04:00
|
|
|
session = setup_for_extracting_channel_action do |ch|
|
2009-05-19 23:54:57 -04:00
|
|
|
ch.expects(:exec).with(%(sh -c 'echo $CAPISTRANO:OTHER$'))
|
2007-03-14 10:22:35 -04:00
|
|
|
end
|
|
|
|
Capistrano::Command.new("echo $CAPISTRANO:OTHER$", [session])
|
|
|
|
end
|
|
|
|
|
2012-07-26 19:14:10 -04:00
|
|
|
def test_input_stream_closed_when_eof_option_is_true
|
|
|
|
channel = nil
|
|
|
|
session = setup_for_extracting_channel_action { |ch| channel = ch }
|
|
|
|
channel.expects(:eof!)
|
|
|
|
Capistrano::Command.new("cat", [session], :data => "here we go", :eof => true)
|
|
|
|
assert_equal({ :data => 'here we go', :eof => true }, channel[:options])
|
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
private
|
|
|
|
|
2008-04-27 23:47:23 -04:00
|
|
|
def mock_session(channel=nil)
|
Release 2.7.0
A fairly substantial release. There are fixes so that current_release
works
during dry-runs, (although, apparently still not with bundler.)
The test-suite was also modified to work with Ruby 1.9.2, except in one
case
where Ruby 1.9.x calls `to_ary` and `to_a` on mocks, which still makes
an
error. 1.9.x has always been supported, but due to lack of maintenance
on my
part the tests didn't ever pass.
The `start`, `stop` and `restart` tasks have been reduced to mere hooks
into
which extensions can define their own functionality.
The `readme` was also slightly improved, simply tweaks to express how
best to
run the test suite.
* Ensure dry-run works with `:current_release` variable (Carol Nichols)
* Added a new variable `:git_submodules_recursive`, setting the value to
* false
will ensure Git doesn't recursively initialize and checkout submodules.
(Konstantin Kudryashov)
* Added an additional task option, `:on_no_matching_servers`, setting
* the
value to `:continue` will ensure tasks with no matched servers continue
without error, instead of raising `Capistrano::NoMatchingServersError`
as was
the previous behaviour. (Chris Griego)
A huge thanks to all contributors, as always!
Remember: @capistranorb on twitter for news.
2011-08-02 20:11:19 -04:00
|
|
|
stub('session',
|
|
|
|
:open_channel => channel,
|
|
|
|
:preprocess => true,
|
|
|
|
:postprocess => true,
|
|
|
|
:listeners => {},
|
|
|
|
:xserver => server("capistrano"))
|
2008-08-21 16:29:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class MockChannel < Hash
|
|
|
|
def close
|
|
|
|
end
|
2008-04-27 23:47:23 -04:00
|
|
|
end
|
|
|
|
|
2007-03-01 01:23:26 -05:00
|
|
|
def new_channel(closed, status=nil)
|
2008-08-21 16:29:28 -04:00
|
|
|
ch = MockChannel.new
|
|
|
|
ch.update({ :closed => closed, :host => "capistrano", :server => server("capistrano") })
|
|
|
|
ch[:status] = status if status
|
2007-03-01 01:23:26 -05:00
|
|
|
ch.expects(:close) unless closed
|
|
|
|
ch
|
|
|
|
end
|
|
|
|
|
2007-08-31 23:23:51 -04:00
|
|
|
def setup_for_extracting_channel_action(action=nil, *args)
|
2007-05-09 00:45:54 -04:00
|
|
|
s = server("capistrano")
|
|
|
|
session = mock("session", :xserver => s)
|
2007-03-01 01:23:26 -05:00
|
|
|
|
2008-08-21 16:29:28 -04:00
|
|
|
channel = {}
|
2007-03-01 01:23:26 -05:00
|
|
|
session.expects(:open_channel).yields(channel)
|
|
|
|
|
2008-08-21 16:29:28 -04:00
|
|
|
channel.stubs(:on_data)
|
|
|
|
channel.stubs(:on_extended_data)
|
|
|
|
channel.stubs(:on_request)
|
|
|
|
channel.stubs(:on_close)
|
|
|
|
channel.stubs(:exec)
|
|
|
|
channel.stubs(:send_data)
|
2008-04-27 23:47:23 -04:00
|
|
|
|
|
|
|
if action
|
|
|
|
action = Array(action)
|
|
|
|
channel.expects(action.first).with(*action[1..-1]).yields(channel, *args)
|
|
|
|
end
|
2007-03-01 01:23:26 -05:00
|
|
|
|
2007-08-31 23:23:51 -04:00
|
|
|
yield channel if block_given?
|
2007-03-01 01:23:26 -05:00
|
|
|
|
|
|
|
session
|
|
|
|
end
|
2005-08-06 15:35:25 -04:00
|
|
|
end
|