class Net::SSH::Test::Channel

end
channel.sends_close
channel.gets_close
channel.gets_extended_data “some error coming from ls”
channel.gets_data “result of ls”
channel.sends_exec “ls”
channel = session.opens_channel
story do |session|
in a unit test.
a convenience for scripting channel-related activity for later comparison
This class has little real functionality on its own, but rather acts as
Net::SSH::Test::Script instance, and delegates to it for the most part.
A mock channel, used for scripting actions in tests. It wraps a

def gets_close

channel.gets_close

Scripts the reception of a "channel close" packet from the remote end.
def gets_close
  script.gets_channel_close(self)
end

def gets_data(data)

channel.gets_data "bar"

Scripts the reception of a channel data packet from the remote end.
def gets_data(data)
  script.gets_channel_data(self, data)
end

def gets_eof

channel.gets_eof

Scripts the reception of an EOF packet from the remote end.
def gets_eof
  script.gets_channel_eof(self)
end

def gets_exit_status(status = 0)

channel.gets_exit_status(127)

Scripts the reception of an "exit-status" channel request packet.
def gets_exit_status(status = 0)
  script.gets_channel_request(self, "exit-status", false, status)
end

def gets_extended_data(data)

channel.gets_extended_data "whoops"

end.
Scripts the reception of a channel extended data packet from the remote
def gets_extended_data(data)
  script.gets_channel_extended_data(self, data)
end

def initialize(script)

must be a Net::SSH::Test::Script instance).
Creates a new Test::Channel instance on top of the given +script+ (which
def initialize(script)
  @script = script
  @local_id = @remote_id = nil
end

def inject_remote_delay!

channel.gets_data "hijklmn"
channel.inject_remote_delay!
channel.gets_data "abcdefg"

essentially just mimics receiving an empty data packet):
need to separate those calls with calls to #inject_remote_delay! (which
to be concatenated (causing expectations in tests to fail), you may
Because adjacent calls to #gets_data will sometimes cause the data packets
def inject_remote_delay!
  gets_data("")
end

def local_id

(See Net::SSH::Test::Packet#instantiate!.)
that will return the local-id later if the local id has not yet been set.
Returns the local (client-assigned) id for this channel, or a Proc object
def local_id
  @local_id || Proc.new { @local_id or raise "local-id has not been set yet!" }
end

def remote_id

(See Net::SSH::Test::Packet#instantiate!.)
that will return the remote-id later if the remote id has not yet been set.
Returns the remote (server-assigned) id for this channel, or a Proc object
def remote_id
  @remote_id || Proc.new { @remote_id or raise "remote-id has not been set yet!" }
end

def sends_close

channel.sends_close

Scripts the sending of a "channel close" packet across the channel.
def sends_close
  script.sends_channel_close(self)
end

def sends_data(data)

channel.sends_data "foo"

Scripts the sending of a data packet across the channel.
def sends_data(data)
  script.sends_channel_data(self, data)
end

def sends_eof

channel.sends_eof

Scripts the sending of an EOF packet across the channel.
def sends_eof
  script.sends_channel_eof(self)
end

def sends_exec(command, reply = true, success = true)

channel.sends_exec "ls -l"

be scripted.
is +true+, then the request will be successful, otherwise a failure will
request, otherwise no response to this request will be sent. If +success+
server. If +reply+ is true, then the server is expected to reply to the
Scripts the sending of an "exec" channel request packet to the mock
def sends_exec(command, reply = true, success = true)
  script.sends_channel_request(self, "exec", reply, command, success)
end

def sends_request_pty

channel.sends_request_pty

Scripts the sending of a "request pty" request packet across the channel.
def sends_request_pty
  script.sends_channel_request_pty(self)
end

def sends_subsystem(subsystem, reply = true, success = true)

channel.sends_subsystem "sftp"

and +success+ arguments.
server. See #sends_exec for a discussion of the meaning of the +reply+
Scripts the sending of a "subsystem" channel request packet to the mock
def sends_subsystem(subsystem, reply = true, success = true)
  script.sends_channel_request(self, "subsystem", reply, subsystem, success)
end