diff --git a/lib/producer/core/remote.rb b/lib/producer/core/remote.rb index bed2936..1f4d2bc 100644 --- a/lib/producer/core/remote.rb +++ b/lib/producer/core/remote.rb @@ -11,7 +11,11 @@ module Producer end def session - @session ||= Net::SSH.start(@hostname, Etc.getlogin) + @session ||= Net::SSH.start(@hostname, user_name) + end + + def user_name + Etc.getlogin end def fs diff --git a/spec/producer/core/remote_spec.rb b/spec/producer/core/remote_spec.rb index 817fab3..1000e65 100644 --- a/spec/producer/core/remote_spec.rb +++ b/spec/producer/core/remote_spec.rb @@ -12,8 +12,8 @@ module Producer::Core end describe '#session' do - it 'builds a new SSH session to the remote host' do - expect(Net::SSH).to receive(:start).with(hostname, Etc.getlogin) + it 'builds a new SSH session to the remote host with #user_name' do + expect(Net::SSH).to receive(:start).with(hostname, remote.user_name) remote.session end @@ -29,6 +29,12 @@ module Producer::Core end end + describe '#user_name' do + it 'returns the name of the user currently logged in' do + expect(remote.user_name).to eq Etc.getlogin + end + end + describe '#fs' do it 'builds a new FS' do expect(Remote::FS).to receive(:new)