Sha256: 67bd4883bc76899882fde1d2e4eeedd0cf8280987441c9e1e786143100c31d8e
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require 'helper' class TestSSH < Test::Unit::TestCase def test_read store = Keyrack::Store::SSH.new('host' => 'example.com', 'user' => 'dude', 'port' => 22, 'path' => 'foo.txt') scp = mock('scp session') scp.expects(:download!).with("foo.txt").returns("foo") session = mock('ssh session', :scp => scp) Net::SSH.expects(:start).with('example.com', 'dude', :port => 22).yields(session) assert_equal "foo", store.read end def test_write store = Keyrack::Store::SSH.new('host' => 'example.com', 'user' => 'dude', 'path' => 'foo.txt') scp = mock('scp session') session = mock('ssh session', :scp => scp) Net::SSH.expects(:start).with('example.com', 'dude', :port => 22).yields(session) scp.expects(:upload!).with do |local, remote| local.is_a?(StringIO) && local.read == "foo" && remote == "foo.txt" end store.write("foo") end def test_read_returns_nil_for_non_existant_file store = Keyrack::Store::SSH.new('host' => 'example.com', 'user' => 'dude', 'port' => 22, 'path' => 'foo.txt') scp = mock('scp session') scp.expects(:download!).with("foo.txt").raises(Net::SCP::Error) session = mock('ssh session', :scp => scp) Net::SSH.expects(:start).with('example.com', 'dude', :port => 22).yields(session) assert_nil store.read end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
keyrack-0.3.2 | test/unit/store/test_ssh.rb |
keyrack-0.3.1 | test/unit/store/test_ssh.rb |
keyrack-0.3.0 | test/unit/store/test_ssh.rb |