Modify Remote::FS interface:

* Accept SFTP session in FS constructor;
* Modify Remote to build the session required by FS;
* Change TestEnvHelpers#build_remote in order to provided a test double
  as the remote FS.
This commit is contained in:
Thibault Jouan
2014-01-23 22:21:10 +00:00
parent 65c727d5da
commit f45d0b5a20
5 changed files with 18 additions and 59 deletions

View File

@@ -68,20 +68,11 @@ module Producer::Core
end
describe '#fs' do
it 'builds a new FS' do
expect(Remote::FS).to receive :new
remote.fs
end
let(:sftp_session) { double 'sftp session' }
it 'returns the new FS instance' do
fs = double 'fs'
allow(Remote::FS).to receive(:new) { fs }
expect(remote.fs).to be fs
end
it 'memoizes the FS' do
allow(Remote::FS).to receive(:new) { Object.new }
expect(remote.fs).to be remote.fs
it 'returns an FS instance built with a new sftp session' do
remote.stub_chain(:session, :sftp, :connect) { sftp_session }
expect(remote.fs.sftp).to be sftp_session
end
end