Sha256: e5a7fbdae2896639833cf3f64615cbcff4fd0858473f101fd65343c7b0ab33d0
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'spec_helper' describe Net::SSH::Session do describe '#initialize' do context 'with :timeout option' do it 'raises error if timeout value is not numeric' do expect { Net::SSH::Session.new('host', 'user', 'password', :timeout => 'data') }.to raise_error ArgumentError, "Timeout value should be numeric" end it 'sets global session timeout value' do session = Net::SSH::Session.new('host', 'user', 'password', :timeout => 1) expect(session.timeout).to eq 1 end end end describe '#method_missing' do let(:session) { Net::SSH::Session.new('host', 'user', 'password') } before { session.stub(:run).with("uname").and_return(fake_run("uname", "Linux")) } it 'runs a command based on missing method name' do expect(session.uname.output).to eq "Linux" end end describe '#run' do context 'when session timeout is set' do let(:process) do proc { sleep 5 } end let(:session) do Net::SSH::Session.new('host', 'user', 'password', :timeout => 1) end before do session.stub_chain(:shell, :execute).with('foo') { process.call } end it 'raises error if operation timed out' do expect { session.run('foo') }.to raise_error Timeout::Error end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
net-ssh-session-0.1.6 | spec/session_spec.rb |
net-ssh-session-0.1.5 | spec/session_spec.rb |