class Net::SSH::Test::LocalPacket
of the sends_* methods.
automatically by Net::SSH::Test::Script and Net::SSH::Test::Channel by any
packets that are sent from the local (client) host. These are created
This is a specialization of Net::SSH::Test::Packet for representing mock
def initialize(type, *args, &block)
optional block, which is used to finalize the initialization of the
Extend the default Net::SSH::Test::Packet constructor to also accept an
def initialize(type, *args, &block) super(type, *args) @init = block end
def local?
def local? true end
def process(packet)
if what was sent matches what was scripted. If it differs in any way,
packet it was given with the contents of this LocalPacket's data, to see
to mimic remote processing of a locally-sent packet. It compares the
Called by Net::SSH::Test::Extensions::PacketStream#test_enqueue_packet
def process(packet) @init.call(Net::SSH::Packet.new(packet.to_s)) if @init type = packet.read_byte raise "expected #{@type}, but got #{type}" if @type != type @data.zip(types).each do |expected, _type| _type ||= case expected when nil then break when Numeric then :long when String then :string when TrueClass, FalseClass then :bool end actual = packet.send("read_#{_type}") next if expected.nil? raise "expected #{_type} #{expected.inspect} but got #{actual.inspect}" unless expected == actual end end