Extract logic for current target ssh user name:

Add Remote#user_name method, with code returning which user name
will be used for SSH authentication.
This commit is contained in:
Thibault Jouan 2013-08-26 14:02:35 +00:00
parent 868c502531
commit 9985fceb63
2 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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)