spec/net-ssh-simple.rb in net-ssh-simple-1.4.5 vs spec/net-ssh-simple.rb in net-ssh-simple-1.5.0
- old
+ new
@@ -43,11 +43,11 @@
end
it "enforces idle timeout" do
raised = false
begin
- r = Net::SSH::Simple.ssh('localhost', 'sleep 60', {:timeout => 1})
+ r = Net::SSH::Simple.ssh('localhost', 'sleep 60', {:timeout => 5, :keepalive_interval => 1})
rescue => e
raised = true
e.to_s.should match /^idle timeout @ .*/
e.result.op == :ssh
e.result.timed_out.should == true
@@ -122,9 +122,17 @@
raised.should == true
end
it "returns a result" do
Net::SSH::Simple.ssh('localhost', 'true').success.should == true
+ end
+
+ it "sends keep-alive" do
+ r = Net::SSH::Simple.ssh('localhost', 'sleep 3', {:keepalive_interval=>1})
+ (Time.now - r.last_keepalive_at).to_i.should < 3
+
+ r = Net::SSH::Simple.ssh('localhost', 'sleep 3', {:keepalive_interval=>5})
+ (Time.now - r.last_keepalive_at).to_i.should > 2
end
it "recognizes exit-codes" do
Net::SSH::Simple.ssh('localhost', 'true').exit_code.should == 0
Net::SSH::Simple.ssh('localhost', 'false').exit_code.should == 1