Sha256: 630a0a9ea37d9bfb91b975b77bd661639868da46d5a0b122f74433668ef696d9

Contents?: true

Size: 1001 Bytes

Versions: 6

Compression:

Stored size: 1001 Bytes

Contents

require 'helper'

module Keyrack
  module Store
    class TestSSH < Test::Unit::TestCase
      def test_read
        store = SSH.new('host' => 'example.com', 'user' => 'dude', 'path' => 'foo.txt')
        Net::SCP.expects(:download!).with("example.com", "dude", "foo.txt").returns("foo")
        assert_equal "foo", store.read
      end

      def test_write
        store = SSH.new('host' => 'example.com', 'user' => 'dude', 'path' => 'foo.txt')
        Net::SCP.expects(:upload!).with do |host, user, local, remote|
          host == 'example.com' && user == 'dude' && 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 = SSH.new('host' => 'example.com', 'user' => 'dude', 'path' => 'foo.txt')
        Net::SCP.expects(:download!).with("example.com", "dude", "foo.txt").raises(Net::SCP::Error)
        assert_nil store.read
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
keyrack-0.2.2 test/keyrack/store/test_ssh.rb
keyrack-0.2.1 test/keyrack/store/test_ssh.rb
keyrack-0.2.0 test/keyrack/store/test_ssh.rb
keyrack-0.1.3 test/keyrack/store/test_ssh.rb
keyrack-0.1.2 test/keyrack/store/test_ssh.rb
keyrack-0.1.1 test/keyrack/store/test_ssh.rb