Implement Remote::FS#sftp

This commit is contained in:
Thibault Jouan 2013-09-25 00:17:46 +00:00
parent d240df0281
commit 99710b0df9
2 changed files with 24 additions and 0 deletions

View File

@ -7,6 +7,10 @@ module Producer
def initialize(remote)
@remote = remote
end
def sftp
@sftp ||= @remote.session.sftp.connect
end
end
end
end

View File

@ -10,5 +10,25 @@ module Producer::Core
expect(fs.instance_eval { @remote }).to be remote
end
end
describe '#sftp', :ssh do
before { sftp_story }
it 'builds a new SFTP session' do
expect(remote.session.sftp).to receive(:connect)
fs.sftp
end
it 'returns the new SFTP session' do
session = double('session')
allow(remote.session.sftp).to receive(:connect) { session }
expect(fs.sftp).to be session
end
it 'memoizes the FS' do
allow(remote.session.sftp).to receive(:connect) { Object.new }
expect(fs.sftp).to be fs.sftp
end
end
end
end