Class | Net::SSH::Test::Channel |
In: |
lib/net/ssh/test/channel.rb
|
Parent: | Object |
A mock channel, used for scripting actions in tests. It wraps a Net::SSH::Test::Script instance, and delegates to it for the most part. This class has little real functionality on its own, but rather acts as a convenience for scripting channel-related activity for later comparison in a unit test.
story do |session| channel = session.opens_channel channel.sends_exec "ls" channel.gets_data "result of ls" channel.gets_close channel.sends_close end
local_id | [W] | Sets the local-id of this channel object (the id assigned by the client). |
remote_id | [W] | Sets the remote-id of this channel object (the id assigned by the mock-server). |
script | [R] | The Net::SSH::Test::Script instance employed by this mock channel. |
Creates a new Test::Channel instance on top of the given script (which must be a Net::SSH::Test::Script instance).
Because adjacent calls to gets_data will sometimes cause the data packets to be concatenated (causing expectations in tests to fail), you may need to separate those calls with calls to inject_remote_delay! (which essentially just mimics receiving an empty data packet):
channel.gets_data "abcdefg" channel.inject_remote_delay! channel.gets_data "hijklmn"
Returns the local (client-assigned) id for this channel, or a Proc object that will return the local-id later if the local id has not yet been set. (See Net::SSH::Test::Packet#instantiate!.)
Returns the remote (server-assigned) id for this channel, or a Proc object that will return the remote-id later if the remote id has not yet been set. (See Net::SSH::Test::Packet#instantiate!.)
Scripts the sending of an "exec" channel request packet to the mock server. If reply is true, then the server is expected to reply to the request, otherwise no response to this request will be sent. If success is true, then the request will be successful, otherwise a failure will be scripted.
channel.sends_exec "ls -l"
Scripts the sending of a "subsystem" channel request packet to the mock server. See sends_exec for a discussion of the meaning of the reply and success arguments.
channel.sends_subsystem "sftp"