From 91f2bc35673b2714fe34c06a98da338fba84346e Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Tue, 24 Sep 2013 20:16:08 +0000 Subject: [PATCH] Implement Remote#fs --- lib/producer/core/remote.rb | 4 ++++ spec/producer/core/remote_spec.rb | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/producer/core/remote.rb b/lib/producer/core/remote.rb index e5152b2..bed2936 100644 --- a/lib/producer/core/remote.rb +++ b/lib/producer/core/remote.rb @@ -14,6 +14,10 @@ module Producer @session ||= Net::SSH.start(@hostname, Etc.getlogin) end + def fs + @fs ||= Remote::FS.new(self) + end + def execute(command) output = '' session.open_channel do |channel| diff --git a/spec/producer/core/remote_spec.rb b/spec/producer/core/remote_spec.rb index 2475f84..817fab3 100644 --- a/spec/producer/core/remote_spec.rb +++ b/spec/producer/core/remote_spec.rb @@ -29,6 +29,24 @@ module Producer::Core end end + describe '#fs' do + it 'builds a new FS' do + expect(Remote::FS).to receive(:new) + remote.fs + end + + 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 + end + end + describe '#execute', :ssh do let(:arguments) { 'some remote command' } let(:command) { "echo #{arguments}" }