From 0529fab3c2ed0461f90e570b2159919d5874dcd9 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 30 Aug 2013 05:43:40 +0000 Subject: [PATCH] Import Net::SSH::Test::Channel code from net-sftp: This class is included in net-ssh, but net-sftp adds some new methods that we need for our tests. This code resides in net-sftp test helper, and can't be required dynamicaly, this change adds a copy of the code we need, hardcoded in NetSSHStoryHelpers. --- spec/support/net_ssh_story_helpers.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/support/net_ssh_story_helpers.rb b/spec/support/net_ssh_story_helpers.rb index ee9f26a..949b408 100644 --- a/spec/support/net_ssh_story_helpers.rb +++ b/spec/support/net_ssh_story_helpers.rb @@ -2,6 +2,24 @@ module NetSSHStoryHelpers require 'net/ssh/test' include Net::SSH::Test + # FIXME: must be moved elsewhere or implemented another way/form. + class ::Net::SSH::Test::Channel + def gets_packet(type, *args) + gets_data(sftp_packet(type, *args)) + end + + def sends_packet(type, *args) + sends_data(sftp_packet(type, *args)) + end + + private + + def sftp_packet(type, *args) + data = Net::SSH::Buffer.from(*args) + Net::SSH::Buffer.from(:long, data.length + 1, :byte, type, :raw, data).to_s + end + end + def story_with_new_channel story do |session| ch = session.opens_channel