diff options
author | Jamis Buck <jamis@37signals.com> | 2007-08-26 04:03:39 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2007-08-26 04:03:39 +0000 |
commit | aaa563330f8c11078ff007c769406740a1ecf875 (patch) | |
tree | 72568db1fb0fb1dde0bd962f3a088c52980846bf | |
parent | 952d84d8e1b9a85e870f017a034481b5d40d3523 (diff) | |
download | net-ssh-aaa563330f8c11078ff007c769406740a1ecf875.tar.gz |
more tweaks to the testing module
git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@208 1d2a57f2-1ded-0310-ad52-83097a15a5de
-rw-r--r-- | lib/net/ssh/test.rb | 5 | ||||
-rw-r--r-- | lib/net/ssh/test/script.rb | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/net/ssh/test.rb b/lib/net/ssh/test.rb index bc46a39..fe8f510 100644 --- a/lib/net/ssh/test.rb +++ b/lib/net/ssh/test.rb @@ -7,7 +7,8 @@ module Net; module SSH module Test def story - yield socket.script + yield socket.script if block_given? + return socket.script end def socket(options={}) @@ -22,7 +23,7 @@ module Net; module SSH @transport ||= Net::SSH::Transport::Session.new(options[:host] || "localhost", options.merge(:kex => "test", :host_key => "ssh-rsa", :paranoid => false, :proxy => socket(options))) end - def assert_script + def assert_scripted raise "there is no script to be processed" if socket.script.events.empty? yield assert socket.script.events.empty?, "there should not be any remaining scripted events, but there are still #{socket.script.events.length} pending" diff --git a/lib/net/ssh/test/script.rb b/lib/net/ssh/test/script.rb index 9be2617..69b5d92 100644 --- a/lib/net/ssh/test/script.rb +++ b/lib/net/ssh/test/script.rb @@ -11,12 +11,16 @@ module Net; module SSH; module Test @events = [] end - def opens_channel + def opens_channel(confirm=true) channel = Channel.new(self) channel.remote_id = 5555 events << LocalPacket.new(:channel_open) { |p| channel.local_id = p[:remote_id] } - events << RemotePacket.new(:channel_open_confirmation, channel.local_id, channel.remote_id, 0x20000, 0x10000) + + if confirm + events << RemotePacket.new(:channel_open_confirmation, channel.local_id, channel.remote_id, 0x20000, 0x10000) + end + channel end @@ -72,7 +76,7 @@ module Net; module SSH; module Test end def process(packet) - event = events.shift or raise "end of script reached, but got a packet type #{packet.type}" + event = events.shift or raise "end of script reached, but got a packet type #{packet.read_byte}" event.process(packet) end end |